 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Wed Nov 02, 2005 8:54 am Post subject: Preview of a Clipboard Helper (CH) |
|
|
The not ready for prime time, but good enough for the weekend Clipboard Helper.
Features:
* preview of captured clips
* delete captured clips
* random clip selection
* keyboard and mouse interface
Usage:
* show CH (Control+Insert or Control+v)
* show/hide CH from Tray (left-button click)
* hide CH (Escape)
* delete selected clip (context menu via right-button click)
* paste clip (Enter or left-button double-click)
* select clip (left-button click)
* browse clips (mouse or arrow up/down, home, end)
Note: Enter will paste a single clip and hide CH. However, left-button double-click will only paste a single clip.
| Code: | #SingleInstance, Ignore
DetectHiddenWindows, On
; -- ignore existing clipboard content --
ignore_clipboard_change := true
; -- construct TRAY menu --
Menu, TRAY, Icon, %A_WinDir%\system32\clipbrd.exe
Menu, TRAY, NoStandard
Menu, TRAY, Add, Show Clipboard Helper, TRAY$ShowClipboardHelper
Menu, TRAY, Add
Menu, TRAY, Add, Exit Program, TRAY$ExitProgram
; -- construct main window --
Gui, +AlwaysOnTop -MinimizeBox -Resize
Gui, Add, Text, x5 y5, Target:
Gui, Add, Edit, x45 y5 w360 h20 ReadOnly vTarget
Gui, Add, ListBox, x5 y35 w400 h200 vClipboardList
Gui, Add, Edit, x5 y240 w400 h100 HScroll ReadOnly vTextPreview
Gui, Show, w410 h345 Hide, Clipboard Helper
WinGet, hw_ClipboardHelper, ID, Clipboard Helper ahk_class AutoHotkeyGUI
; -- activate message handlers --
WM_KEYUP = 0x101
OnMessage( WM_KEYUP, "HandleMessage" )
WM_LBUTTONUP = 0x202
OnMessage( WM_LBUTTONUP, "HandleMessage" )
WM_LBUTTONDBLCLK = 0x203
OnMessage( WM_LBUTTONDBLCLK, "HandleMessage" )
WM_RBUTTONUP = 0x0205
OnMessage( WM_RBUTTONUP, "HandleMessage" )
AHK_NOTIFYICON = 0x404
OnMessage( AHK_NOTIFYICON, "HandleMessage" )
return
HandleMessage( p_w, p_l, p_m, p_hw )
{
global WM_KEYUP, WM_LBUTTONUP, WM_LBUTTONDBLCLK, WM_RBUTTONUP, AHK_NOTIFYICON
global timer_PasteItem@m, timer_ShowMenu@l, timer_ShowMenu@hw
global hw_ClipboardHelper, ClipboardList?menu@item
if ( p_m = AHK_NOTIFYICON and p_l = WM_LBUTTONUP )
{
SetTimer, timer_ToggleClipboardHelper, 10
}
else if ( A_GuiControl = "ClipboardList" )
{
if ( p_m = WM_KEYUP )
{
if ( p_w = 13 )
{
timer_PasteItem@m := p_m
SetTimer, timer_PasteItem, 10
}
else if ( p_w = 0x26 or p_w = 0x28 or p_w = 0x23 or p_w = 0x24 )
{
SetTimer, timer_ShowPreview, 10
}
else if ( p_w = 0x2E )
{
SetTimer, timer_DeleteItem, 10
}
}
else if ( p_m = WM_LBUTTONUP )
{
SetTimer, timer_ShowPreview, 10
}
else if ( p_m = WM_LBUTTONDBLCLK )
{
timer_PasteItem@m := p_m
SetTimer, timer_PasteItem, 10
}
else if ( p_m = WM_RBUTTONUP )
{
timer_ShowMenu@l := p_l
SetTimer, timer_ShowMenu, 10
}
}
return
timer_ToggleClipboardHelper:
SetTimer, timer_ToggleClipboardHelper, off
if ( DllCall( "IsWindowVisible", "uint", hw_ClipboardHelper ) )
Gosub, HideClipboardHelper
else
Gosub, ShowClipboardHelper
return
timer_PasteItem:
SetTimer, timer_PasteItem, off
;LB_GETCOUNT
SendMessage, 0x18B, 0, 0, ListBox1, ahk_id %hw_ClipboardHelper%
if ( ErrorLevel = 0 )
return
GuiControlGet, item,, ClipboardList
if ( timer_PasteItem@m = WM_KEYUP )
Gosub, HideClipboardHelper
PasteItem( item )
return
timer_ShowPreview:
SetTimer, timer_ShowPreview, off
GuiControlGet, item,, ClipboardList
ShowPreview( item )
return
timer_ShowMenu:
SetTimer, timer_ShowMenu, off
;LB_ITEMFROMPOINT
SendMessage, 0x1A9, 0, timer_ShowMenu@l, ListBox1, ahk_id %hw_ClipboardHelper%
if ( ErrorLevel = 0x1FFFF or ( ErrorLevel & 0x10000 ) )
return
ClipboardList?menu@item := ErrorLevel+1
GuiControl, Choose, ClipboardList, %ClipboardList?menu@item%
Gosub, timer_ShowPreview
if ClipboardList?menu=
{
Menu, ClipboardList?menu, Add, Delete, ClipboardList?menu$delete
}
Menu, ClipboardList?menu, Show
return
timer_DeleteItem:
SetTimer, timer_DeleteItem, off
;LB_GETCURSEL
SendMessage, 0x188, 0, 0, ListBox1, ahk_id %hw_ClipboardHelper%
DeleteItem( ErrorLevel )
return
}
TRAY$ExitProgram:
ExitApp
TRAY$ShowClipboardHelper:
Gosub, ShowClipboardHelper
return
ClipboardList?menu$delete:
DeleteItem( ClipboardList?menu@item-1 )
return
GuiEscape:
HideClipboardHelper:
SetTimer, timer_MonitorTarget, off
Gui, Hide
return
~LButton::
SetTimer, timer_MonitorTarget, off
return
~LButton up::
SetTimer, timer_MonitorTarget, on
return
^v::
+Insert::
ShowClipboardHelper:
WinGet, hw_active, ID, A
ControlGetFocus, control_active, A
UpdateTarget( hw_active, control_active )
Gui, Show
ControlFocus, ListBox1, ahk_id %hw_ClipboardHelper%
SetTimer, timer_MonitorTarget, 200
return
timer_MonitorTarget:
WinGet, hw_active, ID, A
ControlGetFocus, control_active, A
UpdateTarget( hw_active, control_active )
return
OnClipboardChange:
if ( ignore_clipboard_change )
ignore_clipboard_change := false
else if ( A_EventInfo = 1 )
AddItem( Clipboard )
return
AddItem( p_item )
{
global hw_ClipboardHelper
fill := Chr( 1 )
StringReplace, p_item, p_item, |, %fill%, All
;LB_GETCOUNT
SendMessage, 0x18B, 0, 0, ListBox1, ahk_id %hw_ClipboardHelper%
items := ErrorLevel
loop, %items%
{
;LB_GETTEXTLEN
SendMessage, 0x18A, A_Index-1, 0, ListBox1, ahk_id %hw_ClipboardHelper%
len := ErrorLevel
VarSetCapacity( text, len, 1 )
;LB_GETTEXT
SendMessage, 0x189, A_Index-1, &text, ListBox1, ahk_id %hw_ClipboardHelper%
if ( p_item = text )
{
GuiControl, Choose, ClipboardList, %A_Index%
ShowPreview( p_item )
p_item=
break
}
}
if p_item!=
{
GuiControl,, ClipboardList, %p_item%
items++
GuiControl, Choose, ClipboardList, %items%
ShowPreview( p_item )
MsgBox, 4160, Clipboard Helper, Capture complete!, 0.4
}
}
DeleteItem( p_item )
{
global hw_ClipboardHelper
;LB_DELETESTRING
SendMessage, 0x182, p_item, 0, ListBox1, ahk_id %hw_ClipboardHelper%
p_item++
if ( p_item > 1 )
p_item--
GuiControl, Choose, ClipboardList, %p_item%
GuiControlGet, item,, ClipboardList
ShowPreview( item )
}
PasteItem( p_item )
{
global target?hw, target?control, ignore_clipboard_change
fill := Chr( 1 )
StringReplace, p_item, p_item, %fill%, |, All
ignore_clipboard_change := true
Clipboard := p_item
ControlFocus, %target?control%, ahk_id %target?hw%
Send, +{Insert}
}
ShowPreview( p_item )
{
fill := Chr( 1 )
StringReplace, p_item, p_item, %fill%, |, All
GuiControl,, TextPreview, %p_item%
}
UpdateTarget( p_hw, p_control )
{
global hw_ClipboardHelper, target?hw, target?control
if ( p_hw = hw_ClipboardHelper )
return
target?hw := p_hw
target?control := p_control
WinGetTitle, title, ahk_id %target?hw%
GuiControl,, Target, %title%
} |
Last edited by shimanov on Thu Nov 03, 2005 11:30 pm; edited 2 times in total |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Wed Nov 02, 2005 3:09 pm Post subject: |
|
|
Wow, even without the future enhancements, that's really slick multi-clipboard script. It also has the most advanced use of OnMessage I've ever seen. Most importantly, it's very easy to use due to a well-designed, intuitive user interface.
Thanks for sharing it. |
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Wed Nov 02, 2005 9:20 pm Post subject: |
|
|
| Chris wrote: | | it's very easy to use due to a well-designed, intuitive user interface. |
Thanks. If you like where this is going, you really should check out ClipMate. It inspired this design. Although, I still have a long way to go before I can match, let alone replace it.
| Quote: | | Thanks for sharing it. |
Sure. I have noticed, on and off, that others find value in my contributions. If not whole, then at least in pieces.
Oh well. I also look for items of specific interest to myself.
Edit:
I just tried their new version 7. The program has really evolved since its introduction. A lot of thoughtful, well implemented features, which I am sure the AHk community would love to play with. |
|
| Back to top |
|
 |
Nemroth
Joined: 07 Sep 2004 Posts: 262 Location: France
|
Posted: Wed Nov 02, 2005 9:51 pm Post subject: Re: Preview of a Clipboard Helper (CH) |
|
|
At first, thanks a lot for this very good script. You said you wanted to add more keyboard shortcuts. I propose this one, witch seems to lack :
| shimanov wrote: | Usage:
* delete selected clip (context menu via right-button click) |
The more simple wouldn't be to use the Del key to delete the selected clip ?
Thanks again for the good job. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4001 Location: Pittsburgh
|
Posted: Thu Nov 03, 2005 12:31 am Post subject: |
|
|
I use a keyboard manager, which inserts Unicode characters into MS Word via the clipboard, and also a math expression evaluator, which copies and pastes equations to Pari/GP. These are slowed down or prevented to work by the Clipboard Helper. Therefore, I'd like a more selective version, where other hotkeys copy clipboards to the buffer, not Ctrl-C, which should remain undisturbed. (Many of us accustomed to have Ctrl-C/V act as single keystrokes, and a popup window, or an extra Enter key is confusing and slowing us down.)
I use a version of my old Deluxe Clipboard script, where CapsLock & C copies the selection to a named private clipboard, CapsLock & A appends the selection, CapsLock & V pastes the named clipboard, etc. It does not interfere with any normal use of the Windows clipboard. (It lacks the preview, though, which I'd like to steal from your script, but I need the named clipboard and the append functionality.)
Somehow Clipboard Helper once interfered with MultiEdit 9.10, my favorite editor. After copying a line to the clipboard, at an attempt to paste it back the window title started to flicker and no input was possible until I shut down the script.
The target box does not seem to be important: of course we want to paste to the window, where Ctrl-C was pressed.
It is a very nice script. Have you seen the versions of Decarlo110 and Skromel? |
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Thu Nov 03, 2005 12:43 am Post subject: Re: Preview of a Clipboard Helper (CH) |
|
|
| Nemroth wrote: | | The more simple wouldn't be to use the Del key to delete the selected clip ? |
You're right.
It was left out as I was trying to decide what balance to strike between a mouse and keyboard interface. Since I decided on left-button double-click to paste, this addition will be straightforward.
Check the first post for the updated version.
| Quote: | | Thanks again for the good job. |
I am glad it works for you. |
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Thu Nov 03, 2005 2:18 am Post subject: |
|
|
| Laszlo wrote: | a more selective version, where other hotkeys copy clipboards to the buffer, not Ctrl-C, which should remain undisturbed.
...
a popup window, or an extra Enter key is confusing and slowing us down.
...
CapsLock & C copies the selection to a named private clipboard, CapsLock & A appends the selection, CapsLock & V pastes the named clipboard, etc.
|
The present implementation captures all text on the clipboard using OnClipboardChange to trigger the capture. I can't think of any reason not to change the current mechanism. I'll consider how to introduce the change in the most transparent manner possible.
All these changes can be implemented in a straightforward manner with the introduction of a configuration interface -- that should probably be the priority.
| Quote: | | It lacks the preview, though, which I'd like to steal from your script, but I need the named clipboard and the append functionality. |
This preview release was meant as a concept demonstration. If there are specific pieces which interest you, go ahead and cannibalize it.
| Quote: | | Somehow Clipboard Helper once interfered with MultiEdit 9.10, my favorite editor. |
When I have the opportunity, I will install MultiEdit and test this.
| Quote: | | The target box does not seem to be important: of course we want to paste to the window, where Ctrl-C was pressed. |
The target box indicates where a clip will be pasted and is essential for the mouse interface to work properly. When pasting a clip via left-button double-click, this feature informs the user which target window will be the recipient of the pasted clip.
| Quote: | | Have you seen the versions of Decarlo110 and Skromel? |
I just checked them. They each have features and behaviors of merit.
As with my other contributions, the primary purpose is an exchange of knowledge. If others find the contribution useful, then all the better.
The public posts are a way for others to share in my quest for greater knowledge and understanding. |
|
| Back to top |
|
 |
Atomhrt
Joined: 02 Sep 2004 Posts: 128 Location: Sunnyvale
|
Posted: Thu Nov 03, 2005 7:38 pm Post subject: |
|
|
| shimanov wrote: | Thanks. If you like where this is going, you really should check out ClipMate. It inspired this design. Although, I still have a long way to go before I can match, let alone replace it.
|
While I think that ClipMate is really nice and I am a registered user, I wanted something a bit less bloated and, for me, easier to use. I've been using Ditto-cp for a long time now.
http://ditto-cp.sourceforge.net/ _________________ I am he of whom he speaks! |
|
| Back to top |
|
 |
TGKS Guest
|
Posted: Tue May 23, 2006 11:14 pm Post subject: Beep Beep Beep Beep Beep Beep Beep |
|
|
Beep Beep Beep Beep Beep Beep Beep
I hope you get the idea!! I like the Clipboard Helper but that darn infernal Beep just drives me nuts. When I'm copying multiple items I don't want to hear a beep every time. The splash screen I can live with but how can you turn off that beep.
In case you can't see I'm a newbie too AutoHotkey. |
|
| Back to top |
|
 |
Why not Guest
|
Posted: Wed May 24, 2006 1:39 am Post subject: |
|
|
Very good indeed!!!
One little thing: I try to shift the gui at the right but the gui stay at the center, Why, please?
| Code: | | Gui, Show, x500 y0 w740 h990 Hide, Clipboard Helper |
Why not an Gui hide after a "enter" and "double click left" (only a idea)
Thank you for sharing!!! |
|
| Back to top |
|
 |
Guest
|
Posted: Wed May 24, 2006 11:44 am Post subject: |
|
|
| Try ArsClip |
|
| Back to top |
|
 |
LazFishEnt_As_Guest Guest
|
Posted: Wed Feb 14, 2007 1:09 am Post subject: |
|
|
| How can I make it save all the clips between sessions? I tried for like an hour. plz help. |
|
| Back to top |
|
 |
MarkyMark
Joined: 28 Sep 2007 Posts: 22
|
Posted: Fri Feb 01, 2008 4:36 pm Post subject: |
|
|
Useful script. it'd be nice to be able to save clips through sessions.
 |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3622 Location: Belgrade
|
Posted: Fri Feb 01, 2008 5:19 pm Post subject: |
|
|
Use CLCL - the state of the art open-source clipboard manager. _________________
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|