Last active
August 29, 2015 13:56
-
-
Save saltlakeryan/9043315 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pywinauto import application, timings | |
import subprocess, pywinauto, time | |
def activation_window(app): | |
actwin = repeated_check(app, 'Dragon NaturallySpeaking 12.0 Activation') | |
actwinbutton = repeated_check(actwin, 'Activate Later') | |
repeated_check_generic(actwinbutton, 'Activate Later', button_ready) | |
return actwin | |
def profile_window(app): | |
win = repeated_check(app, 'Open User Profile') | |
winbutton = repeated_check(win, 'Open') | |
repeated_check_generic(winbutton, 'Open', button_ready) | |
return win | |
def update_window(app): | |
win = repeated_check_generic('unused', 'unused', update_window_ready) | |
return win | |
def update_window_ready(unusedvar1, unusedvar2): | |
window_handle = pywinauto.findwindows.find_window(title_re=".*Software Manager") | |
app = pywinauto.application.Application() | |
window = app.window_(handle = window_handle) | |
return window | |
def button_ready(button, name): | |
return button.VerifyEnabled() | |
def repeated_check(app, dialogname): | |
return repeated_check_generic(app, dialogname, check_for_dialog) | |
def repeated_check_generic(dlg, name, callback): | |
return timings.WaitUntilPasses(120, 0.5, callback, (pywinauto.findwindows.WindowNotFoundError, pywinauto.findbestmatch.MatchError, pywinauto.controls.HwndWrapper.ControlNotEnabled), dlg, name) | |
def check_for_dialog(app, dialogname): | |
print "check for dialog called: ", dialogname | |
print "app: ", app | |
return app[dialogname] | |
def check_button(app, buttonname): | |
return app[buttonname].VerifyEnabled() | |
def start_dragon(): | |
subprocess.call(["net", "use", "y:", "\\\\vboxsrv\\dragon"]) | |
app = application.Application() | |
app.start_('C:\\Program Files\\Nuance\\NaturallySpeaking12\\Program\\natspeak.exe') | |
activation = activation_window(app) | |
activation['Activate Later'].Click() | |
profile = profile_window(app) | |
profile['Open'].Click() | |
update = update_window(app) | |
update.Close() | |
start_dragon() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment