This script watches that the left mouse button is held down. If it exceeds a certain time, a small Gui is activated which gives the option to copy.
The problem is that when you open it for the first time it doesn't work and you have to reload it, as you can see in the video? Why?
(If the clipboard is not used, TrayTip does not emerge).
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
;#Persistent
CoordMode, Mouse, Screen
~LButton::
time := A_TickCount
KeyWait, LButton
varTemp := A_TimeSinceThisHotkey
if varTemp>1200
Gosub, Select
Else
return
Select:
MouseGetPos, xpos1, ypos1
Gui,1: color,EEAA99
Gui, Add, Button, x2 y2 w64 h15 gExitMenu, Exit
Gui, Add, Button, x2 y18 w64 h64 hwndIcon gButtonLabel
Gui, Show, x%xpos1% y%ypos1% w68 h84, Window-Title
Gui, -Caption ;+alwaysontop
GuiButtonIcon(Icon, "clipboard.ico", 1, "s90")
Return
ButtonLabel:
ClipTemp := Clipboard
clipboard := ""
Gui, Destroy
SetTimer, ActivateWinUM, 100
Send, ^c
;Gosub, OnClipboardChange
ClipWait
if Not Clipboard=ClipTemp
{
SoundPlay, Clipboard_Sound.mp3
TrayTip, Timed TrayTip, %Clipboard%, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -1500
}
Else
{
SoundPlay, ambiguity2.mp3
TrayTip, Timed TrayTip, REPEATED CLIPBOARD!, 0x2, 0x10, 0x20
SetTimer, HideTrayTip, -1500
}
Return
ActivateWinUM:
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
return
;^esc::
;Gui, Destroy
;Return
ExitMenu:
Gui, Destroy
Return
;GuiClose:
;ExitApp
HideTrayTip() {
TrayTip
}
Return
GuiButtonIcon(Handle, File, Index := 1, Options := "")
{
RegExMatch(Options, "i)w\K\d+", W), (W="") ? W := 16 :
RegExMatch(Options, "i)h\K\d+", H), (H="") ? H := 16 :
RegExMatch(Options, "i)s\K\d+", S), S ? W := H := S :
RegExMatch(Options, "i)l\K\d+", L), (L="") ? L := 0 :
RegExMatch(Options, "i)t\K\d+", T), (T="") ? T := 0 :
RegExMatch(Options, "i)r\K\d+", R), (R="") ? R := 0 :
RegExMatch(Options, "i)b\K\d+", B), (B="") ? B := 0 :
RegExMatch(Options, "i)a\K\d+", A), (A="") ? A := 4 :
Psz := A_PtrSize = "" ? 4 : A_PtrSize, DW := "UInt", Ptr := A_PtrSize = "" ? DW : "Ptr"
VarSetCapacity( button_il, 20 + Psz, 0 )
NumPut( normal_il := DllCall( "ImageList_Create", DW, W, DW, H, DW, 0x21, DW, 1, DW, 1 ), button_il, 0, Ptr ) ; Width & Height
NumPut( L, button_il, 0 + Psz, DW ) ; Left Margin
NumPut( T, button_il, 4 + Psz, DW ) ; Top Margin
NumPut( R, button_il, 8 + Psz, DW ) ; Right Margin
NumPut( B, button_il, 12 + Psz, DW ) ; Bottom Margin
NumPut( A, button_il, 16 + Psz, DW ) ; Alignment
SendMessage, BCM_SETIMAGELIST := 5634, 0, &button_il,, AHK_ID %Handle%
return IL_Add( normal_il, File, Index )
}
Return
Can it be improved, they have errors in their execution.
(I know the limits of this script. If you have done a mouse drag, without selecting text it does the same procedure, but that's why a gui comes out and it's not very annoying).