Jump to content

Using Autoit to move mouse


Recommended Posts

I've created a short test script which is supposed to simply right click, move the mouse slightly, and then left click when a hotkey is pressed. However, when I press the hotkey, the function to move the mouse is not called. Am I missing something fundamental? Many thanks

HotkeySet("^{F10}", "myexit")
Func myexit()
Exit
EndFunc
 
HotKeySet("^{F11}","movemouse")
 
Func movemouse()
    
mouseclick("right")
    $pos = MouseGetPos()
MouseMove($pos[0], $pos[1] + 37, 10)
mouseclick("left")
 
 
EndFunc

EDIT: Working now!

Edited by Tricky898
Link to comment
Share on other sites

  • Developers

When this is the whole script it will end right away after it is started!

You need some sort of loop to keep the script active.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

while learning proved:

Func movemouse()
    ; mouseclick("right")
    Local $pos1 = MouseGetPos()
    MsgBox(0, "MOUSE INFO", "Mouse x,y: " & $pos1[0] & "," & $pos1[1])
    Sleep(200)
    MouseMove($pos1[0] + 20, $pos1[1] + 20, 10)
    Sleep(200)
    Local $pos2 = MouseGetPos()
    MsgBox(0, "Mouse x,y: ", "Moved at: " & $pos2[0] & "," & $pos2[1])
    ; mouseclick("left")
EndFunc
Func myexit()
    Exit
EndFunc
HotkeySet("^{F10}", "myexit")
HotKeySet("^{F11}","movemouse")
While 1
    Local $pos0 = MouseGetPos()
    ToolTip ( "Mouse x,y: " & $pos0[0] & " __ " & $pos0[1], 0, 0, "TOOLTIP title" , 1, 2)
    Sleep(200)
Wend
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
 Share

  • Recently Browsing   0 members

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