AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Second clipboard
PostPosted: January 19th, 2012, 11:58 pm 
Offline

Joined: January 19th, 2012, 11:37 pm
Posts: 5
I just want a very simple second copy/paste. I know there are lots of clipboard managers, but I couldn't find one that did only this.

I have this:

Code:
^h::
ClipSaved := ClipboardAll   ; Save the entire clipboard
Clipboard =                 ; Clear the clipboard (useful for when there is no highlighted text)
Send ^c                     ; Copy the highlighted text to the clipboard
ClipWait 1                  ; Wait up to 1 second for the clipboard to contain data
if ErrorLevel               ; If there is no data in the clipboard after 1 second, exit
Stuff := Clipboard   ; Assign the clipboard content to the variable
Clipboard := ClipSaved      ; Restore the original clipboard
ClipSaved =                 ; Free the memory in case the clipboard was very large
return

^k::SendInput %Stuff%


Can anyone help me get a second clipboard if not like this?

Thanks,

Brent.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 20th, 2012, 8:47 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
Duplicate your code in the same file, choose different hotkeys for the (2) new hotkeys.

Change the variable "Stuff" to some other name.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2012, 2:02 am 
Offline

Joined: January 19th, 2012, 11:37 pm
Posts: 5
Leef_me wrote:
Duplicate your code in the same file, choose different hotkeys for the (2) new hotkeys.

Change the variable "Stuff" to some other name.


Thanks. I've just gotten back to this. I worked out that hadn't given the If Errorlevel an action.

I've got the following, which almost works:

Code:
^e::
ClipSaved := ClipboardAll   ; Save the entire clipboard
Clipboard =              ; Clear the clipboard (useful for when there is no highlighted text)
Send ^c                     ; Copy the highlighted text to the clipboard
ClipWait, 1                 ; Wait up to 1 second for the clipboard to contain data
if ErrorLevel               ; If there is no data in the clipboard after 1 second, exit
{
   MsgBox, The attempt to copy text onto the clipboard failed.
   return
}
NewClipboard := Clipboard   ; Assign the clipboard content to the variable
Clipboard := ClipSaved      ; Restore the original clipboard
ClipSaved :=              ; Free the memory in case the clipboard was very large
return

^r::SendInput %NewClipboard%


The only problem now is that when I ^e text with multiple lines, when I ^r every new-line is sent as 2xnew-line. Any idea on how to stop that?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2012, 8:57 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
referring to your posted script, I had to add a line to make the script reliably copy & paste
Code:
NewClipboard := Clipboard   ; Assign the clipboard content to the variable

sleep, 100 ; <--- added this line

Clipboard := ClipSaved      ; Restore the original clipboard


>>The only problem now is that when I ^e text with multiple lines, when I ^r every new-line is sent as 2xnew-line. Any idea on how to stop that?

http://www.autohotkey.com/docs/misc/Clipboard.htm
Please notice the first example script has "Loop, parse, clipboard, `n, `r "
Please read the docs to understand how the parameters work http://www.autohotkey.com/docs/commands/LoopParse.htm
And read about the characters `n, `r
http://www.autohotkey.com/docs/commands/_EscapeChar.htm

Depending on the program that you paste text into the above characters may be interpreted differently.
Notpad for example expands them so the original text as a blank line where there was none.

Do some experimenting with this command to see if you can replace `n`r with just one or the other, or with `r`n.

See the examples here
http://www.autohotkey.com/docs/commands ... eplace.htm


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2012, 12:06 am 
Offline

Joined: January 19th, 2012, 11:37 pm
Posts: 5
Hi, thanks. I had read those pages, and it didn't make much sense to me. I've added the sleep, and the line replacing `r with nothing.

Now I've got the code:

Code:
^e::
ClipSaved := ClipboardAll   ; Save the entire clipboard
Clipboard =              ; Clear the clipboard (useful for when there is no highlighted text)
Send ^c                     ; Copy the highlighted text to the clipboard
ClipWait, 1                 ; Wait up to 1 second for the clipboard to contain data
if ErrorLevel               ; If there is no data in the clipboard after 1 second, exit
{
   MsgBox, The attempt to copy text onto the clipboard failed.
   return
}
NewClipboard := Clipboard   ; Assign the clipboard content to the variable
sleep,100
Clipboard := ClipSaved      ; Restore the original clipboard
ClipSaved :=              ; Free the memory in case the clipboard was very large
StringReplace, NewClipboard, NewClipboard,`r,,All
return

^r::SendInput {raw}%NewClipboard%


When ^r this text here in IE it works ok, but then 1 second later it truncates the text to the following and adds it to the Preview Window

Code:
^e::
ClipSaved := ClipboardAll   ; Save the entire clipboard
Clipboard =              ; Clear the clipboard (useful for when there is no highlighted text)
Send ^c                     ; Copy the highlighted text to the clipboard
ClipWait, 1                 ; Wait up to 1 second for the clipboard to contain data
if ErrorLevel               ; If there is no data in the clipboard after 1 second, exit
{
The attempt to copy text onto the clipboard failed.


Something is going on beyond my ability to learn about and debug. I don't suppose you've got any other pointers? Or if anyone else is reading this do they know of any simple copy/paste autohotkey scripts?

Thanks for all your help.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2012, 6:37 am 
Offline

Joined: February 10th, 2012, 6:00 am
Posts: 3
http://www.autohotkey.com/forum/topic79 ... ht=winclip
Winclip seems to be a good way to do your own clipboard with Min amount of programming


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2012, 6:44 am 
Offline

Joined: January 19th, 2012, 11:37 pm
Posts: 5
Thanks. I'll check it out.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2012, 9:04 am 
Also check VirClip() http://www.autohotkey.com/wiki/index.ph ... #Clipboard


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Google Feedfetcher, immunity, sjc1000 and 72 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