|
-
Jul 29th, 2003, 09:39 AM
#1
Thread Starter
Junior Member
N00B Need Help :)
I got a problem here i think i want my app to just hit Delete and then Enter ive tried to do like this:
SendKeys "DEL"
SendKeys "ENTER"
ok but when i try it VB just freeze down and cant do anything
-
Jul 29th, 2003, 09:58 AM
#2
Lively Member
Braces
Try it with curly braces
VB Code:
Call Sendkeys("{ENTER}")
Call Sendkeys("{ESC}")
-
Jul 29th, 2003, 10:09 AM
#3
Thread Starter
Junior Member
The proggy still freeze and dont do what its supposed to do
-
Jul 29th, 2003, 10:16 AM
#4
Lively Member
Another way?
I meant
VB Code:
Call Sendkeys("{DEL}")
Call Sendkeys("{ENTER}")
by the way.
Sorry, I didn't pay close enough attention to your original post... don't know where I came up with Enter ESC...
What do you want the app to do? I assume you are trying to communicate with another program. There may be a better way. Sendkeys isn't a very reliable thing to use.
-
Jul 29th, 2003, 10:19 AM
#5
Thread Starter
Junior Member
yes im trying to communicate with another program i want it like when u click on a item then when start my progg it will sendkeys delete and then enter
-
Jul 29th, 2003, 10:49 AM
#6
Lively Member
Potential Explaination
Here's what I think is happening.
The form that calls the SendKeys function is the enabled form at the time and thus is also receiving the Sendkeys function which, in turn, recalls the Sendkeys again. You end up in a loop of sorts. Ctrl+Break will break you out of the loop and get you into break mode in VB.
As far as fixing the issue. I think you're going to need to find the window handle of the window you wish to send the keys to and then use the SetForeGroundWindow function right before you call the sendkeys function to ensure that the keys go to the correct window.
VB Code:
Public Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long
Other functions you may need to play with
VB Code:
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Wish I could help more but its lunch time...
-
Jul 29th, 2003, 10:50 AM
#7
Fanatic Member
ive never seen SendKeys before, I would have thought you should use the KeyDown or KeyUp event.
Want to try that out? I think alot of people can help you there much easier
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
|