Sign in to follow this  
Followers 0
Othello

MouseClick Using Borked Coords?

8 posts in this topic

I'm having a problem with using mouse based controls, and I'm wondering if it's a problem in my script. What is supposed to hapen is at certain points it should open a contextual menu and then choose an option from the menu. This operates correctly, but on occasion it will click in the wrong place, either opening the wrong contextual menu or choosing the wrong option. At first I thought lag was the problem, so I added some sleeps to compensate, however I managed to catch it opening the menu and then going ~60 pixels too high, smooth as silk. If the problem isn't with my script, could it be rooted in the fact that it's a full screen application running at a different resolution than desktop resolution? I run 1680x1050 and the app is 1280x800. I commented the witnessed problem area, however there seem to be problems in other areas as well, but I haven't seen them as they occured. All seem to deal with the contextual menu, and it usually seems to work fine on the first run-through. My code is as follows:

Global $Singing
HotKeySet("{PAUSE}", "Sing")
opt("MouseCoordMode", 0)

While 1
    If $Singing then
        MouseClick ( "left", 14, 768 )
        Sleep (60000)
        MouseClick ( "left", 183, 141, 2 )
        Sleep (1000)
        MouseClick ( "left", 183, 141, 2 )
        Sleep (1000)
        MouseClick ( "right", 130, 175 )
        Sleep (1000)
        MouseClick ( "left", 224, 184 )
        Sleep (48000)
        MouseClick ( "right", 1158, 651 )
        Sleep (1000)
        MouseClick ( "left", 1186, 677 )
        MouseClick ( "left", 1193, 670 )
        Sleep (500)
        MouseClick ( "right", 130, 175 )
        Sleep (1000)
        MouseClick ( "left", 224, 184 )
        Send ( "{F5}" )
        MouseClick ( "left", 1060, 152 )
        Sleep (1000)
        MouseClick ( "left", 1099, 176 )
        Sleep (40000)
        MouseClick ( "left", 1114, 185 )
        Sleep (1000)
        MouseClick ( "left", 1101, 96 )
        Send ( "{F5}" )
        Sleep (25000)
        MouseClick ( "left", 1170, 94 )
        Sleep (3000)
        MouseClick ( "left", 1058, 152 )
        Sleep (1000)
        MouseClick ( "left", 1136, 163 )
        Sleep (5000)
        Send ( "{F1}{F2}{F3}{F4}" )
        Sleep (1000)
        $Ast = Random ( 184, 400, 1 )
        MouseClick ( "left", 1114, $Ast ) 
        Sleep (60000)
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (60000)
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (60000) 
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (60000)
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (60000) 
        MouseClickDrag ( "left", 341, 720, 609, 691 ) 
        Sleep (60000) 
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (60000)
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (60000)
        MouseClickDrag ( "left", 341, 720, 609, 691 ) 
        Sleep (60000)
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (60000) 
        MouseClickDrag ( "left", 341, 720, 609, 691 ) 
        Sleep (60000) 
        MouseClickDrag ( "left", 341, 720, 609, 691 ) 
        MouseClick ( "left", 1160, 94 ) 
        Sleep (63000) 
        Send ( "{F1}{F2}{F3}{F4}" ) 
        $Ast2 = Random ( 184, 400, 1 )
        MouseClick ( "left", 1114, $Ast2 )
        Sleep (1000) 
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (60000) 
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (60000) 
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (60000)
        MouseClickDrag ( "left", 341, 720, 609, 691 ) 
        Sleep (60000) 
        MouseClickDrag ( "left", 341, 720, 609, 691 ) 
        MouseClick ( "right", 670, 677 ) 
        Sleep (1000)
        MouseClick ( "left", 743, 787 )  
        Sleep (60000) 
        MouseClickDrag ( "left", 341, 720, 609, 691 ) 
        Sleep (60000) 
        MouseClickDrag ( "left", 341, 720, 609, 691 ) 
        Sleep (60000)
        MouseClickDrag ( "left", 341, 720, 609, 691 ) 
        Sleep (60000)
        MouseClickDrag ( "left", 341, 720, 609, 691 ) 
        Sleep (60000) 
        MouseClickDrag ( "left", 341, 720, 609, 691 ) 
        Sleep (60000) 
        Sleep (60000) 
        Sleep (60500) 
        MouseClick ( "left", 644, 476 ) 
        Sleep (1000) 
        MouseClick ( "right", 1193, 670 ) 
        Sleep (1000) 
        MouseClick ( "left", 1192, 730 ) 
        Sleep (20000)
        MouseClick ( "left", 91, 141, 2 ) 
        Sleep (1000) 
        MouseClick ( "left", 91, 141, 2 ) 
        Sleep (1000) 
        MouseClick ( "right", 117, 175 ) 
        Sleep (1000) 
        MouseClick ( "left", 153, 214 ) 
        Sleep (51000)
        Send ( "{F5}" ) 
        Sleep (60000) 
        MouseClick ( "left", 606, 615 ) 
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (500) 
        MouseClickDrag ( "left", 341, 720, 609, 691 ) 
        Sleep (1000)
        MouseClick ( "left", 676, 615 )
        Sleep (10000)
        MouseClick ( "right", 765, 691 );problem here
        Sleep (2000) 
        MouseClick ( "left", 822, 662 );problem here
        Sleep (1000)
        MouseClick ( "left", 14, 768 ) 
        Sleep (65000)
        MouseClick ( "left", 183, 141, 2 )
        Sleep (1000) 
        MouseClick ( "left", 183, 141, 2 ) 
        Sleep (1000) 
        MouseClick ( "right", 130, 175 ) 
        Sleep (1000) 
        MouseClick ( "left", 224, 184 )
        Sleep (55000) 
        MouseClick ( "right", 130, 175 ) 
        Sleep (1000) 
        MouseClick ( "left", 224, 184 ) 
        Send ( "{F3}" ) 
        MouseClick ( "left", 1060, 152 ) 
        Sleep (1000) 
        MouseClick ( "left", 1099, 176 )
        Sleep (42000) 
        MouseClick ( "left", 1114, 185 ) 
        Sleep (1000) 
        MouseClick ( "left", 1101, 96 ) 
        Send ( "{F3}" ) 
        Sleep (29000) 
        MouseClick ( "left", 1170, 94 )
        Sleep (2000) 
        MouseClick ( "right", 670, 677 )
        Sleep (1000) 
        MouseClick ( "left", 743, 787 ) 
        MouseClickDrag ( "left", 609, 691, 341, 720 )
        Sleep (500) 
        MouseClickDrag ( "left", 609, 691, 341, 720 )
        Sleep (500) 
        MouseClickDrag ( "left", 609, 691, 341, 720 )
        Sleep (500) 
        MouseClickDrag ( "left", 609, 691, 341, 720 ) 
        Sleep (500) 
        MouseClickDrag ( "left", 609, 691, 341, 720 )
        Sleep (500) 
        MouseClickDrag ( "left", 609, 691, 341, 720 )
        Sleep (500) 
        MouseClickDrag ( "left", 609, 691, 341, 720 )
        Sleep (500) 
        MouseClick ( "left", 91, 141, 2 )
        Sleep (1000) 
        MouseClick ( "left", 91, 141, 2 ) 
        Sleep (1000) 
        MouseClick ( "right", 117, 175 ) 
        Sleep (1000) 
        MouseClick ( "left", 153, 214 ) 
        Sleep (51000) 
        Send ( "{F3}" ) 
        Sleep (75000)
            MouseClick ( "left", 606, 615 )
        Sleep (1000) 
        MouseClickDrag ( "left", 341, 750, 609, 691 ) 
        Sleep (500) 
        MouseClickDrag ( "left", 341, 750, 609, 691 )
        Sleep (500) 
        MouseClickDrag ( "left", 341, 750, 609, 691 ) 
        Sleep (500) 
        MouseClickDrag ( "left", 341, 750, 609, 691 ) 
        Sleep (500) 
        MouseClickDrag ( "left", 341, 750, 609, 691 ) 
        Sleep (500) 
        MouseClickDrag ( "left", 341, 750, 609, 691 ) 
        Sleep (500);wait for ore
        MouseClickDrag ( "left", 341, 750, 609, 691 ) 
        Sleep (500)
        MouseClick ( "right", 670, 677 ) 
        Sleep (1500) 
        MouseClick ( "left", 743, 789 )
        Sleep (1000) 
        MouseClick ( "left", 676, 615 )
        Sleep (1500) 
        MouseClick ( "right", 614, 691 )
        Sleep (1500) 
        MouseClick ( "left", 668, 662 )
        Sleep (1000) 
        MouseClick ( "left", 1051, 291 )
        Sleep (3000)
        MouseClick ( "left", 446, 148 )
        Sleep (1000) 
        Send ("{SHIFTDOWN}")
        MouseClick ( "left", 446, 229 )
        Send ("{SHIFTup}")
        MouseClick ( "left", 76, 109 )
        Sleep (1000) 
        MouseClick ( "left", 74, 581 )
        Sleep (1000) 
        Send ("{ENTER}")
        Sleep (1000) 
        MouseClick ( "left", 1007, 10 ) 
        Sleep (1000) 
        If @HOUR = 06 Then
            ProcessClose ( "app.exe" )
            Exit
        EndIf

    Else

        Sleep (1)

    EndIf
wend

Func Sing()
    $Singing = NOT $Singing
EndFunc

Share this post


Link to post
Share on other sites



So everything else works fine? If so, then I'd have to say that it'd either be the game lagging or wrong coordinates. Try getting those coords again and make sure you're not accidently moving an in game window or something to that effect. If all else fails, report back here and we'll take a more aggresive approach.

(Why did I end that talking like a army general? Maybe I've been here too long...)

Share this post


Link to post
Share on other sites

So everything else works fine? If so, then I'd have to say that it'd either be the game lagging or wrong coordinates. Try getting those coords again and make sure you're not accidently moving an in game window or something to that effect. If all else fails, report back here and we'll take a more aggresive approach.

(Why did I end that talking like a army general? Maybe I've been here too long...)

I had made sure to doublecheck the coords and have been watching the script activate. Most of the time the mouse seems to go in the right direction, atleast on the first run through. I'm running it and watching it right now actually (I use it on my laptop).

Share this post


Link to post
Share on other sites

Well, it says you're posting but you've been "posting" for the last 30 minutes... Anyhow, if a script works right MOST of the time and it's looping and not changing/relying on variables, that tells me that it's not the script. I think the only solution is some detective work on your part. Just got an idea... Check the pixel color before it clicks and if it doesn't match, have it print screen and exit. Just an idea though. If the app is popular, maybe people familiar with it might now what's up if you tell us.

Share this post


Link to post
Share on other sites

are you sure that the mouseclicks always are on the good place?


-jaenster

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Oxin8, I have a feeling you're right, I was just hoping I'd screwed something up as that;d make it about 10 times easier to fix :lmao: Pixel searching isn't possible as the menu is basically a solid gray background with white text, so every option would return a positive result. I have seen some nifty code here that can build font recognition databases based on pixel searching, so if worse comes to worse I can alsways go that route...

jaenster - well that's sort of the problem. It seems like it's clicking the right place at first, but on subsequent loops it clicks the wrong area. None of the windows or menus are changing position, everything's been the same for the last... 5 or 6 days.

I'm going to try increasing the sleeps and making mouse movement instant to see if that improves matters. Thanks for the help so far ;)

Edit: Nope, didn't work. Here's what I don't understand... I've been working on this script for ~6 days. The first version worked perfectly and without incident, while this version can't even run past a single loop without it going bonkos. Guess I'm going to have to work backwards until I fix it..

Edited by Othello

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Since it appears that a lot of the movements are repetative, you could clean it up with some loops and functions for repeated things.

Edit: Turned some of the repeating stuff into For loops. I hope I didn't mess anything up.... Try commenting the code by section like "Select Character" "Pickup Axe" "Move Forward" and such. Oh, and i didn't mean pixel search, I meant:

Returns a pixel color according to x,y pixel coordinates.

PixelGetColor ( x , y )

Here's the code:

Global $Singing
HotKeySet("{PAUSE}", "Sing")
opt("MouseCoordMode", 0)

While 1
    If $Singing then
        MouseClick ( "left", 14, 768 )
        Sleep (60000)
        MouseClick ( "left", 183, 141, 2 )
        Sleep (1000)
        MouseClick ( "left", 183, 141, 2 )
        Sleep (1000)
        MouseClick ( "right", 130, 175 )
        Sleep (1000)
        MouseClick ( "left", 224, 184 )
        Sleep (48000)
        MouseClick ( "right", 1158, 651 )
        Sleep (1000)
        MouseClick ( "left", 1186, 677 )
        MouseClick ( "left", 1193, 670 )
        Sleep (500)
        MouseClick ( "right", 130, 175 )
        Sleep (1000)
        MouseClick ( "left", 224, 184 )
        Send ( "{F5}" )
        MouseClick ( "left", 1060, 152 )
        Sleep (1000)
        MouseClick ( "left", 1099, 176 )
        Sleep (40000)
        MouseClick ( "left", 1114, 185 )
        Sleep (1000)
        MouseClick ( "left", 1101, 96 )
        Send ( "{F5}" )
        Sleep (25000)
        MouseClick ( "left", 1170, 94 )
        Sleep (3000)
        MouseClick ( "left", 1058, 152 )
        Sleep (1000)
        MouseClick ( "left", 1136, 163 )
        Sleep (5000)
        Send ( "{F1}{F2}{F3}{F4}" )
        Sleep (1000)
        $Ast = Random ( 184, 400, 1 )
        MouseClick ( "left", 1114, $Ast )
        For $i = 1 to 11
        Sleep (60000)
            MouseClickDrag ( "left", 341, 720, 609, 691 )
    Next
        Sleep (60000)
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        MouseClick ( "left", 1160, 94 )
        Sleep (63000)
        Send ( "{F1}{F2}{F3}{F4}" )
        $Ast2 = Random ( 184, 400, 1 )
        MouseClick ( "left", 1114, $Ast2 )
        Sleep (1000)
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (60000)
        For $i = 1 to 4
        Sleep (60000)
            MouseClickDrag ( "left", 341, 720, 609, 691 )
    Next
        MouseClick ( "right", 670, 677 )
        Sleep (1000)
        MouseClick ( "left", 743, 787 )  
        For $i = 1 to 5
        Sleep (60000)
            MouseClickDrag ( "left", 341, 720, 609, 691 )
    Next
        Sleep (60000)
        Sleep (60000)
        Sleep (60500)
        MouseClick ( "left", 644, 476 )
        Sleep (1000)
        MouseClick ( "right", 1193, 670 )
        Sleep (1000)
        MouseClick ( "left", 1192, 730 )
        Sleep (20000)
        MouseClick ( "left", 91, 141, 2 )
        Sleep (1000)
        MouseClick ( "left", 91, 141, 2 )
        Sleep (1000)
        MouseClick ( "right", 117, 175 )
        Sleep (1000)
        MouseClick ( "left", 153, 214 )
        Sleep (51000)
        Send ( "{F5}" )
        Sleep (60000)
        MouseClick ( "left", 606, 615 )
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (500)
        MouseClickDrag ( "left", 341, 720, 609, 691 )
        Sleep (1000)
        MouseClick ( "left", 676, 615 )
        Sleep (10000)
        MouseClick ( "right", 765, 691 );problem here
        Sleep (2000)
        MouseClick ( "left", 822, 662 );problem here
        Sleep (1000)
        MouseClick ( "left", 14, 768 )
        Sleep (65000)
        MouseClick ( "left", 183, 141, 2 )
        Sleep (1000)
        MouseClick ( "left", 183, 141, 2 )
        Sleep (1000)
        MouseClick ( "right", 130, 175 )
        Sleep (1000)
        MouseClick ( "left", 224, 184 )
        Sleep (55000)
        MouseClick ( "right", 130, 175 )
        Sleep (1000)
        MouseClick ( "left", 224, 184 )
        Send ( "{F3}" )
        MouseClick ( "left", 1060, 152 )
        Sleep (1000)
        MouseClick ( "left", 1099, 176 )
        Sleep (42000)
        MouseClick ( "left", 1114, 185 )
        Sleep (1000)
        MouseClick ( "left", 1101, 96 )
        Send ( "{F3}" )
        Sleep (29000)
        MouseClick ( "left", 1170, 94 )
        Sleep (2000)
        MouseClick ( "right", 670, 677 )
        Sleep (1000)
        MouseClick ( "left", 743, 787 )
        MouseClickDrag ( "left", 609, 691, 341, 720 )
        For $i = 1 to 6
        Sleep (500)
            MouseClickDrag ( "left", 609, 691, 341, 720 )
    Next
        Sleep (500)
        MouseClick ( "left", 91, 141, 2 )
        Sleep (1000)
        MouseClick ( "left", 91, 141, 2 )
        Sleep (1000)
        MouseClick ( "right", 117, 175 )
        Sleep (1000)
        MouseClick ( "left", 153, 214 )
        Sleep (51000)
        Send ( "{F3}" )
        Sleep (75000)
            MouseClick ( "left", 606, 615 )
        Sleep (1000)
    For $i = 1 to 6
            MouseClickDrag ( "left", 341, 750, 609, 691 )
            Sleep (500);wait for ore
        Next
    MouseClick ( "right", 670, 677 )
        Sleep (1500)
        MouseClick ( "left", 743, 789 )
        Sleep (1000)
        MouseClick ( "left", 676, 615 )
        Sleep (1500)
        MouseClick ( "right", 614, 691 )
        Sleep (1500)
        MouseClick ( "left", 668, 662 )
        Sleep (1000)
        MouseClick ( "left", 1051, 291 )
        Sleep (3000)
        MouseClick ( "left", 446, 148 )
        Sleep (1000)
        Send ("{SHIFTDOWN}")
        MouseClick ( "left", 446, 229 )
        Send ("{SHIFTUP}")
        MouseClick ( "left", 76, 109 )
        Sleep (1000)
        MouseClick ( "left", 74, 581 )
        Sleep (1000)
        Send ("{ENTER}")
        Sleep (1000)
        MouseClick ( "left", 1007, 10 )
        Sleep (1000)
        If @HOUR = 06 Then
            ProcessClose ( "app.exe" )
            Exit
        EndIf

    Else

        Sleep (1)

    EndIf
wend

Func Sing()
    $Singing = NOT $Singing
EndFunc
Edited by Oxin8

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Since it appears that a lot of the movements are repetative, you could clean it up with some loops and functions for repeated things.

Edit: Turned some of the repeating stuff into For loops. I hope I didn't mess anything up.... Try commenting the code by section like "Select Character" "Pickup Axe" "Move Forward" and such. Oh, and i didn't mean pixel search, I meant:

Here's the code:

What's funny is I just finished (literally 5 mins ago) making all the repeats into for loops myself.. thanks for doing it too though :lmao:

I do have my code commented actually, I just took it out to save space for posting.

Right now what I'm doing is taking out various enhancements I made to the code and testing to see if they fix the problem, that way I can know what's messing everything up. Right now I'm testing to make sure I did the For loops right, but then I'll start debugging again.

edit: weirdest thing... i took out the second random (setting $Ast2), and raised mouse speed to 20, and lowered all loops to 1 or 2 and it runs fine. I added in the second rand again and it still seems to work, so I'm going to up the loops to full value and test that. if it all works, then the mouse was moving too fast. If it doesnt work, I'll just go insane.

edit edit: well, it works. my guess is that the mouse was moving too fast and confsing the app, or that the timing was slightly off.

Edited by Othello

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0