Results 1 to 15 of 15

Thread: Searching for a color/icon and doing something when it finds it

  1. #1
    Join Date
    Feb 2015
    Posts
    57
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default Searching for a color/icon and doing something when it finds it

    Hello,

    I'm fairy new to all this and am going to get bashed for asking this I bet. However, I have read over some tutorials and beginner's guides and haven't had any luck.

    What I need help with and need to know how to do since I have no clue at the moment is:
    Have a script that keeps checking for a color/icon in-game on rs3, possibly by color or DTM's and then pressing a key on the keyboard if it sees the color popup.

    I honestly have no clue how to do this. Some help would be awesome. If you have Skype and want to chat about this, please leave me your skype here or via PM and I will add you.

    THanks so much and I apologize for the dumb question.

  2. #2
    Join Date
    Sep 2014
    Posts
    447
    Mentioned
    10 Post(s)
    Quoted
    203 Post(s)

    Default

    What in particular are you looking for? It'd be easier to help I knew, as there are a bunch of different possible cases in which a problem like this can occur.

  3. #3
    Join Date
    Feb 2015
    Posts
    57
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default

    A script that keeps running looking/waiting for a specific color/icon to pop up in a certain tab.. for example, keep looking for the smiley face icon to pop up in the friend chat's tab on rs3.

    So pretty much just have my rs3 acc logged in with the friend chat's tab open and the script constantly searching for the icon/colors of the smiley rank to pop up in the tab.

  4. #4
    Join Date
    Sep 2014
    Posts
    447
    Mentioned
    10 Post(s)
    Quoted
    203 Post(s)

    Default

    I think looking for a DTM or Bitmap would be your best bet!

    Take a look at the tutorial here for DTMs: https://villavu.com/forum/showthread.php?t=77691
    And here is a tutorial for finding bitmaps: https://villavu.com/forum/showthread.php?t=47374

    Once you feel like you understand how that works, your script should be doing something called polling. Every few hundred milliseconds or so, it should be looking in a TBox for the bitmap, and once it does find it, then you can call some other function. A general outline would be something like:

    Simba Code:
    procedure example();
     smileyDTM : integer;
     friendChatBoxBounds : TBox;
    begin
     smileyDTM := DTMFromString(\\Insert DTM String here);
     friendChatBoxBounds := intToBox(\\Insert box dimensions here)
     repeat
       wait(500); //wait 500 ms between searches
     until findDTM(smileyDTM, x, y, friendChatBoxBounds);

      //Insert code to do something once the DTM has been found
    end;

    This is a quite simple loop, and you shouldn't use it in your script (because it can loop infinitely). If you are confused about loops, booleans, and other code structure, I'd advise you to take another look at the basic scripting tutorial by The Mayor.

    Hope this helps somewhat!

  5. #5
    Join Date
    Feb 2015
    Posts
    57
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default

    Thank you so much!

    I will do some studying and learning. I had already started to look into DTMs. It's good to know I was on the right track!

  6. #6
    Join Date
    Feb 2015
    Posts
    57
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default

    I have this right now. I tried making a test script to see if it found my DTM or not. But even when the DTM isn't on screen it still says it found it.

    How can I make this so it tells me whether the DTM was found or not?

    Code:
    program BloodRune;
      {$I SRL-6/SRL.simba} 
    var
      icon : integer;
    begin//Begins program.
      ClearDebug;
      SetupSRL;
      icon := DTMFromString('mbQAAAHicY2VgYPBnYmDwYYLQvkDsCcStjBDcBcQNQFwPxFyBU4CqHSB0qQgYiwFF0DEjFgwGACNaB8s=');
        Writeln('Located Icon');
        FreeDTM(icon);
    end.//

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

  8. #8
    Join Date
    Jan 2007
    Location
    Not here
    Posts
    1,604
    Mentioned
    2 Post(s)
    Quoted
    19 Post(s)

    Default

    Quote Originally Posted by trips View Post
    I have this right now. I tried making a test script to see if it found my DTM or not. But even when the DTM isn't on screen it still says it found it.

    How can I make this so it tells me whether the DTM was found or not?

    Code:
    program BloodRune;
      {$I SRL-6/SRL.simba} 
    var
      icon : integer;
    begin//Begins program.
      ClearDebug;
      SetupSRL;
      icon := DTMFromString('mbQAAAHicY2VgYPBnYmDwYYLQvkDsCcStjBDcBcQNQFwPxFyBU4CqHSB0qQgYiwFF0DEjFgwGACNaB8s=');
        Writeln('Located Icon');
        FreeDTM(icon);
    end.//
    You're missing a couple of bits. You created a variable called "icon" and you also correctly assigned the DTM to this "icon" variable but this by itself doesn't do anything. You then need to prompt the script to look for the DTM you assigned to "icon" within an area using findDTM. I haven't scripted in colour for a while but this might work, have a read through it.

    Simba Code:
    program BloodRune;
      {$I SRL-6/SRL.simba}
    var
      icon : integer;
      boxToLookIn : TBox;
    begin//Begins program.
      ClearDebug;
      SetupSRL;
      icon := DTMFromString('mbQAAAHicY2VgYPBnYmDwYYLQvkDsCcStjBDcBcQNQFwPxFyBU4CqHSB0qQgYiwFF0DEjFgwGACNaB8s=');
      boxToLookIn := intToBox(0, 0, 800, 600) //The area to look for "icon" between in pixels
      if findDTM(icon, x, y, boxToLookIn) then //if we find the DTM called "icon" then
        Writeln('Located Icon');
      FreeDTM(icon);
    end.//
    Sleeping...

  9. #9
    Join Date
    Feb 2015
    Posts
    57
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default

    Quote Originally Posted by rkroxpunk View Post
    You're missing a couple of bits. You created a variable called "icon" and you also correctly assigned the DTM to this "icon" variable but this by itself doesn't do anything. You then need to prompt the script to look for the DTM you assigned to "icon" within an area using findDTM. I haven't scripted in colour for a while but this might work, have a read through it.

    Simba Code:
    program BloodRune;
      {$I SRL-6/SRL.simba}
    var
      icon : integer;
      boxToLookIn : TBox;
    begin//Begins program.
      ClearDebug;
      SetupSRL;
      icon := DTMFromString('mbQAAAHicY2VgYPBnYmDwYYLQvkDsCcStjBDcBcQNQFwPxFyBU4CqHSB0qQgYiwFF0DEjFgwGACNaB8s=');
      boxToLookIn := intToBox(0, 0, 800, 600) //The area to look for "icon" between in pixels
      if findDTM(icon, x, y, boxToLookIn) then //if we find the DTM called "icon" then
        Writeln('Located Icon');
      FreeDTM(icon);
    end.//
    Thanks so much, that makes a lot more sense to me. I knew what I was doing wrong but didn't know how to diagnose it and explain it.. therefor I couldn't fix it! Thanks a lot.

    Now, would what you provided give an error because x, y, aren't being declared at the top under var?

    Code:
    Var
    icon, X, Y:Integer;
    Not sure! Just learning

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

    Default

    Quote Originally Posted by trips View Post
    Now, would what you provided give an error because x, y, aren't being declared at the top under var?

    Code:
    Var
    icon, X, Y:Integer;
    Not sure! Just learning
    Yes, they just need to be declared as variables. If the DTM is found, its position will be stored in those variables. You can then do something like mouse(x, y);

  11. #11
    Join Date
    Feb 2015
    Posts
    57
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default

    Ok so I've managed to come up with a good script that repeats itself on a loop and ends if it finds the DTM thanks to you guys who helped. Such a great help!

    However, instead of executing the script when it finds the dtm I want it to press enter on my keyboard..

    This is what I have so far. (Major thanks to the people above



    NVM!

    Code:
        begin
      KeyDown(13);
      KeyUp(13);
      end;
    That's what did it for me :P

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

    Default

    Since you're using SRL-6, you can just use typeSend.
    Simba Code:
    typeSend('', true);
    should just hit enter

  13. #13
    Join Date
    Feb 2015
    Posts
    57
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    Since you're using SRL-6, you can just use typeSend.
    Simba Code:
    typeSend('', true);
    should just hit enter
    That worked as well.

    How would you suggest detecting a certain word in a specific box? I couldn't use a DTM based on the color of the text because there is another color of text just like it right next to the word that needs to be clicked.

    Do you recon it would be alright doing so as long as I make it search within the coords I want to click specifically?

    Edit:
    It might be dumb, but could you use a DTM to detect a certain character? Like for example, say I wanted to locate the char "#" could I use a dtm to do so?

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

    Default

    Quote Originally Posted by trips View Post
    That worked as well.

    How would you suggest detecting a certain word in a specific box? I couldn't use a DTM based on the color of the text because there is another color of text just like it right next to the word that needs to be clicked.

    Do you recon it would be alright doing so as long as I make it search within the coords I want to click specifically?

    Edit:
    It might be dumb, but could you use a DTM to detect a certain character? Like for example, say I wanted to locate the char "#" could I use a dtm to do so?
    Haha don't worry about sounding dumb. Everyone has to start somewhere.
    Simba has a lot of text-reading capability. Where exactly are you looking for text?

  15. #15
    Join Date
    Feb 2015
    Posts
    57
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    Haha don't worry about sounding dumb. Everyone has to start somewhere.
    Simba has a lot of text-reading capability. Where exactly are you looking for text?
    within a tab such as the friends list.

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
  •