SeltzerWater
asked on
Sendkeys in VBscript not working
I am trying to automate a scanning application for some users.
I thought this would be simple, but its not working.
All I need to do is open the app, send ALT+s and then ALT+F, and then two {ENTER} keys.
here is what I have so far...
set WshShell = Wscript.CreateObject("WScr ipt.Shell" )
WshShell.run"FImage.exe" ,3,true
WSHShell.AppActivate "FImage"
wscript.sleep 200
wshshell.SendKeys "%s"
wscript.sleep 100
wshshell.SendKeys "%f"
wscript.sleep 100
WshShell.SendKeys "{ENTER}"
After the app opens, it just sits there, the ALT+ S does not open the Menuitem.
Does the .AppActivate use the name of the executibale or something else?
I thought this would be simple, but its not working.
All I need to do is open the app, send ALT+s and then ALT+F, and then two {ENTER} keys.
here is what I have so far...
set WshShell = Wscript.CreateObject("WScr
WshShell.run"FImage.exe" ,3,true
WSHShell.AppActivate "FImage"
wscript.sleep 200
wshshell.SendKeys "%s"
wscript.sleep 100
wshshell.SendKeys "%f"
wscript.sleep 100
WshShell.SendKeys "{ENTER}"
After the app opens, it just sits there, the ALT+ S does not open the Menuitem.
Does the .AppActivate use the name of the executibale or something else?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Im trying to open the "Scan" menu item, and then the "scan to File" item.
I just tried your suggestion, but nothing. I am noticing, however that after I close the scanning application, the ALT + F is being sent to IE and the IE File menu is appearing.
I just tried your suggestion, but nothing. I am noticing, however that after I close the scanning application, the ALT + F is being sent to IE and the IE File menu is appearing.
ASKER
Dave you were right,
when I took out the "true" it worked.
when I took out the "true" it worked.
I know this is old but you can also use "~" at the end of your string to ENTER
Example below is to run calc.exe as another user. Very useful if you need regular users to run applications that require admin rights.
Set oShell = WScript.CreateObject("WScr ipt.Shell" )
oShell.Run "C:\Windows\System32\RunAs .exe /user:card\someuser ""C:\Windows\System32\Calc .exe"
WScript.Sleep 1000
oShell.SendKeys "somepassword~"
Example below is to run calc.exe as another user. Very useful if you need regular users to run applications that require admin rights.
Set oShell = WScript.CreateObject("WScr
oShell.Run "C:\Windows\System32\RunAs
WScript.Sleep 1000
oShell.SendKeys "somepassword~"
cmdID = WshShell.run( "FImage.exe" ,3,true )
WSHShell.AppActivate( cmdID )
When you call ALT-S are you tring to open the file menu and save the file contents? If so, you might want to try:
wscript.sleep 200
wshshell.SendKeys "%f"
wscript.sleep 100
wshshell.SendKeys "s"
wscript.sleep 100
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "{ENTER}"
If that is not the case what does ALT-S do in your application?
Dave