Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding the window for a process...

Status
Not open for further replies.

JediBMC

MIS
Dec 5, 2003
178
US
I have a little application that launches a DOS program to connect to a device and retrieve information. Here is, basically, what I am doing:
-Open the DOS application using system.diagnostics.process.start
-set the enableraisingevents property to true
-Send keystrokes using sendkeys.sendwait
-wait for the process to exit

Sometimes, the keystrokes do not seem to be passed to the DOS application and are, instead, lost. It is my guess that this is caused by the process not necessarily having the focus when the keys are sent. So is there a way of ensuring that the process has the focus prior to sending the keys? Or perhaps a different way of sending key strokes that specifies the process they are being sent to?

Thanks, in advance!

-Brian-
I'm not an actor, but I play one on TV.
 
You could try something like:

Dim p As System.Diagnostics.Process = System.Diagnostics.Process.Start(TheProgramIWantToRun)

'when you need to send keys use:
AppActivate(p.Id) 'This should give focus to the other program
SendKeys.SendWait(KeysToBeSent)

This has not been tested.


Hope this helps.
 
As always with these kind of procedures, there is one thing you can never be sure of "THE USER", if it decides to go on a click-marathon, it won't work.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top