Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoTrayIcon
- #Persistent ; Keep this script running until the user explicitly exits it.
- JoystickNumber = 1
- SetTimer, WatchAxis, 5
- return
- WatchAxis:
- GetKeyState, JoyX, %JoystickNumber%JoyX
- GetKeyState, JoyY, %JoystickNumber%JoyY
- GetKeyState, joy_name, %JoystickNumber%JoyName
- KeyToHoldDownPrev = %KeyToHoldDown% ; Prev now holds the key that was down before (if any).
- KeyToHoldDown =
- if JoyX > 51.0
- KeyToHoldDown = d
- if JoyX < 49.0
- KeyToHoldDown = %KeyToHoldDown% a
- button = %JoystickNumber%Joy3
- if GetKeyState(button) {
- KeyToHoldDown = %KeyToHoldDown% w
- }
- button = %JoystickNumber%Joy4
- if GetKeyState(button) {
- KeyToHoldDown = %KeyToHoldDown% s
- }
- button = %JoystickNumber%Joy2
- if GetKeyState(button) {
- KeyToHoldDown = %KeyToHoldDown% Space
- }
- button = %JoystickNumber%Joy5
- if GetKeyState(button) {
- KeyToHoldDown = %KeyToHoldDown% 3
- }
- button = %JoystickNumber%Joy6
- if GetKeyState(button) {
- KeyToHoldDown = %KeyToHoldDown% 4
- }
- button = %JoystickNumber%Joy7
- if GetKeyState(button) {
- KeyToHoldDown = %KeyToHoldDown% 1
- }
- button = %JoystickNumber%Joy8
- if GetKeyState(button) {
- KeyToHoldDown = %KeyToHoldDown% 2
- }
- if KeyToHoldDown = %KeyToHoldDownPrev%
- return ; Do nothing.
- ; Otherwise, release the previous key and press down the new key:
- SetKeyDelay -1 ; Avoid delays between keystrokes.
- if KeyToHoldDownPrev {
- StringSplit, PrevArray, KeyToHoldDownPrev, %A_Space%
- Loop, %PrevArray0%
- {
- key := PrevArray%a_index%
- Send, {%key% up} ; Release it.
- }
- }
- if KeyToHoldDown {
- StringSplit, CurrArray, KeyToHoldDown, %A_Space%
- Loop, %CurrArray0%
- {
- key := CurrArray%a_index%
- Send, {%key% down} ; Press it down.
- }
- }
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement