Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Basic examples:
  2. GetKeyState, state, RButton  ; Right mouse button.
  3. GetKeyState, state, Joy2  ; The second button of the first joystick.
  4.  
  5. GetKeyState, state, Shift
  6. if state = D
  7.     MsgBox At least one Shift key is down.
  8. else
  9.     MsgBox Neither Shift key is down.
  10.  
  11. GetKeyState, state, CapsLock, T ;  D if CapsLock is ON or U otherwise.
  12. state := GetKeyState("Capslock", "T")  ; True if CapsLock is ON, false otherwise.
  13.  
  14. ; Remapping example (this is only for illustration because it would be easier to use
  15. ; the built-in remapping feature):
  16. ; In the following hotkey, the mouse button is kept held down while NumpadAdd is
  17. ; down, which effectively transforms NumpadAdd into a mouse button. This method
  18. ; can also be used to repeat an action while the user is holding down a key or button:
  19. *NumpadAdd::
  20. MouseClick, left,,, 1, 0, D  ; Hold down the left mouse button.
  21. Loop
  22. {
  23.     Sleep, 10
  24.     GetKeyState, state, NumpadAdd, P
  25.     if state = U  ; The key has been released, so break out of the loop.
  26.         break
  27.     ; ... insert here any other actions you want repeated.
  28. }
  29. MouseClick, left,,, 1, 0, U  ; Release the mouse button.
  30. return
  31.  
  32. ; Example: Make joystick button behavior depend on joystick axis position.
  33. joy2::
  34. GetKeyState, joyx, JoyX
  35. if joyx > 75
  36.     MsgBox Action #1 (button pressed while joystick was pushed to the right).
  37. else if joyx < 25
  38.     MsgBox Action #2 (button pressed while joystick was pushed to the left).
  39. else
  40.     MsgBox Action #3 (button pressed while joystick was centered horizontally).
  41. return
  42.  
  43. ; See the joystick remapping page and the Joystick-To-Mouse script for other examples.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement