Advertisement
Guest User

Untitled

a guest
Sep 29th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MouseGetPos, xx
  2. TimeButtonDown = %A_TickCount%
  3. ; Wait for it to be released
  4. Loop
  5. {
  6.    Sleep 10
  7.    GetKeyState, LButtonState, LButton, P
  8.    if LButtonState = U  ; Button has been released.
  9.    {
  10.       If WinActive("Crimson Editor") and (xx < 25) ; Single Click in the Selection Area of CE
  11.       {
  12.          Send, ^c
  13.          return
  14.       }
  15.       break
  16.    }
  17.    elapsed = %A_TickCount%
  18.    elapsed -= %TimeButtonDown%
  19.    if elapsed > 200  ; Button was held down too long, so assume it's not a double-click.
  20.    {
  21.       MouseGetPos x0, y0            ; save start mouse position
  22.       Loop
  23.    {
  24.      Sleep 20                    ; yield time to others
  25.      GetKeyState keystate, LButton
  26.      IfEqual keystate, U, {
  27.        MouseGetPos x, y          ; position when button released
  28.        break
  29.      }
  30.    }
  31.    if (x-x0 > 5 or x-x0 < -5 or y-y0 > 5 or y-y0 < -5)
  32.    {                             ; mouse has moved
  33.       clip0 := ClipBoardAll      ; save old clipboard
  34.       ;ClipBoard =
  35.       Send ^c                    ; selection -> clipboard
  36.       ClipWait 1, 1              ; restore clipboard if no data
  37.       IfEqual ClipBoard,, SetEnv ClipBoard, %clip0%
  38.    }
  39.       return
  40.    }
  41. }
  42. ; Otherwise, button was released quickly enough.  Wait to see if it's a double-click:
  43. TimeButtonUp = %A_TickCount%
  44. Loop
  45. {
  46.    Sleep 10
  47.    GetKeyState, LButtonState, LButton, P
  48.    if LButtonState = D  ; Button has been pressed down again.
  49.       break
  50.    elapsed = %A_TickCount%
  51.    elapsed -= %TimeButtonUp%
  52.    if elapsed > 350  ; No click has occurred within the allowed time, so assume it's not a double-click.
  53.       return
  54. }
  55.  
  56. ;Button pressed down again, it's at least a double-click
  57. TimeButtonUp2 = %A_TickCount%
  58. Loop
  59. {
  60.    Sleep 10
  61.    GetKeyState, LButtonState2, LButton, P
  62.    if LButtonState2 = U  ; Button has been released a 2nd time, let's see if it's a tripple-click.
  63.       break
  64. }
  65. ;Button released a 2nd time
  66. TimeButtonUp3 = %A_TickCount%
  67. Loop
  68. {
  69.    Sleep 10
  70.    GetKeyState, LButtonState3, LButton, P
  71.    if LButtonState3 = D  ; Button has been pressed down a 3rd time.
  72.       break
  73.    elapsed = %A_TickCount%
  74.    elapsed -= %TimeButtonUp%
  75.    if elapsed > 350  ; No click has occurred within the allowed time, so assume it's not a tripple-click.
  76.    {  ;Double-click
  77.       Send, ^c
  78.       return
  79.    }
  80. }
  81. ;Tripple-click:
  82.    Sleep, 100
  83.    Send, ^c
  84. return
  85.  
  86. #Persistent
  87. return
  88.  
  89. OnClipboardChange:
  90. ToolTip Clipboard data type: %A_EventInfo%
  91. StringReplace, Clipboard, Clipboard,  `r`n,%A_Space%, All
  92. Sleep 1000
  93. ToolTip  ; Turn off the tip.
  94. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement