Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Description:
- This script enables traditional WASD movements for Diablo III.
- The default keys are:
- North - W
- West - A
- South - S
- East - D
- The keys can be combined to produce a total of 8 directions (4 ordinal and 4 diagonal). The directions are relative to the
- screen, meaning north is moving towards the top of the screen, west is moving towards the left of the screen, and so on.
- Use Instructions:
- 1) Run this script with AutoHotKey
- 2) Start Diablo III within 60 seconds of step 1
- 3) If this is your first time running this script remove bindings for the "W" "A" "S" and "D" keys in Diablo III. If any
- action is bound to one of the keys used for movement by this script the action would be performed in addition to the
- movement. Keep in mind if you edit this script to use another keyset the same rule applies to those keys
- 4) Bind the F12 key on your keyboard to the Move action.
- NOTE:
- If you change the resolution of the game at any point after running the script, you must reload the script for it to function properly
- */
- #NoEnv ; Prevents bugs caused by environmental variables matching those in the script
- #Persistent ; Allows the script to stay active and makes it single-instance
- #MaxHotkeysPerInterval, 200 ; Safeguard to prevent accidental infinite-looping of events
- SendMode Input ; Avoids the possible limitations of SendMode Play, increases reliability.
- SetWorkingDir %A_ScriptDir% ; Sets the script's working directory
- SetDefaultMouseSpeed, 0 ; For character movement without moving the cursor
- SetTitleMatchMode, 3 ; Window title must exactly match Winactive("Diablo III")
- ; BEGIN config section -- you can change the variables below to your specific needs
- mkey = F12 ; key bound to Move command in game
- y_offset = 10 ; distance from character to issue move command on the y-axis (used to calculate the x_offset to maintain aspect ratios)
- ; END config section
- OnExit, Agent_Kill
- WinWaitActive, Diablo III, , 60 ; this command waits for Diablo III to be the active window to get window information
- if ErrorLevel
- {
- MsgBox, Diablo III not started within the allotted time. Please run the script again then start Diablo III
- ExitApp
- }
- else
- {
- Sleep 500
- WinGetPos, win_x, win_y, width, height, A
- x_center := win_x + width / 2
- compensation := (width / height) == (16 / 10) ? 1.063829 : 1.063711
- y_center := win_y + height / 2 / compensation
- offset_mod := y_offset / height
- x_offset := width * offset_mod
- }
- SetTimer, WASD_Handler, 10
- return
- Agent_Kill: ; kills Agent.exe if it is still running after Diablo and the script close
- if !WinExist("Diablo III")
- {
- Process, Close, Agent.exe
- }
- ExitApp
- return
- WASD_Handler:
- if !WinActive("Diablo III")
- {
- if !WinExist("Diablo III") ; closes the script down if Diablo is no longer running
- {
- ExitApp
- }
- return
- }
- if GetKeyState("Shift", "P") ; this if/loop lets Shift still function as a stand still key
- {
- Loop
- {
- GetKeyState, state, Shift, P
- if state = U
- break
- }
- }
- else if GetKeyState("w", "P") || GetKeyState("s", "P") || GetKeyState("a", "P") || GetKeyState("d", "P")
- {
- if GetKeyState("w", "P")
- {
- y_final := y_center - y_offset
- }
- else if GetKeyState("s", "P")
- {
- y_final := y_center + y_offset
- }
- else
- {
- y_final := y_center
- }
- if GetKeyState("a", "P")
- {
- x_final := x_center - x_offset
- }
- else if GetKeyState("d", "P")
- {
- x_final := x_center + x_offset
- }
- else
- {
- x_final := x_center
- }
- MouseGetPos, x_initial, y_initial
- MouseMove, %x_final%, %y_final%, 0
- Send {%mkey%}
- MouseMove, %x_initial%, %y_initial%, 0
- }
- return
- ;====================================================================================
- ; KEY SPAM
- ;====================================================================================
- #SingleInstance, Force ; Make sure only one copy of this is running at a time
- Random, 100ms, 50, 150 ; Define random function "100ms"
- SetKeyDelay, 30,30 ; sets up the keyhandler for key-press and key-hold times
- xbutton1:: ; a hotkey based on the left side mouse button
- Send, 1 ; sends a 1 key to the active window
- gosub,100ms ; pauses the program for 100 milliseconds
- Send, 2 ; sends a 2 key to the active window
- gosub,100ms ; pauses for another 100 milliseconds
- Send, 3 ; and finally sends the 3 key to the active window
- Return
- ^esc:: ; press ctrl-Esc to exit the script entirely.
- ExitApp
- Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement