We help IT Professionals succeed at work.

How can multiple values from a vb form window can be placed in clipboard and then can paste back by using function keys or shortcut keys indvidually?

khalidsuhail
khalidsuhail asked
on
I want to grab mulitple textbox values from vb window forms like copy to clipboard and want to paste back outside my application like web application. Any idea? I am using VB6.
for example I have three textbox Name, Date of birth, and ID. I want to grab from my application and paste it to web application by just pressing three different key f1 for name, f2 for DOB and f3 for id.


Thanks
Comment
Watch Question

Store the text in variables like Name$, DOB$, ID$.
Store the total in a string.
S$= Name$ & " " & DOB$ & " " & ID$
Of course, you can format the text any way you like.
Use
Clipboard.SetText S$
to put this into the clipboard.
You did not specify how you want to paste it into the other application. I assume you want to just click on the appliation and then press Shift + Ins.
Does this answer your question?
KarenAnalyst programmer

Commented:
What do you mean by "web application"? Is this something you have written yourself, or do you mean a web browser? If it is a web browser, I don't think you'll be able to use f1/f2/f3 as these are mapped to other things - unless you have full control over the system and will be able to control the mapping.
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009
Commented:
You could use the Hotkey code here:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_20829612.html#9965835

It sets up hotkeys for Ctrl-F10, Ctrl-F11, and Ctrl-F12.

Then change the DoFunctions() sub at the bottom to:
Public Sub DoFunctions(ByVal vKeyID As Byte)
    ' Set the clipboard contents from Text1, Text2, or Text3 based on the hotkey ID
    If vKeyID = 0 Then
        Clipboard.SetText Form1.Text1.Text
    Else
        If vKeyID = 1 Then
            Clipboard.SetText Form1.Text2.Text
        Else
            Clipboard.SetText Form1.Text3.Text
        End If
    End If
    
    ' paste the clipboard contents into the current control using Ctrl-V
    SendKeys "^v", False 
End Sub

Open in new window

Author

Commented:
It doesn't matter what key we can use or combination of keys. Yes I means web application means web browser.
Let me explain once agian the senario.
I have VB application which has client data. Which we have to renter  into web application. which is duplication of work. To avoid mistake and do the job easy I want grab this data name, DOB, and ID in separate clipboard and want to paste in web application by pressing three different keys. it could be any key or key combination like CTRL+N for name, CTRL +D for DOB, CTRL+I for ID.
I have already done for one value. I press command button which place the name to clipboard. and by pressin CTRl+C , I can paste the name. But my problem is how to do it for more than one value?
Thanks for help
Private Sub Command12_Click()
Clipboard.SetText Trim(cboReceiver.Text) + " " + Trim(txtReceiverPersonOnBehalf.Text)
End Sub

Private Sub Command12_Click()
Clipboard.SetText Trim(cboReceiver.Text) + " " + Trim(txtReceiverPersonOnBehalf.Text)
End Sub

Open in new window

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

Commented:
With my approach you wouldn't need to switch back to your form first.  You'd just go to the web form, place the cursor into the desired field, and then press the hotkey.

If you pressed Ctrl-F10 then the value from Text1 would be pasted into the current web form field.
If you pressed Ctrl-F11 then the value from Text2 would be pasted into the current web form field.
If you pressed Ctrl-F12 then the value from Text3 would be pasted into the current web form field.

Author

Commented:
So Idle Mind,
Do you have solution for it?
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

Commented:

Author

Commented:
I am getting error for hot keys registering. How can I reset hot keys?
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

Commented:
It's hitting one of these lines?

    MsgBox "Can not register all or one of the hotkeys CTRL+F10 ... Try other keys this key is already registered by some other running applications.", vbCritical

If another application has already registered the combination you want then you have no recourse but to pick a different key combination.

If you absolutely must trap that key combination then a different approach than hotkeys can be used...such as polling the keyboard state with a timer or by using a low level keyboard hook with WH_KEYBOARD_LL.

Author

Commented:
Hi Idle Mind,
I modify your code and it seems working but not direct method. For every field user has to press CTRL+key to placed the data in current clipboard. then he can paste in web apllication by pressing CTRL+C. Did you find any direct solution for the following senario. Is there any other way to paste ctrl+c ? SendKeys "^v", False is not working.
With my approach you wouldn't need to switch back to your form first.  You'd just go to the web form, place the cursor into the desired field, and then press the hotkey.

If you pressed Ctrl-F10 then the value from Text1 would be pasted into the current web form field.
If you pressed Ctrl-F11 then the value from Text2 would be pasted into the current web form field.
If you pressed Ctrl-F12 then the value from Text3 would be pasted into the current web form field.

Author

Commented:
Hi Idle Mind,
Thanks. I have done it with your approach and its working.