Jump to content

Make _IsPressed() like HotKeySet?


Recommended Posts

Hello, I'm creating a way to move your mouse cursor with the arrow keys. I would like it so the keys don't let windows perform the functions they normally do. I do not want to use HotKeySet() because there is a delay in the action ending. I am using

Ex:

If _IsPressed() Then
MouseMove(x, y+1, 0)
EndIf

You get the idea. So, is there a way to make it so only my functions happen when these buttons are pressed?

Edited by Donald8282
Link to comment
Share on other sites

Try something like that:

#include <Misc.au3>
HotKeySet("{ESC}", "_Exit")

$dll = DllOpen("user32.dll")
$speed = 1
$acc = 1

While Sleep(10)
    $aMPos = MouseGetPos()
    If _IsPressed("25", $dll) And _IsPressed("12", $dll) Then ;alt + left
        MouseMove($aMPos[0] - $speed, $aMPos[1])
        $speed += $acc
    ElseIf _IsPressed("27", $dll) And _IsPressed("12", $dll) Then ;alt + right
        MouseMove($aMPos[0] + $speed, $aMPos[1])
        $speed += $acc
    ElseIf _IsPressed("26", $dll) And _IsPressed("12", $dll) Then ;alt + up
        MouseMove($aMPos[0], $aMPos[1] - $speed)
        $speed += $acc
    ElseIf _IsPressed("28", $dll) And _IsPressed("12", $dll) Then ;alt + down
        MouseMove($aMPos[0], $aMPos[1] + $speed)
        $speed += $acc
    Else
        $speed = 1
    EndIf
WEnd

Func _Exit()
    DllClose($dll)
    Exit
EndFunc

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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