AutoHotkey Community

It is currently May 27th, 2012, 11:27 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: August 21st, 2009, 4:42 pm 
Offline

Joined: May 15th, 2007, 8:59 pm
Posts: 169
This is a great idea for a script. I have wanted something flexible like this without so many GUI options or Hotkeys.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2009, 10:55 pm 
Offline

Joined: July 30th, 2009, 1:54 am
Posts: 60
Is it possible to modify the script to allow clicking the tool tip for pasting?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 22nd, 2009, 12:12 am 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
First, I have modified the script so that the sending to the clipboard occurs when the fader fires and not every time you scroll, this makes it much easier to modify. It also makes it 100x saner, I almost can't believe I didn't notice it.

New script:

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
{
   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

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


For the modifications, to do this you would need to:

Either disable or greatly increase the duration of the fade timer(if you want a timeout or max wait), I assume you don't want both autofade and the click,

by commenting out this line in the SPIN: routine:

Code:
SetTimer, CloseWindow, -1450


Then, add a gLabel routine to this text so when clicked it will fire the routine:

Code:
Gui, Add, Text, vGuiText gMyLabel, Invisible Text Here


Use the following for the Label (at the bottom of the file probably):

Code:
MyLabel:
GoSub, CloseWindow
Return


Or maybe just

Code:
Gui, Add, Text, vGuiText gCloseWindow, Invisible Text Here


Really it's pretty easy to modify this script to fit the behavior that you desire, you could set up whatever bind or thing you want that just points at the close CloseWindow label and it will 'pick' the current line, even if it is not visible. Like I identified above for many behaviors you would want to disable the fader entirely.

Next version I'll try to add labels to the top so that you can easily change durations and other things...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 22nd, 2009, 2:08 am 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
Oh, I see what you mean. Click the tooltip to cause a paste action, I misread your statement. That's a great idea, thanks!

I'll add it to the program right now:

Code:
Gui, Add, Text, vGuiText gTextClick, Invisible Text Here


Code:
TextClick:
Gui, Cancel
ClipBoard := % ClipLineArray%ClipLine%
Send , ^v
;if you want it to also scroll down a line:
;Clipline++
;GoSub Spin
Return



Whole script:


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



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2009, 1:05 am 
Offline

Joined: May 17th, 2007, 6:03 pm
Posts: 391
Location: Titan
Very nice and original idea.
________
Love quotes forum


Last edited by lilalurl.T32 on March 13th, 2011, 7:44 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2009, 4:54 am 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
lilalurl.T32 wrote:
Very nice and original idea.


Thanks! I want to write version 2 (from the ground up) but I have a lot on my plate atm... in fact it's really kinda nagging me because I've learned so much since I wrote this that it won't even really look similar and will be worlds faster.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2009, 7:23 am 
Offline

Joined: February 7th, 2009, 11:28 pm
Posts: 384
randallf wrote:
Still interested in a better way to do this because in previous versions it felt a tad slow:
Code:
~^c::
ClipBoard =
Send , ^c
ClipWait


What about using OnClipboardChange label?

Code:
OnClipboardChange:
;list hotkeys to ignore (if any)
If A_ThisHotkey In #Right,#Up,#Down,#s,#t,#x
  Return

;not sure why i added the delay - maybe to give my other clipboard hotkeys/scripts time to finish
Sleep, 300

;if clipboard content is text do A
If (A_EventInfo = 1)
  FileAppend,%clipboard%,%A_MyDocuments%\clipwheel.txt
;if not text (e.g. PrntSc was used to store an image)
Else If (A_EventInfo = 2)
  Convert(0, A_MyDocuments . "" . A_Now . ".png")
;requires convert() from Sean's ScreenCapture.ahk: http://www.autohotkey.com/forum/viewtopic.php?t=18146
Return

_________________
Hardware: 1.8 GHz laptop with 4 GB ram, Windows XP/SP3
Software: Prevx, Privatefirewall, KeyScrambler.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2009, 5:10 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
Quote:
What about using OnClipboardChange label?


yep, I recently discovered this, I didn't think it existed before I even wrote a whole function using clipwait to do it but this will make it easy

if anyone interested in this has any ideas or requests for features I am all ears

I do plan to add a menu to v2 to control positioning, fade delays and a couple other features like clearing the history or setting its length

i also want to do a more 'wheel' looking gui that shows 3 entries (with the top and bottom slightly faded) instead of 1, this should make it much easier to tell where you are in the history

does anyone have any thoughts on truncation? one problem with the current version is that if you are using large clipboard objects it will take up the whole screen and also cut if off so if changes are at the end of large objects you can't tell what it is that you want

I think it should have a timestamp for when the text came in as well, perhaps, a few options are having it show the begining and end, the display could be like:

Quote:
12:01 | This a clipboard item. |
==================
12:02 | This is an example of some very very ... very very long text. |
==================
12:07 | This is a very very ... very very long history item |


It could also adjust the font size trying to get things to fit. I think the 'dummy gui' method would work well for that.

I think the next version will use clipboardall with an array of clipboard items.

The next version also should not require binds for ^v or ^c in any way, it should work from OnClipBoardChange:

Any thoughts?


Last edited by randallf on September 12th, 2009, 10:42 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2009, 7:39 pm 
Offline

Joined: April 30th, 2006, 6:23 pm
Posts: 358
Location: Shigle Springs
randallf wrote:

Any thoughts?


Yes,
#1. THANKYOU
#2. I tried to modify a script here to do something like this, but it had bugs and I gave up. http://www.autohotkey.com/forum/viewtop ... 998#235998
#3. This looks like exactly what I have been wanting for years. (I have been using MS Clipboard :oops: :roll: ) I will try it now.
#4. You should update the original post with most recent code.

_________________
CPULOCK.com
virusSWAT.com
Computer Repair Computer Service.com
911PCFIX.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2009, 8:20 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
DeWild1 wrote:
#4. You should update the original post with most recent code.


Done.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: bowen666, Google Feedfetcher, MSN [Bot], nomissenrojb, nothing and 65 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