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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sendkeys won't keep sending keys

Status
Not open for further replies.

cold25

Programmer
Feb 11, 2002
41
US
Hi. Might anyone know why the code I have below stops short, after executing the program Hpqdirec.exe? It does nothing else, unless I click the launch button a second time, and then it doesn't execute all of my sendkey commands. I've just begun learning about vbs & sendkeys so I'm not sure what the problems is. Thanks in advance for any help.
cold25


Private Sub cmdLaunchHP_Click()

Call shell("C:\Program Files\Hewlett-Packard\Digital Imaging\bin\Hpqdirec.exe")

Set WshShell = CreateObject("WScript.Shell")

WshShell.AppActivate "HP Director"
WshShell.SendKeys "%{h}"
WshShell.SendKeys "~"
WshShell.AppActivate "hp photo & imaging help"
WshShell.SendKeys "%{n}"
WshShell.SendKeys "{DOWN 50}"
WshShell.SendKeys "~"
WshShell.SendKeys "Typed something."

End Sub
 
My guess is that your code is sending keys, but it is sending them too soon, before your application is fully ready. Try to add code to wait a few seconds to make sure the application is fully ready. Something like this,

WshShell.Sleep 5000

this will wait for 5 seconds.
Place it before the

WshShell.AppActivate "HP Director"

I hope this helps

John Borges
 
If this is VBScript then try forum329

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Thank you both for your suggestions and guidance. It was much appreciated!
cold25
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top