0

My script runs a program that will eventually start an app that will prompt the user with a dialog box. I have a separate script that I can run using subprocess.call to hit the left arrow key and enter, but I need some way to make the script wait until the dialog box opens. Is there any way to make it wait until the box with a certain title prompts the user and then execute the script?

Essentially:

subprocess.Popen("java -jar file.jar", creationflags=subprocess.CREATE_NEW_CONSOLE, stdout=subprocess.PIPE)
#wait for dialog box of title "title"
subprocess.call("myscript.wsf")

Working in Windows 7. Thank you.

jfs
  • 399,953
  • 195
  • 994
  • 1,670
Kieran
  • 133
  • 2
  • 2
  • 12
  • @Vicyorus: it is not a duplicate if `java` opens the dialog and `myscript.wsf` closes it. – jfs Jul 14 '15 at 22:27
  • 1
    related: [Interact with other programs using Python](http://stackoverflow.com/q/14288177/4279). Additionally, [see my answer there](http://stackoverflow.com/a/14338006/4279) -- i.e., reconsider your approach to avoid driving a GUI program: pass command line parameters, write input via a pipe or use some other IPC methods instead. – jfs Jul 14 '15 at 22:29
  • @Kieran I misunderstood the question, so my answer may not be what you wanted, so let me see if I understood it right this time: You want to run a script that will interact with the Java program to automatically skip the dialog box when it appears. Is that correct? – Vicyorus Jul 14 '15 at 22:36
  • @Vicyorus: you should address this question to the OP (my answer: I believe it is correct). – jfs Jul 14 '15 at 22:37
  • @Vicyorus essentially yes. Not just skip the dialog box but specially choose an option using SendKeys (which the wsf does - inputs arrow key commands on the active window). – Kieran Jul 15 '15 at 14:50

0 Answers0