Jump to content

Using Autoit to control Windows Mousekeys


Recommended Posts

Hi. I'm very new to Autoit and writing scripts as a whole. However, I've had a look through the help files, and read the FAQ on the wiki but can't find a solution.

I have no real application for this, but am just experimenting and am wondering how I can use a script to hold down CTRL and press and numpad number in order to move the mouse.

I tried using:

send("{Ctrldown}")
send("{NUMPAD8}")
send("{Ctrlup}")

as this is what I physically press to get the mouse to shift upwards using mousekeys. However, nothing happens. Any help would be appreciated. Thanks :)

Link to comment
Share on other sites

Something like this?

Global $var,$movment = 10

HotKeySet("^{NUMPAD8}","up")
HotKeySet("^{NUMPAD2}","down")
HotKeySet("^{NUMPAD4}","left")
HotKeySet("^{NUMPAD6}","right")

While 1
    Sleep(10)
WEnd

Func up()
    $var = MouseGetPos()
    If $var[1] - $movment > 0 Then
        $var[1] -= $movment
        MouseMove($var[0],$var[1],0)
    Else
        MouseMove($var[0],0,0)
    EndIf
EndFunc

Func down()
    $var = MouseGetPos()
    If $var[1] + $movment < @DesktopHeight Then
        $var[1] += $movment
        MouseMove($var[0],$var[1],0)
    Else
        MouseMove($var[0],@DesktopHeight,0)
    EndIf
EndFunc

Func left()
    $var = MouseGetPos()
    If $var[0] - $movment > 0 Then
        $var[0] -= $movment
        MouseMove($var[0],$var[1],0)
    Else
        MouseMove(0,$var[1],0)
    EndIf
EndFunc

Func right()
    $var = MouseGetPos()
    If $var[0] + $movment < @DesktopWidth Then
        $var[0] += $movment
        MouseMove($var[0],$var[1],0)
    Else
        MouseMove(@DesktopWidth,$var[1],0)
    EndIf
EndFunc

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Something like this?

Global $var,$movment = 10

HotKeySet("^{NUMPAD8}","up")
HotKeySet("^{NUMPAD2}","down")
HotKeySet("^{NUMPAD4}","left")
HotKeySet("^{NUMPAD6}","right")

While 1
    Sleep(10)
WEnd

Func up()
    $var = MouseGetPos()
    If $var[1] - $movment > 0 Then
        $var[1] -= $movment
        MouseMove($var[0],$var[1],0)
    Else
        MouseMove($var[0],0,0)
    EndIf
EndFunc

Func down()
    $var = MouseGetPos()
    If $var[1] + $movment < @DesktopHeight Then
        $var[1] += $movment
        MouseMove($var[0],$var[1],0)
    Else
        MouseMove($var[0],@DesktopHeight,0)
    EndIf
EndFunc

Func left()
    $var = MouseGetPos()
    If $var[0] - $movment > 0 Then
        $var[0] -= $movment
        MouseMove($var[0],$var[1],0)
    Else
        MouseMove(0,$var[1],0)
    EndIf
EndFunc

Func right()
    $var = MouseGetPos()
    If $var[0] + $movment < @DesktopWidth Then
        $var[0] += $movment
        MouseMove($var[0],$var[1],0)
    Else
        MouseMove(@DesktopWidth,$var[1],0)
    EndIf
EndFunc

Thanks, yeah that works as an alternative to Windows Mousekeys. However, I was wondering if a script could be created to replicate me pressing, say, CTRL+Num8 which would moev the mouse up by getting Autoit to hit those keys for me.

An easier alternative at this stage would be to just get a script to run the functions in the code above, instead of trying to press the keys for Mousekeys, so thanks :)

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...