Working on the Python-powered automation tool.
Imagine there is a pool of apps running:
APPS_POOL = ['Chrome', 'SomeApp', 'Foo']
The script runs in the loop (every second) and needs to switch randomly between them:
# Init App object
app = application.Application()
# Select random app from the pull of apps
random_app = random.choice(APPS_POOL)
app.connect(title_re=".*%s" % random_app)
print 'Select "%s"' % random_app
# Access app's window object
app_dialog = app.window_(title_re=".*%s.*" % random_app)
if app_dialog.Exists():
app_dialog.SetFocus()
The first time it works fine, but every other - the window would not be brought into foreground. Any ideas?
EDIT: the script is ran from Win7 CMD. Is it possible the system "blocks" CMD from setting focus somehow, once focus is set to other window?