Guest User

Untitled

a guest
Jan 21st, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  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. StringCaseSense, On
  6.  
  7. AnyKeyPressedOtherThanSpace(mode = "P") {
  8. keys = 1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./
  9. Loop, Parse, keys
  10. {
  11. isDown := GetKeyState(A_LoopField, mode)
  12. if(isDown)
  13. return True
  14. }
  15.  
  16. return False
  17. }
  18.  
  19.  
  20. supressed := False
  21. RestoreInput(){
  22. BlockInput, Off
  23. Global supressed
  24. supressed := False
  25. }
  26.  
  27. SupressInput(){
  28. Global supressed
  29. supressed := True
  30. BlockInput, On
  31. SetTimer, RestoreInput, -180
  32. }
  33.  
  34. ModifierStates := ""
  35. UpdateModifierStates(){
  36. Global ModifierStates
  37. if (supressed){
  38. return
  39. }
  40. ModifierStates := ""
  41.  
  42. if GetKeyState("LWin", "P") || GetKeyState("RWin", "P") {
  43. ModifierStates .= "#"
  44. }
  45.  
  46. if GetKeyState("Ctrl", "P"){
  47. ModifierStates .= "^"
  48. }
  49.  
  50. if GetKeyState("Alt", "P"){
  51. ModifierStates .= "!"
  52. }
  53.  
  54. if GetKeyState("Shift", "P"){
  55. ModifierStates .= "+"
  56. }
  57. }
  58.  
  59. SendKey(Key, num=1){
  60. Global ModifierStates
  61. Loop, %num%{
  62. Send, %ModifierStates%%Key%
  63. }
  64. }
  65.  
  66. ReleaseModifier(){
  67. global space_up
  68. if (not space_up){
  69. space_up := true
  70. }
  71. Send, {RShift}
  72. }
  73.  
  74. Space Up::
  75. Send {Blind}{Space up}
  76. space_up := true
  77. SendEvent, {RShift}
  78. return
  79. Space::
  80. if AnyKeyPressedOtherThanSpace(){
  81. SendInput, {Blind}{Space}
  82. Return
  83. }
  84. if (GetKeyState(LShift, mode)){
  85. SendInput ^{Space}
  86. Return
  87. }
  88. inputed := False
  89. space_up := False
  90. input, UserInput, L1 T0.05, {RShift}
  91. if (space_up) {
  92. Send, {Blind}{Space}
  93. return
  94. }else if (StrLen(UserInput) == 1){
  95. Send, {Space}%UserInput%
  96. return
  97. }
  98. SetTimer, ReleaseModifier, -18000
  99. while true{
  100. input, UserInput, L1, {RShift}
  101. if (space_up) {
  102. if (!inputed){
  103. Send, {Blind}{Space}
  104. }
  105. break
  106. }else{
  107. inputed := True
  108. StringLower, UserInput, UserInput
  109. UpdateModifierStates()
  110. SupressInput()
  111. if (UserInput == "b")
  112. SendKey("{Left}")
  113. else
  114. {
  115. ModifierStates .= "^"
  116. SendKey(UserInput)
  117. }
  118. }
  119. }
  120. RestoreInput()
  121. return
Add Comment
Please, Sign In to add comment