Advertisement
EzFlow997

CopyClipBoard Hotkey AHK V2

Jul 8th, 2024 (edited)
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Autohotkey 1.71 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.  
  7. specialKey := "1"
  8.  
  9. Hotkey "^9", Exit
  10. Hotkey Format("{1}",specialKey), ClipCopy
  11.  
  12. clip := CopyClipBoardClass()
  13. ClipCopy(ThisHotkey){
  14.     clip.copy()
  15. }
  16.  
  17. Exit(ThisHotkey){
  18.     ExitApp
  19. }
  20.  
  21. class CopyClipBoardClass {
  22.     keyPressesRequired := 2
  23.     countKeyPresses := 0
  24.     timeStarted := A_TickCount
  25.     delayTime := 200
  26.    
  27.     _new(){                                                                      
  28.    
  29.     }
  30.    
  31.     copy(){
  32.         if(this.countKeyPresses == 0){
  33.             this.timeStarted := A_TickCount
  34.             this.countKeyPresses += 1
  35.             SetTimer CheckKeyTime, 10
  36.         }
  37.         else if(this.countKeyPresses == this.keyPressesRequired - 1 && A_TickCount - this.timeStarted <= this.delayTime){
  38.             this.countKeyPresses := 0
  39.             Send "^c"
  40.             ;MsgBox "Test2"
  41.         }
  42.         else if(this.countKeyPresses > 0 && A_TickCount - this.timeStarted > this.delayTime){
  43.             this.countKeyPresses := 0
  44.         }                                                                                                                                                                        
  45.         else{
  46.             this.countKeyPresses += 1
  47.         }
  48.         ;Tooltip Format("{1}`n{2}`n{3}", this.countKeyPresses, this.timeStarted, A_TickCount)
  49.     }
  50. }
  51.  
  52. CheckKeyTime(){
  53.     static numberT := 0
  54.     if(clip.countKeyPresses == 1 && A_TickCount - clip.timeStarted > clip.delayTime){
  55.         clip.countKeyPresses := 0
  56.         Send Format("{1}", specialKey)
  57.         ;ToolTip "Sending 1"
  58.         SetTimer CheckKeyTime, 0
  59.     }
  60.     ;ToolTip Format("{1}",numberT)
  61.     numberT += 1
  62. }
Tags: AHKv2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement