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
Printable View
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
Try it with curly braces
VB Code:
Call Sendkeys("{ENTER}") Call Sendkeys("{ESC}")
The proggy still freeze and dont do what its supposed to do
I meant
by the way.VB Code:
Call Sendkeys("{DEL}") Call Sendkeys("{ENTER}")
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.
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
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...
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