Results 1 to 18 of 18

Thread: Interaction with User help

  1. #1
    Join Date
    Aug 2016
    Posts
    44
    Mentioned
    1 Post(s)
    Quoted
    25 Post(s)

    Default Interaction with User help

    What can I use to display images and messages outside of simba? showmessage doesnt work because everytime a message appears, it appears in simba, and i need to go back to simba to close the message. So if the code is
    Simba Code:
    repeat
    until iskeydown(32);
    showmessage('You pressed enter');
    and i am using chrome when I pressed enter, I will not see the message. How do I make the message appear in one prompt but two different lines? For example:
    A
    B

    For displaying an image, can the image be displayed if the string format of the bitmap is in the script? How can I do this?

    Why does simba detect a key press or mouse click sometimes when no key or mousebutton is pressed? Do I need to do some kind of reset before using iskeydown? For example, I have:
    Simba Code:
    showmessage('Press Spacebar to start');
    repeat
    until iskeydown(32);
    showmessage('Started');
    and when I ran this code, I got the started message before pressing the spacebar. this happens rarely, but is there any way to fix it?

  2. #2
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    I think it's #13#10

    http://www.asciitable.com/

  3. #3
    Join Date
    Aug 2016
    Posts
    44
    Mentioned
    1 Post(s)
    Quoted
    25 Post(s)

    Default

    How do I use the ASCII in the string?
    #10 is Hex(A) Oct(012) Char(LF)
    #13 is Hex(D) Oct(015) Char(CR)
    Using showmessage as an example because I dont know any other message prompts-things in simba.
    showmessage('A'CR'B');?

  4. #4
    Join Date
    Aug 2016
    Posts
    44
    Mentioned
    1 Post(s)
    Quoted
    25 Post(s)

    Default

    Simba Code:
    showmessage('Are you sure? [Y/N]');
    repeat
    if iskeydown(89) then //yes
    break(); //exit procedure and go to main function
    else if iskeydown(78) then //no
    locateh(); //restart procedure
    until iskeydown(89) or iskeydown(78); //wait until one is pressed
    Whats wrong with the above code? How can I write it better?

  5. #5
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Sorry, I couldn't remember at the time so I didn't include an example
    #13 is carriage return and #10 is new line.
    Simba Code:
    writeln('line one' + #13#10 + 'line two');

    As for your second post, I'd just do something like this:
    Simba Code:
    showMessage('Are you sure' + #13#10 + '[Y/N]');
      repeat
        if isKeyDown($59) then writeln('You pressed: Y');
        if isKeyDown($4E) then writeln('You pressed: N');
        wait(100);
      until false;
    although I've never used showMessage() before.

  6. #6
    Join Date
    Aug 2016
    Posts
    44
    Mentioned
    1 Post(s)
    Quoted
    25 Post(s)

    Default

    Ok thank you. Any alternative for showmessage? showmessage only shows a message box in simba. Meaning you will not see the message box if you are using chrome. http://imgur.com/a/ho6xL

  7. #7
    Join Date
    Jan 2013
    Posts
    86
    Mentioned
    0 Post(s)
    Quoted
    25 Post(s)

    Default

    Quote Originally Posted by Treestump View Post
    Ok thank you. Any alternative for showmessage? showmessage only shows a message box in simba. Meaning you will not see the message box if you are using chrome. http://imgur.com/a/ho6xL
    ShowBalloonHint I believe?

    http://docs.villavu.com/simba/script...howballoonhint

    This will show a windows notification with your message. ^

  8. #8
    Join Date
    Jun 2014
    Posts
    463
    Mentioned
    27 Post(s)
    Quoted
    229 Post(s)

    Default

    As deejaay said, ShowBalloonHint will do just fine, or you could purchase PushOver Desktop and enable browser notifications and then have the script post to http to have a classy display.. + a log of the timestamps etc


    You can enable desktop notifications with pushover, here's what the UI looks like

    Tsunami

  9. #9
    Join Date
    Aug 2016
    Posts
    44
    Mentioned
    1 Post(s)
    Quoted
    25 Post(s)

    Default

    Am I using it correctly?
    Simba Code:
    program new;
    const
    TITLE = 'Test';
    TIMEOUT = 5000;
    FLAG = 2;
    begin
    ShowBalloonHint(TITLE, 'hello', TIMEOUT, FLAG);
    end.
    ShowBalloonHint(const Title, Hint: string; const Timeout: Integer; const Flag: TBalloonFlags)

    Is there no other way to display messages? Windows notification is okay, but it would be better if a message popped up in the middle of the screen. And any idea on how to display images? I checked out DisplayDebugImgWindow(w, h: Integer) + DrawBitmapDebugImg(Bitmap: Integer). Anything else? If not, is there a procedure to close the debugimgwindow?

  10. #10
    Join Date
    Jan 2013
    Posts
    86
    Mentioned
    0 Post(s)
    Quoted
    25 Post(s)

    Default

    Quote Originally Posted by Treestump View Post
    Am I using it correctly?
    Simba Code:
    program new;
    const
    TITLE = 'Test';
    TIMEOUT = 5000;
    FLAG = 2;
    begin
    ShowBalloonHint(TITLE, 'hello', TIMEOUT, FLAG);
    end.
    ShowBalloonHint(const Title, Hint: string; const Timeout: Integer; const Flag: TBalloonFlags)

    Is there no other way to display messages? Windows notification is okay, but it would be better if a message popped up in the middle of the screen. And any idea on how to display images? I checked out DisplayDebugImgWindow(w, h: Integer) + DrawBitmapDebugImg(Bitmap: Integer). Anything else? If not, is there a procedure to close the debugimgwindow?
    What kind of message are you trying to make show up? MufasaLayer may work if you are trying to show time running/status/other dynamic info. https://villavu.com/forum/showthread.php?t=110667

    Also your balloon hint looks like this;

    You don't have to put all those in constants btw,

    Code:
    program new;
    begin
    ShowBalloonHint('Test', 'hello', 5000, 2);
    end.
    Attached Images Attached Images

  11. #11
    Join Date
    Dec 2011
    Posts
    193
    Mentioned
    5 Post(s)
    Quoted
    51 Post(s)

    Default

    I'm intrigued to the use of this lol

    Anyway, got me curious so whipped the code below (based on debug.simba functions). It matches your need to display an Image and multiple lines of Texts in a pop up window that will pop up even if Simba isn't the currently active window. I don't mess around with this stuff much so I'm not sure there's a procedure to close the debug window (read edit), but there's not one to close a message window either, you need to click a button so it's the same with this instead you click the debug window 'x' to close.

    Function takes 2 params. First one is the path to your image file. Second is string array where each element is a new line. I've tied it to call when the 'Delete' key is pressed, remap this however you please or change its invocation entirely. If you minimise Simba, only the debug window should display without bringing the whole of Simba to front.

    Edit: Added a procedure that can close the debug (works on Windows), currently calls after 1 second of window being up. Be warned it'll actually just close the current active window, which will be the debug window provided user interaction hasn't changed it within that 1 second. Decide its usage for yourself. You can create a Simba procedure to close the debug form in your own custom Simba build, source is on github.

    Edit 2: @Treestump found a FindAndSetTarget function laying around. Debug window will be activated before Alt+F4. There's got to be a cleaner way of doing this lol but I'm too tired to know wtf it is. The absolute cleanest solution is as said above, adding your own function in your own Simba build, so if this is something you'll be using a lot and need to rely on, then that's the route.

    Simba Code:
    function FindAndSetTarget(TitlePrefix: String): Boolean;
    var
      T: TSysProcArr;
      I: Integer;
    begin
      T:= GetProcesses();
      for I := 0 to high(T) do
        if ExecRegExpr('^' + TitlePrefix, T[i].Title) then
        begin
          SetTarget(T[i]);
          ActivateClient;
          Exit(True);
        end;
    end;

    procedure CloseDebug;
    begin
      if not FindAndSetTarget('DebugImgForm') then
        Exit;

      KeyDown(VK_MENU);
      PressKey(VK_F4);
      KeyUp(VK_MENU);
    end;

    procedure debugCustom(ImageSrc: String; Texts: TStringArray);
    var
      Image, ImageW, ImageH, TextW, TextH, OffW, OffH, TextsCount, i: Integer;
      TempTPA: TPointArray;
      Box : TBox;
    begin
      try
        Image := loadBitmap(ImageSrc);
        GetBitmapSize(Image, ImageW, ImageH);
        DisplayDebugImgWindow(ImageW, ImageH);

        TextsCount := High(Texts);
        for i := TextsCount downto 0 do
        begin
          TempTPA := TPAFromText(Texts[i], 'UpChars', TextW, TextH);
          Box := GetTPABounds(TempTPA);
          OffW := (ImageW-TextW) shr 1;
          OffH := (ImageH-TextH)-((TextsCount-i)*TextH);   //from bottom
          //OffH := (TextsCount-i)*TextH;                  //from top
          OffsetTPA(TempTPA,Point(OffW, OffH));
          DrawTPABitmap(Image, TempTPA, 255);
        end;

        DrawBitmapDebugImg(Image);
        FreeBitmap(Image);
      except
        Writeln('Error in debug');
      end;
    end;

    begin

      repeat

        while not isKeyDown(VK_DELETE) do
          Wait(100);
        debugCustom('test.png', ['test','check','texty','stuff']);
          Wait(1000);
        closeDebug;

      until(false);

    end.

    OSRS Color Scripts: Borland_Salamanders | Borland_Iron_Ores
    Utilities & Snippets: [Color] OSBuddy Item Looting

  12. #12
    Join Date
    Aug 2016
    Posts
    44
    Mentioned
    1 Post(s)
    Quoted
    25 Post(s)

    Default

    debugcustom works fine. Except since closedebug just does alt+f4, it would be better to make sure the debugimg window is selected first. I think it can be done with settarget and getprocesses (idk). I decided to give up on user interaction for now but I'll definitely use the script someday.

    ive been running into an issue where simba detects a click when nothing has happened. I have
    Simba Code:
    repeat
    until ismousebuttondown(MOUSE_RIGHT);
    getmousepos(x, y);
    writeln(tostr(x));
    writeln(tostr(y));
    sometimes immediately after running the script, the values appear in debug when I havent even moved the mouse yet. How do I fix this? same goes for key presses.

  13. #13
    Join Date
    Dec 2011
    Posts
    193
    Mentioned
    5 Post(s)
    Quoted
    51 Post(s)

    Default

    Quote Originally Posted by Treestump View Post
    sometimes immediately after running the script, the values appear in debug when I havent even moved the mouse yet. How do I fix this? same goes for key presses.
    Hooking Keyboard and Mouse events is a multi decade long struggle, especially on Windows. Essentially think of the isKeyDown and IsMouseButtonDown as checking whether the key/button has been down since it was last checked. So if you've pressed the key/button since it was checked last, script running or not, it'll return positive. After the first potential false positive, it'll be reliable up until the thread is terminated/suspended (well as reliable as the length of time between checks).

    OSRS Color Scripts: Borland_Salamanders | Borland_Iron_Ores
    Utilities & Snippets: [Color] OSBuddy Item Looting

  14. #14
    Join Date
    Jun 2014
    Posts
    463
    Mentioned
    27 Post(s)
    Quoted
    229 Post(s)

    Default

    Quote Originally Posted by Treestump View Post
    snip
    I totally misunderstood your post, I just thought you wanted to display messages.

    Here check out ezForm by Obscurity.

    It has the image displaying, prompts, updating without closing and opening, drop down menus, forms, anything you could need really and on top of that you can save your settings etc.

    Hopefully this is what you've been looking for.
    Tsunami

  15. #15
    Join Date
    Sep 2014
    Location
    C:\Simba\
    Posts
    565
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default

    There's really no point in including ezForm since it's just a wrapper for simba native methods really. The little edge it gives over using Simba's own methods (which I'd argue doesn't exist) is greatly overweighed by the fact that it relies on ProSocks, meaning that it will interfere with other includes that are being kept up to date whenever ProSocks gets an update.
    Feel free to ask me any questions, I will do my best to answer them!

    Previously known as YouPee.

  16. #16
    Join Date
    Aug 2016
    Posts
    44
    Mentioned
    1 Post(s)
    Quoted
    25 Post(s)

    Default

    Why isnt this working?
    Simba Code:
    program new;
    {$i srl-6/srl.Simba}
    var
    Coords : TPointArray;
    const
    Coords := [(670, 460), (566, 464), (569, 460), (571, 458)];
    begin
    getcolors(Coords);
    end.

    I tried using
    Simba Code:
    getcolors([(670, 460), (566, 464), (569, 460), (571, 458)]);
    first but I kept getting an error, closing parenthesis expected.

    How do I use getcolor with a tolerance?
    Simba Code:
    repeat
    until (getcolor(x, y) = col); // col with a tolerance of 10.

    and how do I use dtms with points at a relative location to each other instead of set coordinates? I tried to use the dtm editor, but it has the coordinates of each point.

  17. #17
    Join Date
    Oct 2012
    Posts
    1,258
    Mentioned
    40 Post(s)
    Quoted
    588 Post(s)

    Default

    Quote Originally Posted by Treestump View Post
    Why isnt this working?
    Simba Code:
    program new;
    {$i srl-6/srl.Simba}
    var
    Coords : TPointArray;
    const
    Coords := [(670, 460), (566, 464), (569, 460), (571, 458)];
    begin
    getcolors(Coords);
    end.

    I tried using
    Simba Code:
    getcolors([(670, 460), (566, 464), (569, 460), (571, 458)]);
    first but I kept getting an error, closing parenthesis expected.

    How do I use getcolor with a tolerance?
    Simba Code:
    repeat
    until (getcolor(x, y) = col); // col with a tolerance of 10.

    and how do I use dtms with points at a relative location to each other instead of set coordinates? I tried to use the dtm editor, but it has the coordinates of each point.
    You haven't hit it yet, but you have an issue of Coords as both a variable and a constant. Your current issue is that you're unable to assign points to a TPA with that syntax.
    This would probably be what you're looking for.
    Simba Code:
    Coords := [point(670, 460), point(566, 464), point(569, 460), point(571, 458)];

  18. #18
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by Treestump View Post
    Why isnt this working?
    Use brackets, not parenthesis:
    Simba Code:
    getColors([[1, 2], [234, 432], [666, 666], [69, 69]]);
    or do what acow said.

    How do I use getcolor with a tolerance?
    http://docs.villavu.com/simba/script...colortolerance
    Last edited by Citrus; 03-04-2017 at 06:31 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •