Advertisement
Guest User

Sigrogana Legend 2 WASD to Numpad Rebind Script

a guest
Jul 10th, 2021
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  5. #IfWinActive, Sigrogana ; Makes sure the script is only active when a window with "Sigrogana" in the name is the active window
  6.  
  7. outputKeys := {-1: {-1: "NumpadHome", 0: "NumpadLeft", 1: "NumpadEnd"}
  8.                 , 0: {-1: "NumpadUp", 0:"", 1: "NumpadDown"}
  9.                 , 1: {-1: "NumpadPgUp", 0: "NumpadRight", 1: "NumpadPgDn"}}
  10.  
  11.  
  12. f12:: ; this key suspends/unsuspends the script
  13. Suspend,Toggle
  14. return
  15.  
  16. w::
  17. ProcessKeys("y", -1)
  18. return
  19.  
  20. s::
  21. ProcessKeys("y", 1)
  22. return
  23.  
  24. w up::
  25. s up::
  26. ProcessKeys("y", 0)
  27. return
  28.  
  29. a::
  30. ProcessKeys("x", -1)
  31. return
  32.  
  33. d::
  34. ProcessKeys("x", 1)
  35. return
  36.  
  37. a up::
  38. d up::
  39. ProcessKeys("x", 0)
  40. return
  41.  
  42. ^Esc::
  43.     ExitApp
  44.  
  45. ProcessKeys(axis, vector){
  46.     static keyVectors := {x: 0, y: 0}
  47.     static otherAxes := {x: "y", y: "x"}
  48.     global outputKeys
  49.    
  50.     otherAxis := otherAxes[axis]
  51.     newVectors := {}
  52.     newVectors[axis] := vector
  53.     newVectors[otherAxis] := keyVectors[otherAxis]
  54.    
  55.     oldKey := outputKeys[keyVectors.x, keyVectors.y]
  56.     newKey := outputKeys[newVectors.x, newVectors.y]
  57.    
  58.     if (newKey != oldKey){
  59.         if (oldKey != ""){
  60.             str := "{Blind}{" oldKey " up}"
  61.             Send % str
  62.             ;~ ToolTip % str
  63.         }
  64.         if (newKey != ""){
  65.             str := "{Blind}{" newKey " down}"
  66.             Send % str
  67.             ;~ ToolTip % str
  68.         }
  69.         keyVectors[axis] := vector
  70.     }
  71. }
  72.  
  73. #IfWinActive ; changes wasd back to wasd when Sig isn't active/when any window other than Sig is active
  74.  
  75. w::w
  76. s::s
  77. a::a
  78. d::d
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement