PDA

View Full Version : keybd_event in VISUAL BASIC 6.0


Antonio S.
12th November 2002, 02:06
Using keybd_event, I am trying to write "Ctrl V" (paste from clipboard).
This are the instructions that I am doing:

keybd_event &H11, 0, 0, 0 > this activate CTRL Key
keybd_event 86, 0, KEYEVENTF_KEYUP, 0 > this press the V Key
keybd_event &H11, 0, KEYEVENTF_KEYUP, 0 > this is suppose to disable CTRL Key...

The problem is , that after adding the ASCII code for "Ctrl" (&H11), the "Ctrl" funtion is ENABLE (toggle). How I can disable the "Ctrl" function for the rest of my program? I try a lot API functions without having good results, even when I unload the program the CTRL key is still enable...

Any idea!!!

Antonio S.:confused:

My OS system is Windows XP

int 21h
12th November 2002, 14:08
http://graphicsmagician.com/vbcourse/05menusdialogs/clipbrd.htm

http://www.catenary.com/howto/clipbrd.html

Antonio S.
14th November 2002, 17:27
int 21h:

Thank you for your answer!!!

The problem is, that I can copy to the "Clipboard", also I can paste the text that is in the Clipboard to another text file using the information that you post, but what I have to do is to paste the information that is inside the Clipboard to the input window of other program (for example, Ifoedit...). The only way that I know to do that is using "Key" commands. In VB I use "keybd_event". With it I can write, using Ascii codes, directly to the input file of other programs. The problem is that when I want to paste from the Clipboard to the input of other program I have to simulate what the operator may do. In this case I have to simulate "CTRL V". This will paste, what is in the clipboard directly to the window of the other program that is open ( and the cursor is blinking).I tried it and it works. The big trouble is that after using the "keybd_event" command for the "Ctrl" key, this key appears to be activated all the time(toggle). I need an intruction or command to desactivated it again. How can I do that???

(This is really making me CRAZY!!!)

Thank you for your help...

Antonio S.

Schultz
14th November 2002, 23:44
Wouldn't this do what you need by printing to the active control on that window as in the first link int 21h posted..

Sub mnuPaste_Click ()
If TypeOf Screen.ActiveControl Is TextBox Then
Screen.ActiveControl.SelText = ClipBoard.GetText()
ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
Screen.ActiveControl.Text = ClipBoard.GetText()
ElseIf TypeOf Screen.ActiveControl Is ListBox Then
Screen.ActiveControl.AddItem ClipBoard.GetText()
ElseIf TypeOf Screen.ActiveControl Is PictureBox Then
Screen.ActiveControl.Picture = ClipBoard.GetData()
End If
End Sub

Antonio S.
29th December 2002, 19:44
Help!!!

I still cannot solve this problem...

I just need to desactivate the CTRL and/or ALT key after is active with keybd_event...

Antonio S.