Here is the most recent version of the code:
Code:
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance FORCE
Menu, Tray, add
Menu, Tray, add, ClipWheel Help, HelpLabel
Menu, Tray, add, ClipWheel Credits, CreditsLabel
AutoTrim, off
GoSub, HelpLabel
;prime the variables
ClipLine = 1
delimcount = 2
;set up the GUI
Gui, 1:Default
Gui, Margin, 0,0
Gui +LastFound
GUI_ID:=WinExist()
gui, font, s16, Arial
Gui, -Caption +AlwaysOnTop +Border
Gui, Add, Text, vGuiText gTextClick, Invisible Text Here
;OPTIONAL - binds middle mouse button to 'paste' operation
Mbutton::
Send, ^v
Gosub, nextitem
Return
;shift wheel down
nextitem:
+WheelDown::
SetTimer, CloseWindow, Off
ScrollUp = 0
ScrollDown = 1
ClipLine++
If ClipLine > delimcount
{
Clipline = 1
}
GoSub Spin
Return
;shift wheel up
+WheelUp::
SetTimer, CloseWindow, Off
ScrollUp = 1
ScrollDown = 0
If ClipLine <> 0
{
ClipLine--
}
If ClipLine = 0
{
ClipLine := delimcount
ScrollUp = 0
}
GoSub Spin
Return
;Main Routine
Spin:
;read text from clipboard file into memory
FileRead, ClipFileText, clipwheel.txt
;stringsplit that file based on the deliminator æ
StringSplit, ClipLineArray, ClipFileText, æ
;count total deliminators in file to determine upper limit
delimcount=
Loop, Parse, ClipFileText
{
If A_loopField=`æ
delimcount++
}
;recheck for mean limits
If clipline > %delimcount%
{
ClipLine := 1
}
If clipline < 1
{
clipline := 1
}
;create a junk GUI with the same features as the text
;this is a hack to allow resizing of the GuiText control itself so that it fits
;correctly in the window, since there is unfortunately no "GuiControl, Delete" command
Gui, 3:Default
Gui, Margin, 0,0
Gui, font, s16, Arial
Gui, -Caption +Border
Gui, Add, Text, vt2, % ClipLineArray%ClipLine%
;this next command is more complicated than it looks
GuiControlGet, t2, Pos
Gui, Destroy
;update the GuiText control size with the values from above
Gui, 1:Default
GuiControl, Move, GuiText, x%t2x% y%t2y% w%t2w% h%t2h%
GuiControl,, GuiText, % ClipLineArray%ClipLine%
;display the GUI
ReShow:
Gui, Show, autosize xcenter y0 AlwaysOnTop NoActivate, ClipWheel
;set the timer to close the window and copy the text if the user stopped scrolling
SetTimer, CloseWindow, -1450 ;length of time before the displayed clipboard text fades and the clipboard is set
Return
;bypass clipwheel entirely
!^+c::
Send , ^c
Return
;user is copying text via control+c
;this is intentional, it's probably possible to scan for clip changes, perhaps via "While Clipboard <> ",
;but this would clash with other scripts I use that use the clipboard
~^c::
ClipBoard =
Send , ^c
ClipWait
AppendLine := Clipboard
FileAppend, %Appendline%, clipwheel.txt
FileAppend , æ, clipwheel.txt
;recalculate highest delim
delimcount=
Loop, Parse, ClipFileText
{
If A_loopField=`æ
delimcount++
}
;Set Current to highest (most recently copied)
;so when you copy and wheel down once, you are on the text that you just copied
;if you wheel up once, you have the second-to-last text
;this should it much easier to replace normal copy/paste behavior with clipwheel
ClipLine := delimcount
Return
;call a DLL to fade out the window gracefully
;in "Int",250" 250 is the duration in ms
CloseWindow:
ClipBoard := % ClipLineArray%ClipLine%
DllCall("AnimateWindow","UInt",GUI_ID,"Int",250,"UInt","0x90000")S
Return
^+F1::
HelpLabel:
message =
(
Clipwheel Hotkeys:
Ctrl + C: Copy selection text to the wheel
Shift + Scroll Wheel: Scroll through wheel items
Middle Mouse Button: Paste, and load next wheel item
Left Click on Scroll Block: Paste, and ( unimplemented ) load next wheel item
Alt + Scroll Down: Goes to bottom line
Ctrl + Shift + 1: Empty the wheel
Ctrl + Alt + Shift + C: Copy to the clipboard, but not to the wheel
Ctrl + Shift + F1: This menu
Ctrl + Shift + F12: Kills the clipwheel application `(or use tray icon`)
Clip file is in working directory as ClipWheel.txt
See tray for credits!
)
Msgbox, % message
Return
CreditsLabel:
message =
(
RandallF 2009
Written in AutoHotKey
Special thanks to the AutoHotKey forum gurus and enguneer for getting
it on the right track, without you all this would not be possible!
)
Msgbox, % message
Return
^+F12::
ExitApp
TextClick:
Gui, Cancel
ClipBoard := ""
ClipBoard := % ClipLineArray%ClipLine%
ClipWait
Send , ^v
;if you want it to also scroll down a line:
;Clipline++
;GoSub Spin
Return
^+1::
Gui, Cancel
FileDelete, clipwheel.txt
ClipFileText := ""
ClipBoard := ""
ClipLineArray%ClipLine% := ""
GuiControl,, GuiText, CLEARED
Return
!WheelDown::
ClipLine := delimcount
GoSub Spin
Return
Hello everyone,
I am still new to autohotkey but have been working on this for a while, this is the very first version but it does work quite well on XP and Vista and seems to be reasonably fast.
This I call ClipWheel, and whenever you use Control C to copy something it stores that text in a file. ( c:\clipwheel.txt )
When you hold shift and scroll the mousewheel up and down, you can see the lines of text copied to the file (i.e. your clipboard history) displayed at the top of the screen. When you find the one you want, just stop scrolling and it will copy that text to the clipboard. It's very unobtrusive and doesn't steal focus in any way.
It runs in a circle, if it reaches the 'top' of the file it goes automatically to the bottom and if it reaches the bottom, well, you got it.
If you try to use it with images in HTML it will copy the ALT text of the image.
I stress tested it with a file set up like this:
æA12345678901234567890123456789012345678901234567890123456789012345678901234567890
æB12345678901234567890123456789012345678901234567890123456789012345678901234567890
...and so on and so on through the alphabet so that I could watch it scroll.
first stress test: 2500 line file of 81 characters each line, runs ok, a little slow but usable
second test was: 1000 lines of 81 characters each and runs great.
I can't see those with sore hands not liking it, it easily allows you to run through fields on a page highlighting and copying and then switch to another window, scroll through your copies and paste data in where necessary. I can't wait to test it more and see what limits it has. Can you help me test it?
I think it would also go really well with this, which is commented out, which binds middle mouse button to "Paste" op:
Code:
Mbutton::
Send, {CtrlDown}v{CtrlUp}
Return
My extremely newbie code follows, This Frankensteins monster wouldn't be possible without you all, I had a ton of help on this from the AHK community, special thanks to the folks in the AHK IRC channel and CHOOSE CLIP or WHEEL
Code:
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance FORCE
AutoTrim, off
;prime the variables
ClipLine = 1
delimcount = 2
;set up the GUI
Gui, 1:Default
Gui, Margin, 0,0
Gui +LastFound
GUI_ID:=WinExist()
gui, font, s16, Arial
Gui, -Caption +AlwaysOnTop +Border
Gui, Add, Text, vGuiText, Invisible Text Here
;OPTIONAL - binds middle mouse button to 'paste' operation
;Mbutton::
;Send, {CtrlDown}v{CtrlUp}
;Return
;shift wheel down
+WheelDown::
SetTimer, CloseWindow, Off
ScrollUp = 0
ScrollDown = 1
ClipLine++
If ClipLine > delimcount
{
Clipline = 1
}
GoSub Spin
Return
;shift wheel up
+WheelUp::
SetTimer, CloseWindow, Off
ScrollUp = 1
ScrollDown = 0
ClipLine--
If ClipLine = 0
{
ClipLine := delimcount
ScrollUp = 0
}
GoSub Spin
Return
;Main Routine
Spin:
;read text from clipboard file into memory
FileRead, ClipFileText, c:\clipwheel.txt
;stringsplit that file based on the deliminator æ
StringSplit, ClipLineArray, ClipFileText, æ
;count total deliminators in file to determine upper limit
delimcount=
Loop, Parse, ClipFileText
{
If A_loopField=`æ
delimcount++
}
;recheck
If clipline > %delimcount%
{
ClipLine := 1
}
;create a junk GUI with the same features as the text
;this is a hack to allow resizing of the GuiText control itself so that it fits
;correctly in the window, since there is unfortunately no "GuiControl, Delete" command
Gui, 3:Default
Gui, Margin, 0,0
Gui, font, s16, Arial
Gui, -Caption +Border
Gui, Add, Text, vt2, % ClipLineArray%ClipLine%
;this next command is more complicated than it looks
GuiControlGet, t2, Pos
Gui, Destroy
;update the GuiText control size with the values from above
Gui, 1:Default
GuiControl, Move, GuiText, x%t2x% y%t2y% w%t2w% h%t2h%
GuiControl,, GuiText, % ClipLineArray%ClipLine%
;display the GUI
Gui, Show, autosize xcenter y0 AlwaysOnTop NoActivate, ClipWheel
;set the timer to close the window and copy the text if the user stopped scrolling
SetTimer, CloseWindow, -1000 ;length of time before the displayed clipboard text fades and the clipboard is set
ClipBoard := % ClipLineArray%ClipLine%
Return
;user is copying text via control+c
;this is intentional, it's probably possible to scan for clip changes, perhaps via "While Clipboard <> ",
;but this would clash with other scripts I use that use the clipboard
~^c::
ClipBoard =
Send , ^c
ClipWait
AppendLine := Clipboard
FileAppend , æ, c:\clipwheel.txt
FileAppend, %Appendline%, c:\clipwheel.txt
Return
;call a DLL to fade out the window gracefully
;in "Int",250" 250 is the duration in ms
CloseWindow:
DllCall("AnimateWindow","UInt",GUI_ID,"Int",250,"UInt","0x90000")S
Return