Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. ; To add a new key to the script, add it to this array:
  2. key_list := ["4", "3", "1","2", "5", "`"]
  3.  
  4. ; Init lookup array for modifiers
  5. modifiers := {LAlt: 0, LShift: 0, LCtrl: 0}
  6.  
  7. ; Build lookup array, declare hotkeys
  8. keys := {}
  9. keys_modded := {}
  10. Loop % key_list.MaxIndex(){
  11. key := key_list[A_Index]
  12. ; init array values
  13. keys[key] := 0
  14. keys_modded[key] := 0
  15. ; Declare hotkeys for up and down events
  16. hotkey, $*%key%, keydown
  17. hotkey, $*%key% up, keyup
  18. }
  19.  
  20. Loop {
  21. ; Endless loop - always running
  22. for key, value in keys {
  23.  
  24. ; Loop through each of the keys
  25. if (value){
  26.  
  27.  
  28. ; If the key is held...
  29. ; Detect if any modifiers held
  30. if (modifiers.LAlt || modifiers.LCtrl || modifiers.LShift){
  31. modifier_held := 1
  32. } else {
  33. modifier_held := 0
  34. }
  35.  
  36. s := ""
  37. ; Build the list of modifiers to use for the send
  38.  
  39. if (modifiers.LAlt){
  40. s .= "!"
  41. }
  42. if (modifiers.LShift){
  43. s .= "+"
  44. }
  45. if (modifiers.LCtrl){
  46. s .= "^"
  47. }
  48. ; Send the key with the modifiers
  49. Send % s "{" key "}"
  50. }
  51.  
  52. }
  53. Sleep 1
  54. }
  55.  
  56. ; Any of the "keys" (ie not modifiers) being pressed will call this
  57. keydown:
  58. key := SubStr(A_ThisHotkey,3)
  59. keys[key] := 1
  60. return
  61.  
  62.  
  63. ; Any of the "keys" being released will call this
  64. keyup:
  65. key := SubStr(A_ThisHotkey,3)
  66. ; Remove " up" from end
  67. key := substr(key, 1, StrLen(key) - 3)
  68. keys[key] := 0
  69. keys_modded[key] := 0
  70. return
  71.  
  72. ; Modifiers
  73. $~*LAlt::
  74. $~*LShift::
  75. $~*LCtrl::
  76. mod := substr(A_ThisHotkey, 4)
  77. modifiers[mod] := 1
  78. return
  79.  
  80. $~*LAlt up::
  81. $~*LCtrl up::
  82. $~*LShift up::
  83. mod := substr(A_ThisHotkey, 4)
  84. ; Remove " up" from end
  85. mod := substr(mod, 1, StrLen(mod) - 3)
  86. modifiers[mod] := 0
  87. return
  88.  
  89. ; Quit script on F6
  90. ;*** Suspend AHK ***
  91. ~F5::Suspend
  92.  
  93. F6::
  94. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement