|
-
Mar 26th, 2002, 11:42 PM
#1
Thread Starter
C# Aficionado
Public Sub Main()
SendKeys Chr(vbKeyReturn)
End Sub
-
Mar 26th, 2002, 11:44 PM
#2
Frenzied Member
Try the following code.
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Private Sub Form_KeyPress(KeyAscii As Integer)
Debug.Print KeyAscii
End Sub
Private Sub Form_Load()
keybd_event vbKeyReturn, 0, 0, 0
keybd_event vbKeyReturn, 0, KEYEVENTF_KEYUP, 0
End Sub
-
Mar 26th, 2002, 11:45 PM
#3
Thread Starter
C# Aficionado
Maybe I missed something.
Is there a problem with mine?
-
Mar 27th, 2002, 12:21 AM
#4
Frenzied Member
No Problem !! Your code is exactly perfect
I used to use SendKeys but on occasions i came to know that it is slow...therefore I personally prefer Keybd_Event....Nothing ELSE...
-
Mar 27th, 2002, 12:26 AM
#5
New Member
thanks for the quick response.....
it works perfect.
steve
-
Mar 27th, 2002, 12:45 AM
#6
Thread Starter
C# Aficionado
OK, cool. I'll keep that in mind.
-
Mar 27th, 2002, 12:48 AM
#7
Frenzied Member
Oops!! I forgot.....
Keybd_Event is capable of simulating key downs of keys..(I am not sure but I think SendKeys cannot send extended keys(Alt,Ctrl )through their virtual key codes, correct me if i am wrong) and it can also send extra information about the keys....therefore it is more than a function which just simulates the key presses....
-
Mar 27th, 2002, 12:59 AM
#8
Thread Starter
C# Aficionado
Yes, it can simulate a key being held down, whereas SendKeys cannot.
However, he only asked for a return press.
Your example appeared somewhat like taking a BFG in to kill one drone (pardon the comparison).
However, it still gets the job done, which is the most important part.
-
Mar 27th, 2002, 06:44 AM
#9
Member
I used SendKey in a prog I wrote in W2KPro and it flew. I ran the program in my Win95 partition and it ran like treacle.
I may try the keybd_event to allow better backward OS compatibility.
Regards
John Pike
There are never any problems, just challenges.
-
Mar 27th, 2002, 06:47 AM
#10
PowerPoster
Lord_Rat, please stop being simple. You know the right answer is always the most complicated one. We expect immediate improvement lest you be shunned from the island.
Thank you.
-
Mar 27th, 2002, 11:52 AM
#11
Thread Starter
C# Aficionado
*slaps forehead
OK .. ... .. ok
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
|