Sendkeys during program startup
To make life easier, one of the things I provide in programs I write is a /Sendkeys= parameter for the command line. What is always yucky poo in any given program environment is figuring out what event in the startup sequence is
1) Unique so you don't do it again.
2) Always will occur
3) Will occur late enough so that the form that is the target of the key strokes is visible and accepting keys.
Suggestions please for VB.net as to what event is appropriate for this. My initial attempts were feable at best.
Regards,
Al
Hi,
You could try placing messageBox's on the startup events so you would know which comes first or which is being executed repeatedly...
In sending keys, try placing your code in the Activated event of the form...
BTW also try using the SendKeys.Sendwait Method on sending keys...
cheers,
Paul June A. Domag
Here is a follow up to my original posting to document what I've done that works!
For obscure reaons I'm carefully controlling the start up of my main form. Lot's of stuff with the potential of displaying lots of other forms happens first (License, logon, key entry, etc.) So ... given that frm is an instance of the main form, here is the sequence I follow. It works wonderfully. The first line loads the data files required and if that fails sets things up to cause the options dialog to show once the main program is up and running. Note that wait must be true in the sendkeys calls to make this work.
If Not frm.HandleData() Then keys = "{F10}TO"
frm.Show() ' sendkeys needs the form to be showing
Application.DoEvents()
If keys <> "" Then My.Computer.Keyboard.SendKeys(keys, True)
' see if the command line wants to send keys
if LI.Utility.cliValue(LI.Constants.sendkeys, keys) Then My.Computer.Keyboard.SendKeys(keys, True)
' handle other command line stuff
application.run