I use AHK mostly for games and trying to learn from other people's solutions. These are two ways that I generally use. Both of them works in notepad since I test them in there first but not always in games and I would like the learn their differences. Can someone explain it to me or point me to where should I look in documentation?
First script:
Code: Select all
IF NOT A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
#SingleInstance force
#InstallKeybdHook
#UseHook
SetNumlockState On
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive, ahk_class DeadSpace2WndClass
#MaxThreadsPerHotkey 2
Delayp := "200"
QuickEventKey := "Xbutton1"
Hotkey, %QuickEventKey%, QuickEvent
QuickEvent:
While GetKeyState("Xbutton1", "P")
{
send, {e down}
sleep, %Delayp%
send, {e up}
sleep, %Delayp%
}
return
Code: Select all
IF NOT A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
#SingleInstance force
#InstallKeybdHook
#UseHook
SetNumlockState On
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive, ahk_class DeadSpace2WndClass
#MaxThreadsPerHotkey 2
Delayp := "200"
Xbutton1::
toggle1 := !toggle1
while toggle1
{
send, {e down}
sleep, %Delayp%
send, {e up}
sleep, %Delayp%
}
return
Excuse me for asking this part in bad wording since I don't know the correct terminology for this but how
Code: Select all
QuickEventKey := "Xbutton1"
Hotkey, %QuickEventKey%, QuickEvent
QuickEvent:
Code: Select all
Xbutton1::
Thanks