need help switching keybinds

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
flixosu
Posts: 1
Joined: 03 May 2024, 07:36

need help switching keybinds

03 May 2024, 07:42

hi! i am fairly new to ahk and i need some help.

i currently have a script that moves the mouse smoothly left and right with leftarrow and rightarrow when shift is being held down.
though i need the mouse to go left and right with a/d while maintaining the original input (so if i hold down shift+d it holds d and moves the cursor to the right)

now one thing that is crucial is that it moves the mouse smoothly (feel free to try it out for yourself) since if i use steps the mouse seems to stutter a bit.

does anyone know how i can achieve this?
thank you in advance.

Code: Select all

#Warn
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance Force  ; Ensures only one instance of the script is running.
SetBatchLines, -1  ; Sets the script's processing priority to the highest level.


+left::MouseMover("Left")
+Right::MouseMover("Right")

;EOAES

MouseMover(Key){

Speed := 1
Directions := { Left:Func("DllCaller").Bind(-Speed,0)
            ,	Right:Func("DllCaller").Bind(Speed,0)}

While (GetKeyState(Key, "P") = 1)
    Directions[Key]()
}

DllCaller(X := 0, Y := 0){
    Return DllCall("mouse_event", "UInt", 0x0001, "Int", X, "Int", Y, "UInt", 0, "UPtr", 0)
}
Rohwedder
Posts: 7706
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: need help switching keybinds

04 May 2024, 01:24

Hallo,
I interpret this as follows: If you press LShift + d, your game should only see the pressed d.
Try:

Code: Select all

#Warn
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance Force  ; Ensures only one instance of the script is running.
SetBatchLines, -1  ; Sets the script's processing priority to the highest level.
#InstallKeybdHook
LShift::Return
#IF GetKeyState("LShift","P")
left::MouseMover("Left")
Right::MouseMover("Right")
#IF
;EOAES

MouseMover(Key){

Speed := 1
Directions := { Left:Func("DllCaller").Bind(-Speed,0)
            ,	Right:Func("DllCaller").Bind(Speed,0)}

While (GetKeyState(Key, "P") = 1)
    Directions[Key]()
}

DllCaller(X := 0, Y := 0){
    Return DllCall("mouse_event", "UInt", 0x0001, "Int", X, "Int", Y, "UInt", 0, "UPtr", 0)
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: erotoman, slowwd, sn1perwild and 76 guests