Sign in to follow this  
Followers 0
Tricky898

Using Autoit to move mouse

6 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

How long does your script run?

As far as I can see it will just run and then exit immediately.

Try adding a loop at the end:

While 1
    Sleep(200)
Wend
Edited by hannes08

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

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.


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Ah, silly me, I thought it would be something simple like this !

Thanks a lot - will give it another try.

EDIT: Got it working!

Edited by Tricky898

Share this post


Link to post
Share on other sites

@someone of moderators:

is acceptable to the policy of the forum to send other results pertinent to the discussion ?

Share this post


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

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