[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • Last Modified:

VBScript does not get program to go ahead and execute

After launching a Windows application (under Vista Business)  with a VBS script, I need to select a few menu options, then activate the software.  Subject package is an OCR app, and I need to select a prepositioned configuration file from a pull down menu which offers multiple configurations I have defined.  The following script is same as keystrokes that work when I do this manually from the KB, but under script control it seems to correctly configure but not start operating.  Doing it manually, the engine starts as soon as the menu selectionj is made; no 'enter' required.  I can see by maximizing the window that the correct configuration was selected.  No idea why script would be different from manual.  I have tried with and without 'enter'.  {DOWN} is the step that selects the menu option.


Meanwhile, Sendkeys isn't totally working. I can do the following just fine with the KB:
objWshShell.SendKeys "{^}T"     'pull down menu
WScript.Sleep 1000
objWshShell.SendKeys "{DOWN}"      ' select next item on the list
WScript.Sleep 5000
objWshShell.SendKeys "~"     ' try to get it to go

Have tried {ENTER} and "~" both; no difference
0
Mike Caldwell
Asked:
Mike Caldwell
  • 5
  • 4
1 Solution
 
Mark_FreeSoftwareCommented:

is the window focused properly?
0
 
Mike CaldwellDirector of Business Development, AnaquaAuthor Commented:
Seems to be.  It is opened using a VBS script.  App pops up, is on top of the desktop, and nothing else is running.  How can I force focus?
0
 
Mike CaldwellDirector of Business Development, AnaquaAuthor Commented:
Maybe not.  Just did an experiment by manually opening, selecting a different configuration, then just closing.  Manually opening again, it comes up with the last configuration selected.  Then opening with the VBS the configuration selection does not change.  So, looks like none of the Sendkeys is effective.  So you're probably right; doesn't have focus.  How to switch?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Mike CaldwellDirector of Business Development, AnaquaAuthor Commented:
Tried:
Set objWshShell = WScript.CreateObject("WScript.Shell")
objwshShell.AppActivate "FineReader.exe"

But no difference.  I note that when I run the script and the program launches that the 'tab' corresonding to the program (tool bar across the bottom; Vista) is "indented", which should indicate that it has focus.
0
 
Mark_FreeSoftwareCommented:
and sending the input to another program does work in that program?

for instance, try controlling notepad, as it is a really simple program
0
 
Mike CaldwellDirector of Business Development, AnaquaAuthor Commented:
Well, it opens, but the Sendkeys goes to the text area, not controlling the app.  So maybe my real problem is the code itself.  Did this
objWshShell.Run "notepad", 1
WScript.Sleep 500
objWshShell.SendKeys "{%}F"
WScript.Sleep 100
objWshShell.SendKeys "{DOWN}"

and it types "%F" into the text area instead of pulling down the alt+F menu list.

0
 
Mark_FreeSoftwareCommented:

try this instead:

Set objWshShell = WScript.CreateObject("WScript.Shell")
objWshShell.Run "notepad", 1
WScript.Sleep 500
objWshShell.SendKeys "%(F)"
WScript.Sleep 100
objWshShell.SendKeys "{DOWN}"



and thats the same error as in the first one,
change this
objWshShell.SendKeys "{^}T"
to this
objWshShell.SendKeys "^(T)"

(normal braces, and around the key itself isntead of around the special operator)
0
 
Mike CaldwellDirector of Business Development, AnaquaAuthor Commented:
Yepl, that was it Guru.  I got my "directions" from uSoft at MSDN.  Guess that is for another version or I just didn't understand.  This is a complete cure; all is now well.  Thanks very much.

PS: if you have the time, take a look at my other open question regarding how to close a specific instance of the same program open twice.

Mike
0
 
Mark_FreeSoftwareCommented:

thanks for the A grade!

as for this error:
i should have seen it earlier :(
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now