Jump to content

mouse clicking help

Guest Scruffy

Recommended Posts

Guest Scruffy

Hey, I"m trying to make a simple script that clicks a button in an active window over and over. What would i need to do this? I think i need to use mousegetpos() and then mouseclick then something, but i dont know how to make it click in the pos that it got earlier. all the example scripts i've found don't work. any help is appreciated, thanks

Link to comment
Share on other sites

If the button has a control associated with it, you could use a ControlClick to click the button, and not have to worry about mouse coordinates. You can use the Au3_Spy.exe program to see if the button is a standard control. If so, it would show up in the "Last Control Under Mouse" section.

If it isn't a control (which will be the case if it is in a web browser window or another application that uses non-standard controls) you could use a standard MouseClick function and give the coordinates of the mouse click.

To get the coordinates, you could either hard code them into your script in terms of the active window, or prompt to hold the mouse over the button to establish the position.

Here is a small example of how you could prompt for a mouse position:

Global $pos = 0;reset position indicator
HotKeySet("{ENTER}", "getPos");set ENTER hotkey
While $pos = 0;does the loop while the coordinates have not been set
  ToolTip("Move mouse to the desired coordinates and press ENTER")
ToolTip("");remove the tooltip
HotKeySet("{ENTER}");turn off the hotkey
MsgBox(0, "Cordinates", "The coordinates you picked were: " & $pos[0] & "," & $pos[1])

Func getPos();get position function
  $pos = MouseGetPos();set $pos to escape the loop and give coordinates

To click those coordinates as discovered by the code above, just use a MouseClick function. If you want to click repeatedly, you could set the number of clicks, or use a loop to click until another hotkey is pressed.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...