Code: Select all
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
DllCall("ntdll\ZwSetTimerResolution","Int",5000,"Int",1,"Int*",MyCurrentTimerResolution)
GroupAdd, gw2, Guild Wars 2
GroupAdd, gw2, `.0 0 0
#IfWinActive ahk_group gw2
DllCall("Sleep","UInt",1) ;I just slept exactly 1ms!
DllCall("ntdll\ZwDelayExecution","Int",0,"Int64*",-5000) ;you can use this to sleep in increments of 0.5ms if you need even more granularity
RButton::evaluateButton("RButton", "F1")
Wheelup::evaluateButton("Wheelup", "8")
Wheeldown::evaluateButton("Wheeldown", "7")
evaluateButton(Button1, Button2)
{
if (isMouseShown()) {
send {%Button1% Down}
KeyWait, RButton
send {%Button1% Up}
}
else {
send {%Button2% Down}
KeyWait, % "{" A_ThisHotkey "}"
send {%Button2% Up}
}
}
isMouseShown()
{
StructSize := A_PtrSize + 16
VarSetCapacity(InfoStruct, StructSize)
NumPut(StructSize, InfoStruct)
DllCall("GetCursorInfo", UInt, &InfoStruct)
Result := NumGet(InfoStruct, 8)
return (Result != 0)
}