Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#InstallMouseHook
#installKeybdHook
Coordmode, MouseGetPos, Relative
#HotkeyInterval 1000 ; Prevent Script from bugging out when you press the keys too quickly in succession.
Esc::ExitApp ; Exit script with Escape key
^!s::Suspend ; Suspend script with Ctrl+Alt+S
w::Up
s::Down
a::Left
d::Right
MouseGetPos, xpos, ypos
if xpos != 0 and ypos != 0
{
if GetKeyState(LButton, Down) == true
{
if Abs(xpos) > Abs(ypos)
{
if xpos > 0
{
ControlSend,, Right
}
if xpos < 0
{
ControlSend,, Left
}
}
if Abs(xpos) < Abs(ypos)
{
if ypos > 0
{
ControlSend,, Right
}
if ypos < 0
{
ControlSend,, Left
}
}
}
}
[Mod action: Topic moved from "Ask for Help (v2)" since this is v1 code.]