Sign in to follow this  
Followers 0
Artisan

Why doesn't MouseClick work?!

3 posts in this topic

Here's the code section that's misbehaving:

Sleep(1000)
$ThisX = Int(($MaxX + $MinX) / 2)
$ThisY = Int(($MaxY + $MinY) / 2)
Click($ThisX, $ThisY)

Sleep(1000)
Do
    Sleep(500)
    MouseMove(502, 445, 0)
Until MouseGetCursor() == 16
If PixelGetColor(401, 267) == 0xFFFFFF Then $Wave += 1
Click(500, 455)

And here's the Click() function it calls:

Func Click($x, $y)
    Do
        Sleep(200)
        MouseMove($x, $y, 0)
    Until MouseGetCursor() == 16
    MouseClick("primary", $x, $y, 1, 0)
    Sleep(200)
EndFunc

I'm writing this as an interface to a flash game. When Click($ThisX, $ThisY) happens, the game should go boom (the character should shoot). It doesn't. No shooting actually happens until the script gets to Click(500, 455) at the bottom of that block. I know it enters the Click() routine - a ConsoleWrite() test informed me that it's entering Click() where it should AND it's receiving correct parameters. Click() can't exit until a successful click happens. The game itself is highly responsive to clicking, so it's not that the game is missing the click. (Also, this bug happens 100% of the time.) But no click actually takes place. I'm really confused on what I've got screwed up. I use that same Click() function in many places throughout the script, and this is the only place it doesn't work. I've tested with a straight MouseClick() call, no dice. I've added in an extra Click() call, still no dice. The script just does NOT want to execute a mouse click at that point. I don't have anything running that takes over the mouse or anything else dumb like that - I'm only running SciTE, a web browser, and AutoIt. I'm running Windows 7 x64 bit with the latest version of AutoIt. And I've tried both AutoIt x64 and AutoIt x32. I'm officially out of ideas. I can post more info as needed. Help please?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Oops. I think I'm on the track to finding it. Further testing has indicated that the Y-axis is getting screwed up. It's still in a valid click area, but not where I expected it to be. I'll post again if I can't get it cleared up.

EDIT: Well, it's cleared up, so there's no need for a new post. What I thought was progress was an artifact from prior testing. After correcting that, I swapped the Click() for a manual MouseClick() (again). And it worked this time. I switched back to Click() and now it's working too. And it's EXACTLY how I had it before. *shrug* I dunno... Well, it's solved, I guess. I just hope it doesn't break again...

Edited by Artisan

Share this post


Link to post
Share on other sites

Oops. I think I'm on the track to finding it. Further testing has indicated that the Y-axis is getting screwed up. It's still in a valid click area, but not where I expected it to be. I'll post again if I can't get it cleared up.

global $MaxX,$Maxy
$MinX = 1
$MinY = 1
$ThisX = Int(($MaxX + $MinX) / 2)
$ThisY = Int(($MaxY + $MinY) / 2)
Click($ThisX, $ThisY)

Sleep(1000)
Do
    Sleep(500)
    MouseMove(502, 445, 0)
Until MouseGetCursor() == 16
If PixelGetColor(401, 267) == 0xFFFFFF Then $Wave += 1
Click(500, 455)

Func Click($x, $y)
    Do
        Sleep(200)
        MouseMove($x, $y, 0)
    Until MouseGetCursor() == 16
    MouseClick("primary", $x, $y, 1, 0)
    Sleep(200)
EndFunc

works fine for me, too bad i didnt add exit function caz i ended up with getting my mouse stuck at 0,0 unable to move and click exit tray :mellow:

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