Waiting until the window is activated
I have following code that sets off a timer periodically and click "OK" a button. At the moment, I'm seeing two issues.
1) mouse moves on to the "OK" button (since there is no mouse move commands, it must be executing the mouse click), but the "OK" button does not get clicked. (Wait for the button object can see the "OK" button).
2) After missed button click, I see message saying "Waiting until the window is activated" and id doesnt go away. (Without the timer, "OK" button click works fine). It looks as if control doesnt get returned to the main for loop after handleRestartDeviceCautionForm() gets executed.
During the time handleRestartDeviceCautionForm() executes, I need rest of the code to pause, because this "Restart Device Form" blocks all the functionality in the application. This is being run on Win7 with Python 3.4.3. Can anyone show me how to over come this issue?
Below is the code:
#Main func cancel_future_calls = call_repeatedly(60, handleRestartDeviceCautionForm) for i in range(120): Delay(1000) cancel_future_calls() # stop future calls #Timer code from threading import Timer import threading from threading import Event, Thread def call_repeatedly(interval, func, *args): stopped = Event() def loop(): while not stopped.wait(interval): # the first call is in `interval` secs func(*args) Thread(target=loop).start() return stopped.set #Code that handles ok button def handleRestartDeviceCautionForm(): Tgence = ConfigTool() if Tgence.getzremindBtn().Exists: Tgence.getzremindBtn().ClickButton() Delay(100)