 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
wooing Guest
|
Posted: Fri Dec 28, 2007 12:00 pm Post subject: Multiple copy and paste tool |
|
|
Hi,
I am doing a copy and paste job. I have several different paragraph of text to copy and paste. But each time I don't know what to paste until the very last. What I need is just like the function that excel has provided to choose the content to paste. So I got an idea from the way in starcraft to asign a team to a number. I want to use ctrl + 1 to copy text into slot 1 and use alt + 1 to paste the content in slot 1. and 2 and other numbers. I searched the forum but didn't find a script like that. Maybe it's because I am not familiar with here. Finally I tried to write one myself. The script is like below.
| Code: |
^1::
Send ^c
ClipWait
Clip1 := ClipBoard
return
!1::
ClipBoard := Clip1
Send ^v
return
^2::
Send ^c
ClipWait
Clip2 := ClipBoard
return
!2::
ClipBoard := Clip2
Send ^v
return
^3::
Send ^c
ClipWait
Clip3 := ClipBoard
return
!3::
ClipBoard := Clip3
Send ^v
return
^4::
Send ^c
ClipWait
Clip4 := ClipBoard
return
!4::
ClipBoard := Clip4
Send ^v
return
^5::
Send ^c
ClipWait
Clip5 := ClipBoard
return
!5::
ClipBoard := Clip5
Send ^v
return
^6::
Send ^c
ClipWait
Clip6 := ClipBoard
return
!6::
ClipBoard := Clip6
Send ^v
return
^7::
Send ^c
ClipWait
Clip7 := ClipBoard
return
!7::
ClipBoard := Clip7
Send ^v
return
^8::
Send ^c
ClipWait
Clip8 := ClipBoard
return
!8::
ClipBoard := Clip8
Send ^v
return
^9::
Send ^c
ClipWait
Clip9 := ClipBoard
return
!9::
ClipBoard := Clip9
Send ^v
return
^0::
Send ^c
ClipWait
Clip0 := ClipBoard
return
!0::
ClipBoard := Clip0
Send ^v
return
|
It works pretty good for text.
My question is that how to apply this if not only text?
I tried ClipBoardAll but it did not work.
Can anybody tell me how to copy multi pictures or others? |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6847 Location: Pacific Northwest, US
|
|
| Back to top |
|
 |
wooing Guest
|
Posted: Sat Dec 29, 2007 1:08 am Post subject: |
|
|
dear engunneer,
Thank you very much for such a detailed reply. I think I've got what I need. But I just want to ask the question technically about ClipBoardAll. I changed my script to the code below. It also works well with plain text. But when I open a picture with mspaint. I select one area and press Ctrl + 1 and I select another area and press Ctrl + 2. After that I press Alt + 1, nothing happens. It will be appreciated if you can tell me how to use ClipBoardAll here.
| Code: |
^1::
Send ^c
ClipWait
Clip1 := ClipBoardAll
return
!1::
ClipBoard := Clip1
Send ^v
return
^2::
Send ^c
ClipWait
Clip2 := ClipBoardAll
return
!2::
ClipBoard := Clip2
Send ^v
return
^3::
Send ^c
ClipWait
Clip3 := ClipBoardAll
return
!3::
ClipBoard := Clip3
Send ^v
return
^4::
Send ^c
ClipWait
Clip4 := ClipBoardAll
return
!4::
ClipBoard := Clip4
Send ^v
return
^5::
Send ^c
ClipWait
Clip5 := ClipBoardAll
return
!5::
ClipBoard := Clip5
Send ^v
return
^6::
Send ^c
ClipWait
Clip6 := ClipBoardAll
return
!6::
ClipBoard := Clip6
Send ^v
return
^7::
Send ^c
ClipWait
Clip7 := ClipBoardAll
return
!7::
ClipBoard := Clip7
Send ^v
return
^8::
Send ^c
ClipWait
Clip8 := ClipBoardAll
return
!8::
ClipBoard := Clip8
Send ^v
return
^9::
Send ^c
ClipWait
Clip9 := ClipBoardAll
return
!9::
ClipBoard := Clip9
Send ^v
return
^0::
Send ^c
ClipWait
Clip0 := ClipBoardAll
return
!0::
ClipBoard := Clip0
Send ^v
return
|
|
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1500
|
Posted: Sat Dec 29, 2007 2:52 am Post subject: |
|
|
| Code: | ClipKeys = 1234567890
Loop Parse, ClipKeys
Hotkey, ^%a_LoopField%, ClipKeyLabel
Loop Parse, ClipKeys
Hotkey, !%a_LoopField%, ClipKeyLabel
return
ClipKeyLabel:
StringRight, ClipNN, a_ThisHotkey, 1
Clipboard := Clip%ClipNN%
KeyWait, Alt
Send % ( InStr( a_ThisHotkey, "^" ) ? "{blind}c" : ( ( InStr( a_ThisHotkey, "!" ) && ( clipboard := clip%clipnn% )) ? "{blind}^v" : "" ) )
ClipWait, 1, 1
Clip%clipNN% := ClipBoardAll
return |
Tested. But you have to release the alt key after hitting a nunmber in order to paste (I'm sure you don't mind that, right?)
One likely reason your script was having trouble pasting in MSPaint may be because you were still holding the [alt] key when the script was trying to send ^v. My script works around that with KeWait. _________________ My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|
| Back to top |
|
 |
ManaUser
Joined: 24 May 2007 Posts: 906
|
Posted: Sat Dec 29, 2007 3:16 am Post subject: |
|
|
Almost there.
Just two problems left. First, ClipWait normally looks only for text data. So with if you copy an image instead it just keeps waiting. We can change that by giving it a 1 as the second argument. (The first argument is max time to wait, which I left blank). Second, you need to clear the clipboard before using ClipWait or it may just detect what was already in there. So:
| Code: | ^1::
ClipBoard =
Send ^c
ClipWait, , 1
Clip1 := ClipBoardAll
return
!1::
ClipBoard := Clip1
Send ^v
return |
|
|
| Back to top |
|
 |
tazmanian
Joined: 17 Nov 2007 Posts: 16
|
Posted: Sat Dec 29, 2007 7:36 pm Post subject: Ditto |
|
|
Hi,
Check out Ditto which is absolutely brilliant. IMHO it is the best clipboard utility that exists for Windows. You can set it to store EVERYTHING you copy and paste (although I set it to store 100 clips). You can even search the things you have copied.
What is more its open source, so if you know C++ you can extend it (but it has everything anyway):
http://ditto-cp.sourceforge.net/ |
|
| 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
|