Advertisement
EzFlow997

SpecialRapidKeys

Jul 10th, 2024 (edited)
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Autohotkey 3.01 KB | Source Code | 0 0
  1. #Requires AutoHotkey v2.0
  2. #InputLevel 1
  3. #SingleInstance Force
  4. PID := DllCall("GetCurrentProcessId")
  5. ProcessSetPriority "High", PID
  6. A_HotkeyInterval := 0
  7.  
  8. specialKey1 := "1"
  9. specialKey2 := "2"
  10. specialKey3 := "3"
  11. specialKey4 := "0"
  12.  
  13. Hotkey "^9", Exit
  14. Hotkey Format("{1}",specialKey1), ClipCopy
  15. Hotkey Format("{1}",specialKey2), ClipPaste
  16. Hotkey Format("{1}",specialKey3), SelectAll
  17. Hotkey Format("{1}",specialKey4), ClickRButton
  18.  
  19. RFI_Copy := RapidFireInput()
  20. RFI_Copy.update(2, 200, "^c", specialKey1)
  21. ClipCopy(ThisHotkey){
  22.     RFI_Copy.send()
  23.     RepeatHotKey(ThisHotKey)                                              
  24. }
  25.  
  26. RFI_Paste := RapidFireInput()
  27. RFI_Paste.update(2, 200, "^v", specialKey2)
  28. ClipPaste(ThisHotkey){
  29.     RFI_Paste.send()
  30.     RepeatHotKey(ThisHotKey)
  31. }
  32.  
  33. RFI_SelectAll := RapidFireInput()
  34. RFI_SelectAll.update(2, 200, "^a", specialKey3)
  35. SelectAll(ThisHotkey){
  36.     RFI_SelectAll.send()
  37.     RepeatHotKey(ThisHotKey)
  38. }
  39.  
  40. RFI_RButton := RapidFireInput()
  41. RFI_RButton.update(2, 200, "{RButton}", specialKey4)
  42. ClickRButton(ThisHotkey){
  43.     RFI_RButton.send()
  44.     RepeatHotKey(ThisHotKey)
  45. }
  46.  
  47. RepeatHotKey(ThisHotKey){
  48.     state := GetKeyState(ThisHotKey, "P")
  49.     Sleep 25
  50.     iterations := 0
  51.     while(state == 1){                                                  
  52.         state := GetKeyState(ThisHotKey, "P")
  53.         Sleep 25
  54.         iterations += 1
  55.         if(iterations > 5){
  56.             Send ThisHotKey
  57.         }
  58.     }
  59. }
  60.  
  61. Exit(ThisHotkey){
  62.     ExitApp
  63. }
  64.  
  65. class RapidFireInput {
  66.     keyPressesRequired := 2
  67.     countKeyPresses := 0
  68.     timeStarted := A_TickCount
  69.     delayTime := 200
  70.     originalKey := "1"
  71.     inputToSend := "^c"
  72.     keyTimer := ObjBindMethod(this, "checkTime")
  73.     iterations := 0
  74.    
  75.     update(kp, ds, key, oKey){
  76.         this.keyPressesRequired := kp
  77.         this.delayTime := ds
  78.         this.inputToSend := key
  79.         this.originalKey := oKey
  80.     }
  81.    
  82.     send(){
  83.         if(this.countKeyPresses == 0){
  84.             this.timeStarted := A_TickCount
  85.             this.countKeyPresses += 1
  86.             SetTimer this.keyTimer, 10
  87.         }
  88.         else if(this.countKeyPresses == this.keyPressesRequired - 1 && A_TickCount - this.timeStarted <= this.delayTime){
  89.             this.countKeyPresses := 0
  90.             Send Format("{1}", this.inputToSend)
  91.             SetTimer this.keyTimer, 0
  92.             ;MsgBox "Test2"
  93.         }
  94.         else if(this.countKeyPresses > 0 && A_TickCount - this.timeStarted > this.delayTime){
  95.             this.countKeyPresses := 0
  96.             SetTimer this.keyTimer, 0
  97.         }                                                                                                                                                                        
  98.         else{
  99.             this.countKeyPresses += 1
  100.         }
  101.         ;Tooltip Format("{1}`n{2}`n{3}", this.countKeyPresses, this.timeStarted, A_TickCount)
  102.     }
  103.    
  104.     checkTime(){
  105.         if(this.countKeyPresses < this.keyPressesRequired && A_TickCount - this.timeStarted > this.delayTime){
  106.             this.countKeyPresses := 0
  107.             Send Format("{1}", this.originalKey)
  108.             this.iterations := 0
  109.             SetTimer this.keyTimer, 0
  110.         }
  111.         this.iterations += 1
  112.     }
  113. }
Tags: ahk
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement