AutoHotkey Community

It is currently May 26th, 2012, 8:31 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: ClipWheel 1.0
PostPosted: August 20th, 2009, 5:20 am 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
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 :lol:

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


Last edited by randallf on September 12th, 2009, 8:19 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2009, 8:27 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
I'll give this a shot, and pass it to a few people I think it might help. Thanks for posting it.
Only thing I can think of off-hand is for there to be a way to delete lines from the clipwheel.

Edit: Problem #1. Our security at work doesn't allow you to write directly to teh root directory of c. It might be better to do
Code:
FileRead, ClipFileText, clipwheel.txt


FileAppend , æ, clipwheel.txt
FileAppend, %Appendline%, clipwheel.txt

, so it's in the local directory.

Also, you can fileappend both at the same time, which should help performance ever so slightly.

Lastly, I'd use something other than æ, maybe Chr(somesmallnumber)?

... You did want feedback... Right? :)

Edit2: I also had to switch
Code:
FileAppend , æ, clipwheel.txt
FileAppend, %Appendline%, clipwheel.txt
, so that it would give me my most recent copy as an option.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2009, 8:53 am 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
Hy,
cool script!
But the text insert doesnt run...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2009, 4:02 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
Can you be more specific? Is this the same problem as:
Quote:
Edit2: I also had to switch
Code:
FileAppend , æ, clipwheel.txt
FileAppend, %Appendline%, clipwheel.txt
, so that it would give me my most recent copy as an option.


EDIT: Thanks enguneer! This fixes a host of problems with the code, I'm pretty sure this is what affe was talking about.

I will change the working directory, you are very right about that. And switch those lines, it should have that behavior.

I was running into some odd behavior on vista with copied images and scrolling... can anyone tell me if there is a way to strip all images from a string/the clipboard? This is really meant just for text...

I'd also like to make it so that when you release SHIFT it immediately copies and the current entry stays up so long as you are holding shift, but that's a lot of work I think.

One last edit, The reason I went with æ instead of something else was because if I already have a unique deliminator then I don't have to use stringreplace before I use stringsplit, which no doubt makes it faster though how much I am not sure.

Thanks for the feedback everything helps!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2009, 5:10 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
it just means it won't work for anyone who uses æ in their text. Some of the more obscure symbols, like Chr(31) might be less likely to be what the user is copying/pasting.

Here's how I'm running it right now:
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, ^v
Gosub, nextitem
Return

^+F2::
FileDelete, clipwheel.txt
Reload
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

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
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, %Appendline%, clipwheel.txt
FileAppend , æ, 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

^+F1::
message =
(
Clipwheel Hotkeys:
Ctrl + C: Copy selection to the wheel
Shift + Scroll Wheel: Scroll through wheel items
Middle Mouse Button: Paste, and load next wheel item
Ctrl + Shift + F2: Empty the wheel
Ctrl + Shift + F1: Open this help reminder
Shift + Escape: Kills the clipwheel application
)
Msgbox, % message

Return

+Esc::
ExitApp


I have it auto-increment to the next wheel item when you paste with Mbutton.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2009, 5:38 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
Wow that "Paste, then load next wheel item" is brilliant, that's exactly the sort of thing I was after, you can grab a bunch of lines of text then scroll to the first one you want, then just start left click/middle click to paste them all out without even having to scroll again.

I was looking at trying to make it so that the GUI would stay up until the user releases the shift key, and then do the copy, but the GetKeyState and everything needed for that seems so clunky!

I tried something like this but apparently the conditional does not apply to the hotkey:

While Clipping = 1
{
Shift Up::
;msgbox , shift up fired
ClipBoard := % ClipLineArray%ClipLine%
DllCall("AnimateWindow","UInt",GUI_ID,"Int",250,"UInt","0x90000")
Clipping = 0
Return
}

Any ideas on that? Would it require a whole new method?

Also also,

I changed this, because Control+Shift+Escape is task manager in windows...
Code:
Ctrl + Shift + F12: Kills the clipwheel application
)
Msgbox, % message

Return

^+F12::
ExitApp


and I guess forget that other stuff because this is working fine as it is, my original thought was that the brief preview would be enough and it seems to be, rather than having another key release/press to go through.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2009, 7:46 pm 
Here's my most recent code with tray menu and more... I don't see where to upload a file or I'd provide an EXE w/icon...

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, Invisible Text Here


;OPTIONAL - binds middle mouse button to 'paste' operation
Mbutton::
Send, ^v
Gosub, nextitem
Return

^+F2::
FileDelete, clipwheel.txt
Reload
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

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
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, %Appendline%, clipwheel.txt
FileAppend , æ, 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

^+F1::
HelpLabel:
message =
(
Clipwheel Hotkeys:

Ctrl + C: Copy selection to the wheel
Shift + Scroll Wheel: Scroll through wheel items
Middle Mouse Button: Paste, and load next wheel item

Ctrl + Shift + F1: This Menu
Ctrl + Shift + F2: Empty the wheel
Ctrl + Shift + F12: Kills the clipwheel application

Clip file is in working directory as ClipWheel.txt
)
Msgbox, % message
Return

CreditsLabel:
message =
(
Randall Feuerlein 2009
Written in AutoHotKey
Special thanks to the AutoHotKey forum gurus and IRC denizens,
without you this would not be possible!
)
Msgbox, % message
Return

^+F12::
ExitApp


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2009, 8:37 pm 
Offline

Joined: January 2nd, 2008, 4:47 am
Posts: 150
Location: Freenode IRC
What happens when someone copies a huge document to their clipboard? Say an entire wikipedia article, or this entire thread? Does it still treat each line for line? Or does it show a brief clip of the first paragraph, but will replace the clipboard with the entire document as it was first copied?

_________________
Image

Need help right away? Get live support on IRC.
Already have an IRC client installed? /join #ahk


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2009, 9:13 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
Raccoon wrote:
What happens when someone copies a huge document to their clipboard? Say an entire wikipedia article, or this entire thread? Does it still treat each line for line? Or does it show a brief clip of the first paragraph, but will replace the clipboard with the entire document as it was first copied?


As long as the character æ is not present it should be just fine. If the character is present it will end up splitting a new entry at that point.

Hey, engineer, can you paste the actually character you were recommending? How can I type it with the alt key/numpad?

I tested this in a file with over 202,000 characters in it, 2500 lines, and it still functioned. at 81,000 characters it is speedy. That means it is capable of reading through 202,000 characters 4-5 times and parsing text quickly from that in about .25 of a second so even if your document is large it should be fine. It will depend a lot on your CPU speed, that was on my 3 core phenom 8450 with readyboost on vista.

However, keep in mind it is only meant for text, (rapid copy and paste for those who use a lot of forms or programs with a lot of fields) images and some other special clipboard objects will not push through. In fact, and as may even be desired by some users who would want this sort of thing, it should plain-text the whole string.

If anyone knows a way to enhance the clipboard and storage mechanism so that it can hold any type of clip object I'm listening! :)

Also, as a note for a future change as I have no place else to put it ATM when you copy something it should set the scroller to the last line.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2009, 10:39 pm 
Offline

Joined: January 2nd, 2008, 4:47 am
Posts: 150
Location: Freenode IRC
AHK doesn't handle any other objects (that it can interpret) besides text, or the text of portion of objects with non-text elements.

In fact, ClipboardAll isn't the true, original, clipboard contents as it was first filled by the original program, and in truth, there are probably some graphic or audio software that will take offense to AHK manipulating its contents. AHK strips out many of the objects it feels are redundant, to save space/memory.

I discovered this when trying to save ClipboardAll to a file, and compared it to files saved by Windows Clipboard Viewer (clipbrd.exe) which got me looking at the AHK source for clipboard manipulation.

Anyway, no, AHK doesn't know how to read other formats besides plain text, as of 1.48.0.3.

_________________
Image

Need help right away? Get live support on IRC.
Already have an IRC client installed? /join #ahk


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2009, 4:19 am 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
Sorry I edited this a ton of times lol, I got into working on it I guess, but here is a bunch of changes!

When you copy new text now it sets the current line to the bottom of the file. This means essentially that if you copy text and then scroll down once, you have the text you just copied, and if you scroll up once you have the next to last text.

This should make it much more intuitive, I found that when using it I was always struggling to find my place, like a rolodex arranged randomly lol

I also added a bypass so you can just use the clipboard without the wheel. I didn't make it just control shift C because a lot of programs use that.

I also changed the delay to 1.45 seconds. I hightly recommend that you change this to suit yourself.

Control+Shift+1 is now clear clipboard. I added several new lines to clear the variables, too.

Control Shift F1 is help which has been updated.

Alt + Wheeldown now moves you to the bottom of the file. I think this is very useful because if you get lost scrolling, or just want your last cliptext again, you can just alt+scrolldown and there you have it.

I don't know about everyone but I use control with my palm and alt with my thumb typically and this layout seems to suit the "WASD" style that I'm used to quite well.

Feedback? :)

In the future I should make a gui from the system tray to make the delay editable. This could also allow the user to change the fade time.

2.0 could have a gui for remapping the keys. (zzzzzzz)


Still interested in a better way to do this because in previous versions it felt a tad slow:
Code:
~^c::
ClipBoard =
Send , ^c
ClipWait


Here's the entire current 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, 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

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
{
   Cliplein := 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
ClipBoard := % ClipLineArray%ClipLine%
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:
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
Alt + Scroll Down: Goes to bottom line
Middle Mouse Button: Paste, and load next wheel item

Ctrl + Shift + F1: This menu

Ctrl + Shift + 1: Empty the wheel

Ctrl + Shift + F12: Kills the clipwheel application `(or use tray icon`)

Ctrl + Alt + Shift + C: Copy to the clipboard, but not to the wheel

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


^+1::
FileDelete, clipwheel.txt
ClipFileText := ""
ClipBoard := ""
ClipLineArray%ClipLine% := ""
GuiControl,, GuiText, CLEARED
Return

!WheelDown::
ClipLine := delimcount
GoSub Spin
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2009, 8:56 am 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
Hy randalff,
sorry, but the newest script at the bottom now works like intended.
I dont know what problem I had yesterday...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2009, 3:27 pm 
It doesn't work for me... Items are correctly copied in clipwheel.txt but when I try to scroll through items, only the first one is displayed.

Any ideas?

Thanks!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2009, 3:51 pm 
Added check for 0 before --, fixed leaving items in memory on clear (hopefully).

As to why it won't scroll I am not sure, can you try this new code and see? The way it works is to parse the whole file into an array and then display the array number.

Are you using EN/US key setup?

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, 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
{
   Cliplein := 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
ClipBoard := % ClipLineArray%ClipLine%
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:
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

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


^+1::
Gui, Cancel
FileDelete, clipwheel.txt
ClipFileText := ""
ClipBoard := ""
ClipLineArray%ClipLine% := ""
GuiControl,, GuiText, CLEARED
Return

!WheelDown::
ClipLine := delimcount
GoSub Spin
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2009, 4:01 pm 
Yes I am using EN/US. I tried the new version and it doesn't work either.

I am very interested by that script, I will do some investigation as soon as I can and will let you know my findings.

Thanks!


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: bekihito, Exabot [Bot] and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group