|
-
Nov 15th, 2005, 11:45 AM
#1
Thread Starter
Fanatic Member
Multiple Copy/Pastes using hotkeys
I will try to describe what I am doing as best as possible. I do data entry now and then and I have to copy 2 excel fields and paste them into 2 fields in fireworks. Into the hotslice control in frieworks. Anyone who knows this there are 2 fields, a tag and a pathway. So I am copying from ecxel these 2 things 1 at a time and them flipping to fireworks and pasting them 1 at a time and so on.
I would really like to make a program that will record everything you copy (to a point, so it can be set to record only say, twice) and then when you paste it will paste things one at a time. I will try to explain this. You press CTRL+C 3 times and when you press CTRL+V 3 times, it clears the list, so when you press CTRL+C again, it starts the list over.
Steps
You highlight the text "text1" and press CTRL+C
You then highlight the text "text2" and press CTRL+C
You then press CTRL+V and it pastes the first text you copied, "text1"
You then press CTRL+V and it pastes the second text you copied, "text2"
Then resets since it copied 2 and pasted 2
does anyone know how to do this and stuff or maybe set it to different keys that arent hotkeys so it doesnt get over written by windows? Like doing ALT+C instead of CTRL+C
I wil have this program running in the background. This would make my life so much easier just being able to copy, copy, copy, change pages, paste, paste, paste, repeat. rather then jumping back and forth from page to page copy and paste. Any help will be appreciated and I will give recognition in the program.
-
Nov 15th, 2005, 01:15 PM
#2
Re: Multiple Copy/Pastes using hotkeys
Actually, I have made a simular thing in my Source Edit program. I have a clipboard history and a command I call Paste and Cycle. It's not exactly implemented in the way I understand you want it, but it's close enough.
Since you want it to work in any application it requires to change the clipboard content.
To make things a bit simplier I will show you a start for how to do this with text only.
First of all you need to register your application as a clipboard viewer. This is simply done by a call to the SetClipboardViewer API function to which you simply pass the hWnd of your main Form.
VB Code:
Private Declare Function SetClipboardViewer _
Lib "user32" ( _
ByVal hwnd As Long) As Long
This function returns a handle to the next window in the clipboard chain. You must store that value in a variable because you need to use it later. Later on, when your application ends you must unregister your Form from the clipboard viewer chain. This is done by a call to the ChangeClipboardChain API function, to which you pass your hWnd + the hWnd returned by SetClipboardViewer earlier.
VB Code:
Private Declare Function ChangeClipboardChain _
Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndNext As Long) As Long
Now, when your window is a registered clipboard viewer it must process two messages: WM_CHANGECBCHAIN (= &H30D) and WM_DRAWCLIPBOARD (= &H308). You must send these messages to the next window in the clipboard chain (the return value you got from SetClipboardViewer, remember?). You'll do that simply by calling SendMessage, however to be able to trap these messages you must first subclass your Form and check for them in your new WndProc procedure, to keep this short, I haven't included any code on how to subclass a Form, I'll assume you know how to do that (you can search the forum if you don't, many examples is available).
The WM_CHANGECBCHAIN message is sent when a window is removed from the clipboard chain. The window that is removed is in the wParam and the new window is in lParam. You must send this message to the next window unless the window that is removed is the next window, in which case you must update the variable you use to store the next window in, with the lParam value.
The WM_DRAWCLIPBOARD message is sent when the clipboard content has changed, no arguments are passed (wParam and lParam is 0). Here is where you should do your magic and then pass the message to the next window in the chain.
Now, you should of course store all clipboard contents (if it's text that is, easily checked with the Clipboard.GetData method) in an dynamic array. You should later decrease this array when the special Paste shortcut is pressed and then also alter the clipboard content to the text stored previously in the array. I'll leave the code for that up to you, ask again if you need any help with it.
The last thing to do is to register a system-wide Hotkey to be used as the special paste command where you paste and then change the clipboard according to your stored history (the array). Register a hotkey is done using the RegisterHotKey API function, do a search for it I have showed several times how to use that.
The last thing which may be complicated is to actually paste the current content in the foreign application. The simplies way would be to send WM_COPY to the active window, which would work for textboxes, RTF boxes, and in applications like Word and others, but different applications might handle the paste action differently so there is no guarantee that that would work. But in those cases the user could simply paste the regular way and then press your hotkey to cycle the clipboard before he/she pastes again (a bit of a workaround).
I hope this information will be enough to get you started, if you have any questions just ask.
-
Nov 15th, 2005, 03:57 PM
#3
Re: Multiple Copy/Pastes using hotkeys
I'll suggest you make a Macro in Excel in that file and use it to do what you are requiring.
Pradeep
-
Nov 15th, 2005, 03:58 PM
#4
Thread Starter
Fanatic Member
Re: Multiple Copy/Pastes using hotkeys
A macro wont be any good and I would like to use the program with other things other then excel and fireworks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|