New update, v3. Download page with newest version is at http://www.desiquint...om/wasdcontrols, source code for v3 is below.
Changelog for v3:[*:2576bzcr]Fixed the problem with the script suppressing drop-down menus in some games.
[*:2576bzcr]Improved performance by setting coordinates only once at runtime, instead of every 1 millisecond. =\
[*:2576bzcr]Tightened offset coordinates so that tapping a key will make the character move the shortest distance possible for better control: no more accidentally walking into fireballs. (Note: Titan Quest controls are improved, but still quite loose because TQ requires you to place clicks quite far away from the character for them to register. Torchlight controls are perfect.)
[*:2576bzcr]Allowed mouse to snap back to where the user originally placed it when no WASD buttons are pressed.WASD Controls For Torchlight, v3
; ; WASD Controls For Torchlight v3 ; Author: Desi Quintans <[email protected]> ; Website: http://www.desiquintans.com ; ; Script Function: ; Enables WASD controls in Torchlight. Works across all resolutions, and in both ; Windowed and Full-Screen modes. Does not mess up your typing outside the game. ; M key now toggles Automap (in place of A). ; F now switches weapons (in place of W). ; #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #Persistent #MaxHotkeysPerInterval, 200 SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. SetDefaultMouseSpeed, 0 ; Initialise variables. final_x_coord = 0 final_y_coord = 0 are_coordinates_initialised = 0 SetTimer, Button_Pressed, 1 return Button_Pressed: IfWinActive, Torchlight { if (are_coordinates_initialised != 1) { ; Set coordinate offsets specific to the game. This only initialises once, when the script first detects the game window ; as active. If the user changes game resolutions the script will need to be reloaded, but this is still much better ; than performing the same calculations to set the same variables with the same values every 1 millisecond. WinGetPos,,, total_width, total_height, A ; In case of running a Window, or in a resolution not matching the Desktop's. x_axis_centre := round(total_width//2) y_axis_centre := round(total_height*0.51) ; This is corrected for true horizontal movement. up_coord := y_axis_centre-round(total_height*0.05) down_coord := y_axis_centre+round(total_height*0.06) left_coord := x_axis_centre-round(total_width*0.045) right_coord := x_axis_centre+round(total_width*0.045) are_coordinates_initialised = 1 } if GetKeyState("w", "P") || GetKeyState("s", "P") || GetKeyState("a", "P") || GetKeyState("d", "P") { ; Remember the position of the mouse pointer before the WASD keys were pressed. MouseGetPos, prior_x_pos, prior_y_pos ; Use the chosen coordinates as their respective keys get pressed to direct the mouse pointer. if GetKeyState("w", "P") { final_y_coord := up_coord } else if GetKeyState("s", "P") { final_y_coord := down_coord } else { final_y_coord := y_axis_centre } if GetKeyState("a", "P") { final_x_coord := left_coord } else if GetKeyState("d", "P") { final_x_coord := right_coord } else { final_x_coord := x_axis_centre } ; Perform the directed click. This is a click-hold that immediately gets released. ; Click-hold is necessary as some games don't register a single click. Click down %final_x_coord% %final_y_coord% Click up ; Put the mouse pointer back in its original place. Sleep, 40 Click, %prior_x_pos% %prior_y_pos% Left 0 } } return #IfWinActive, Torchlight { s::Numpad2 ; Remaps intrusive keys to prevent then from opening the skill window and automap. a::Numpad4 w::Numpad8 f::w ; F now switches weapons m::a ; M now toggles automap. }WASD Controls For Titan Quest Series, v3
; ; WASD Movement For Titan Quest Series v3 ; Author: Desi Quintans <[email protected]> ; Website: http://www.desiquintans.com ; ; Script Function: ; Enables WASD controls in the Titan Quest series of RPGs. Works across all resolutions, and in both ; Windowed and Full-Screen modes. Does not mess up your typing outside the game. ; #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #Persistent #MaxHotkeysPerInterval, 200 SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. SetDefaultMouseSpeed, 0 ; Initialise variables. final_x_coord = 0 final_y_coord = 0 are_coordinates_initialised = 0 SetTimer, Button_Pressed, 1 return Button_Pressed: if WinActive("Titan Quest") || WinActive("Titan Quest: Immortal Throne") { if (are_coordinates_initialised != 1) { ; Set coordinate offsets specific to the game. This only runs once, when the script first detects the game window ; as active. If the user changes game resolutions the script will need to be reloaded, but this is still much better ; than performing the same calculations to set the same variables with the same values every 1 millisecond. WinGetPos,,, total_width, total_height, A ; In case of running a Window, or in a resolution not matching the Desktop's. x_axis_centre := round(total_width//2) y_axis_centre := round(total_height*0.575) ; This is corrected for true horizontal movement. up_coord := y_axis_centre-round(total_height*0.095) down_coord := y_axis_centre+round(total_height*0.16) left_coord := x_axis_centre-round(total_width*0.07) right_coord := x_axis_centre+round(total_width*0.07) are_coordinates_initialised = 1 } if GetKeyState("w", "P") || GetKeyState("s", "P") || GetKeyState("a", "P") || GetKeyState("d", "P") { ; Remember the position of the mouse pointer before the WASD keys were pressed. MouseGetPos, prior_x_pos, prior_y_pos ; Use the chosen coordinates as their respective keys get pressed to direct the mouse pointer. if GetKeyState("w", "P") { final_y_coord := up_coord } else if GetKeyState("s", "P") { final_y_coord := down_coord } else { final_y_coord := y_axis_centre } if GetKeyState("a", "P") { final_x_coord := left_coord } else if GetKeyState("d", "P") { final_x_coord := right_coord } else { final_x_coord := x_axis_centre } ; Perform the directed click. This is a click-hold that immediately gets released. ; Click-hold is necessary as some games don't register a single click. Click down %final_x_coord% %final_y_coord% Click up ; Put the mouse pointer back in its original place. Sleep, 40 Click, %prior_x_pos% %prior_y_pos% Left 0 } } return