Python programming - Windows focus and program process

Posted by Zack on Stack Overflow See other posts from Stack Overflow or by Zack
Published on 2011-01-02T04:25:15Z Indexed on 2011/01/02 16:54 UTC
Read the original article Hit count: 189

Filed under:

I'm working on a python program that will automatically combine sets of files based on their names.

Being a newbie, I wasn't quite sure how to go about it, so I decided to just brute force it with the win32api.

So I'm attempting to do everything with virtual keys. So I run the script, it selects the top file (after arranging the by name), then sends a right click command,selects 'combine as adobe PDF', and then have it push enter. This launched the Acrobat combine window, where I send another 'enter' command. The here's where I hit the problem.

  1. The folder where I'm converting these things loses focus and I'm unsure how to get it back. Sending alt+tab commands seems somewhat unreliable. It sometimes switches to the wrong thing.

  2. A much bigger issue for me.. Different combination of files take different times to combine. though I haven't gotten this far in my code, my plan was to set some arbitrarily long time.sleep() command before it finally sent the last "enter" command to finish and confirm the file name completing the combination process. Is there a way to monitor another programs progress? Is there a way to have python not execute anymore code until something else has finished?

© Stack Overflow or respective owner

Related posts about python