Jump to content

[Help] Mouse commands and Hotkeys


Recommended Posts

Hello,

I was just messing around with a script and came across an odd behavior.

Heres my code:

HotKeySet("{PAUSE}", "End1")
while 1
    $pos = MouseGetPos()
    MouseMove($pos[0]-50, $pos[1], 0)
    MouseMove($pos[0], $pos[1], 0)
WEnd
Func End1()
   Exit
EndFunc

When I run it, the mouse shifts back and forth very fast, but if I move it at all, it has a tendency to move to the left of the screen.

If I add a 1 ms Sleep in between each command, it doesn't do it quite as much (very rarely). Why does this happen?

Also on an unrelated note, how does the HotKeySet function work? I.E. Whats the C++ equivalent of the command? I've always been wary about hotkeys as they're usually finicky and it just watches at a high frequency (higher workload than necesary, or lower frequency and its not accurate enough) for a key to be pressed, but it feels like AutoIt's Hotkey function is different, like maybe it reads directly from the input queue of the OS and then nulls the command once it sees a hotkey pressed? Idk.

Thanks!

Link to comment
Share on other sites

Hi and welcome to the forums!!

Also on an unrelated note, how does the HotKeySet function work? I.E. Whats the C++ equivalent of the command? I've always been wary about hotkeys as they're usually finicky and it just watches at a high frequency (higher workload than necesary, or lower frequency and its not accurate enough) for a key to be pressed, but it feels like AutoIt's Hotkey function is different, like maybe it reads directly from the input queue of the OS and then nulls the command once it sees a hotkey pressed? Idk.

A polling hotkey doesn't sound like it would be a useful hotkey... It would be more like _IsPressed(). Anyway, a quick Google search on "msdn hotkey" and you have it. RegisterHotKey.
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...