Send keys to vb6

Just trying to make the enter key pressed after a time delay in vb6, all the examples I find don't work, any help?

Just trying to simulate a key press. Focus doesn't matter.

+1


source to share


7 replies


You may need to provide more details. But IF you are trying to send an input key to a VB6 application and it does not pick it up as usual, the fact that the KeyPreview property for the form is not true. No control with current focus absorbs the pressed keystroke.

If you've created an app that receives an enter key. I highly recommend that you refactor your application so that any code that runs by typing can be executed with code. This is usually done by moving the code to an area that is accessible to both applications. This is because Sendkeys are not known to be deterministic and can cause a lot of weirdness.



There is a key element you can use from the Win32 API information here I found it more reliable than SendKeys.

+2


source


What are you trying to do? How do you know it doesn't work?



If you are trying to call an event handler, you can call it in code instead of sending a keypress.

0


source


SendKeys should always be the last resort.

The problem is really in the spotlight. Before each submission, you must set focus.

Almost everything can be done with scripts, so what are you trying to do?

0


source


I made an application for testing vb6. with 1 shape, 1 default button, 1 timer:

Private Sub Command1_Click()
  Debug.Print CStr(Now) + " Command1"
End Sub
Private Sub Timer1_Timer()
    Debug.Print CStr(Now) + " Sendkeys"
    SendKeys "{Enter}"
End Sub

      

It seemed like it worked when sending in itself. 11/30/2008 18:11:38 Sendkeys 11/30/2008 6:11:48 PM Command1 11/30/2008 18:11:43 Send 11/30/2008 6:11:48 PM Sendkeys 11 / 30/2008 6:11:48 PM Command1

Do you want to submit another process?

0


source


You can try my PushKeys program which is available here . It is syntax compatible with SendKeys, but uses the keybd_event API and has a built in sleep function.

0


source


There are problems with SendKeys in Vista. See this article by Karl Peterson for details and solutions.

0


source


Here's what I do if I want to defer some actions in my script:

t = Timer + 5        'Change 5 to a higher number if you need more time to wait
Do While Timer < t
    DoEvents           'This is necessary to prevent freezing 
Loop

SendKeys "{ENTER}"

SendKeys "{ENTER}", True    'This might also work

      

0


source







All Articles