473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Pasting from clipboard with F12

133 100+
I want to paste from clipboard with the F12 key please give some examples because i cannot uderstand any Key Remapping i have read.
Jan 22 '08 #1
12 1951
kadghar
1,295 Expert 1GB
I want to paste from clipboard with the F12 key please give some examples because i cannot uderstand any Key Remapping i have read.
In the KeyDown event write something like:

Expand|Select|Wrap|Line Numbers
  1. if KeyCode = 123 then
  2.    '[your paste code]
  3. end if
that should do for your application. (even then, it could have some advantages to use the KeyUp event or saving the KeyCode in a public variable and write the paste code in the KeyPress event, but that's up to what you need).
Jan 22 '08 #2
gobblegob
133 100+
In the KeyDown event write something like:

Expand|Select|Wrap|Line Numbers
  1. if KeyCode = 123 then
  2.    '[your paste code]
  3. end if
that should do for your application. (even then, it could have some advantages to use the KeyUp event or saving the KeyCode in a public variable and write the paste code in the KeyPress event, but that's up to what you need).

Thanks for your prompt reply but i am unsure about the syntax of pasting to what ever is selected , Do i use Clipboard.GetText ? if so how.

Thanks for your help :)
Gobble.
Jan 22 '08 #3
kadghar
1,295 Expert 1GB
Thanks for your prompt reply but i am unsure about the syntax of pasting to what ever is selected , Do i use Clipboard.GetText ? if so how.

Thanks for your help :)
Gobble.
well, it depends on what you've selected, if its a textbox, something like:
textbox1.paste
should be enough.
Remember the keydown event occurs when the control or form has the focus and you press any key, so you'll have to write something in the controls' keydown event, that you want to have this feature.

Now, if what you want is a little program that 'remaps the keyboard' all the time, that'll probably need a Timer that read the keyboard events. But i dont think we need to complicate it if a single line:

Expand|Select|Wrap|Line Numbers
  1. if keycode=123 then textbox1.paste
in each textbox keydown event will do.
Jan 22 '08 #4
Killer42
8,435 Expert 8TB
I want to paste from clipboard with the F12 key please give some examples because i cannot uderstand any Key Remapping i have read.
What version of VB are we dealing with? I've never heard of a Paste method on textboxes, so presumably that's a later version than what I'm using.

Also, what is that actual issue here - the pasting, or detecting the function key?
Jan 22 '08 #5
gobblegob
133 100+
well, it depends on what you've selected, if its a textbox, something like:
textbox1.paste
should be enough.
Remember the keydown event occurs when the control or form has the focus and you press any key, so you'll have to write something in the controls' keydown event, that you want to have this feature.

Now, if what you want is a little program that 'remaps the keyboard' all the time, that'll probably need a Timer that read the keyboard events. But i dont think we need to complicate it if a single line:

Expand|Select|Wrap|Line Numbers
  1. if keycode=123 then textbox1.paste
in each textbox keydown event will do.

Thanks for the reply's guys,
ok ill explain it a little better basicly i am copying text from a txt file to the clipboard, Then i want to be able to paste it to any input box the mouse has selected.on.

ohh btw using VB6
Thanks Gobble.
Jan 23 '08 #6
Killer42
8,435 Expert 8TB
Try something like this...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
  2.   If KeyCode = vbKeyF12 Then
  3.     Text1 = Clipboard.GetText
  4.   End If
  5. End Sub
  6.  
This is a very simple version, of course. You might want to do the work in a sub somehwre, and you may want to do different processing depending on things like whether the user has selected part of the text in the textbox.

It may also be nicer to do it from the form's KeyDown event rather than coding it individually for each textbox. But that will be slightly more complex to load, since you'd need to know which control has the focus.
Jan 23 '08 #7
QVeen72
1,445 Expert 1GB
Hi,

OK, First make Form's Property : KeyPreview = True.
Say When user Selects a Control and Presses "F8". you copy the contents to the selcetd Control..
Write this code in KeyUp event of the Form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
  2.     If KeyCode = vbKeyF8 Then
  3.         Dim ctl As Control
  4.         Set ctl = Me.ActiveControl
  5.         If TypeOf ctl Is TextBox Then
  6.             ctl.text = Clipboard.GetText
  7.         ElseIf TypeOf ctl Is Label Then
  8.             ctl.Caption = Clipboard.GetText
  9.         End If
  10.     End If
  11. End Sub
  12.  
Regards
Veena
Jan 23 '08 #8
gobblegob
133 100+
Hi,

OK, First make Form's Property : KeyPreview = True.
Say When user Selects a Control and Presses "F8". you copy the contents to the selcetd Control..
Write this code in KeyUp event of the Form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
  2.     If KeyCode = vbKeyF8 Then
  3.         Dim ctl As Control
  4.         Set ctl = Me.ActiveControl
  5.         If TypeOf ctl Is TextBox Then
  6.             ctl.text = Clipboard.GetText
  7.         ElseIf TypeOf ctl Is Label Then
  8.             ctl.Caption = Clipboard.GetText
  9.         End If
  10.     End If
  11. End Sub
  12.  
Regards
Veena

Thank you so much guys i have learned from your examples ,Thanks for all your time in helping me much appreciated.

Gobble.
Jan 23 '08 #9
gobblegob
133 100+
Thank you so much guys i have learned from your examples ,Thanks for all your time in helping me much appreciated.

Gobble.

Ok stuck again i got it to paste within my program's textbox but i want to be able to paste it onto anything with the Fkey.
For example . paste onto an open notepad or paste into explorer ect.

Thanks again
Gobble.
Jan 23 '08 #10
QVeen72
1,445 Expert 1GB
Hi,

You can code, to paste it on VB Controls, as you can tap the Events..
But, outside VB, you cant code...
use Ctrl+V.. thats all..

Regards
Veena
Jan 23 '08 #11
gobblegob
133 100+
Hi,

You can code, to paste it on VB Controls, as you can tap the Events..
But, outside VB, you cant code...
use Ctrl+V.. thats all..

Regards
Veena
oh ok thanks :)
Gobble.
Jan 23 '08 #12
Killer42
8,435 Expert 8TB
oh ok thanks :)
Gobble.
Note that you can use SendKeys to "pretend" the user pressed Ctrl-V.
Jan 24 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Vlado | last post by:
Hello, I need to copy/paste image from Java application to/from the System clipboard. On windows everything is just fine, but on Mac OS is not. The problem is that when I transfer image to the...
0
by: semhelp | last post by:
I am using VB.net to put a bitmap on the clipboard. MS paint and MS wordpad recognize the bitmap on the clipboard, but openoffice Writer does not. If I put the bitmap on the clipboard from MS...
3
by: sneffe | last post by:
Hi, Does anyone have an example of how to paste or inserting an image into a rtf file? I have tried the following but the image is represented as a lot of weird letters and numbers FileOpen(1,...
6
by: Just Me | last post by:
I've seen code that copies a bmp file into a RichTextBox by first putting it into the clipboard and then using Paste to get it into the RichtextBox. This destroys the clipboard contents. Is...
4
by: hamil | last post by:
I would like to right click and select (copy )a file (or directory) name in Windows Explorer and then paste the file (or directory) name into a text box on a vb.net form. Can anyone explain how to...
1
by: Tim Marshall | last post by:
In my not too successful attempts to get an OLE chart object (Graph 11.0) that has been manipulated on a form to be reproduced on a report, I am considering the following procedure. First copy the...
1
by: Grant Smith | last post by:
I've got an application that I can copy some text out of the RichTextBox control. I would like to keep the formatting so I'm able to copy it to the Clipboard with RTF formatting. I have no...
5
by: exhuma.twn | last post by:
As many might know, windows allows to copy an image into the clipboard by pressing the "Print Screen" button on the keyboard. Is it possible to paste such an image from the clipboard into a "Text"...
5
by: bshul | last post by:
Hi, I am hoping someone knows how to finish this javascript. The script copies selected text to the windows clipboard from, for instance, a webpage. This text is a phone number. It then executes the...
0
by: monty0018 | last post by:
Hi, I'm writing a custom clipboard application in VB .NET 2008 similar to Ditto (http://ditto-cp.sourceforge.net/). I have tried targeting .NET Frameworks 2.0, 3.0, and 3.5 with the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.