pywinauto.timings

Timing settings for all of pywinauto

This module has one object that should be used for all timing adjustments
timings.Timings

There are a couple of predefined settings

timings.Timings.Fast() timings.Timings.Defaults() timings.Timings.Slow()

The Following are the individual timing settings that can be adjusted:

  • window_find_timeout (default 5)
  • window_find_retry (default .09)
  • app_start_timeout (default 10)
  • app_start_retry (default .90)
  • cpu_usage_interval (default .5)
  • cpu_usage_wait_timeout (default 20)
  • exists_timeout (default .5)
  • exists_retry (default .3)
  • after_click_wait (default .09)
  • after_clickinput_wait (default .09)
  • after_menu_wait (default .1)
  • after_sendkeys_key_wait (default .01)
  • after_button_click_wait (default 0)
  • before_closeclick_wait (default .1)
  • closeclick_retry (default .05)
  • closeclick_dialog_close_wait (default 2)
  • after_closeclick_wait (default .2)
  • after_windowclose_timeout (default 2)
  • after_windowclose_retry (default .5)
  • after_setfocus_wait (default .06)
  • setfocus_timeout (default 2)
  • setfocus_retry (default .1)
  • after_setcursorpos_wait (default .01)
  • sendmessagetimeout_timeout (default .01)
  • after_tabselect_wait (default .05)
  • after_listviewselect_wait (default .01)
  • after_listviewcheck_wait default(.001)
  • after_treeviewselect_wait default(.1)
  • after_toobarpressbutton_wait default(.01)
  • after_updownchange_wait default(.1)
  • after_movewindow_wait default(0)
  • after_buttoncheck_wait default(0)
  • after_comboboxselect_wait default(.001)
  • after_listboxselect_wait default(0)
  • after_listboxfocuschange_wait default(0)
  • after_editsetedittext_wait default(0)
  • after_editselect_wait default(.02)
  • drag_n_drop_move_mouse_wait default(.1)
  • before_drag_wait default(.2)
  • before_drop_wait default(.1)
  • after_drag_n_drop_wait default(.1)
  • scroll_step_wait default(.1)
class pywinauto.timings.TimeConfig

Central storage and manipulation of timing values

Defaults()

Set all timings to the default time

Fast()

Set fast timing values

Currently this changes the timing in the following ways: timeouts = 1 second waits = 0 seconds retries = .001 seconds (minimum!)

(if existing times are faster then keep existing times)

Slow()

Set slow timing values

Currently this changes the timing in the following ways: timeouts = default timeouts * 10 waits = default waits * 3 retries = default retries * 3

(if existing times are slower then keep existing times)

exception pywinauto.timings.TimeoutError
pywinauto.timings.WaitUntil(timeout, retry_interval, func, value=True, op=<built-in function eq>, *args)

Wait until op(function(*args), value) is True or until timeout expires

  • timeout how long the function will try the function
  • retry_interval how long to wait between retries
  • func the function that will be executed
  • value the value to be compared against (defaults to True)
  • op the comparison function (defaults to equality)
  • args optional arguments to be passed to func when called

Returns the return value of the function If the operation times out then the return value of the the function is in the ‘function_value’ attribute of the raised exception.

e.g.

try:
    # wait a maximum of 10.5 seconds for the
    # the objects item_count() method to return 10
    # in increments of .5 of a second
    wait_until(10.5, .5, self.item_count, 10)
except TimeoutError as e:
    print("timed out")
pywinauto.timings.WaitUntilPasses(timeout, retry_interval, func, exceptions=<class 'Exception'>, *args)

Wait until func(*args) does not raise one of the exceptions in exceptions

  • timeout how long the function will try the function
  • retry_interval how long to wait between retries
  • func the function that will be executed
  • exceptions list of exceptions to test against (default: Exception)
  • args optional arguments to be passed to func when called

Returns the return value of the function If the operation times out then the original exception raised is in the ‘original_exception’ attribute of the raised exception.

e.g.

try:
    # wait a maximum of 10.5 seconds for the
    # window to be found in increments of .5 of a second.
    # P.int a message and re-raise the original exception if never found.
    wait_until_passes(10.5, .5, self.Exists, (ElementNotFoundError))
except TimeoutError as e:
    print("timed out")
    raise e.
pywinauto.timings.always_wait_until(timeout, retry_interval, value=True, op=<built-in function eq>)

Decorator to call wait_until(...) every time for a decorated function/method

pywinauto.timings.always_wait_until_passes(timeout, retry_interval, exceptions=<class 'Exception'>)

Decorator to call wait_until_passes(...) every time for a decorated function/method

pywinauto.timings.timestamp()

Get a precise timestamp

pywinauto.timings.wait_until(timeout, retry_interval, func, value=True, op=<built-in function eq>, *args)

Wait until op(function(*args), value) is True or until timeout expires

  • timeout how long the function will try the function
  • retry_interval how long to wait between retries
  • func the function that will be executed
  • value the value to be compared against (defaults to True)
  • op the comparison function (defaults to equality)
  • args optional arguments to be passed to func when called

Returns the return value of the function If the operation times out then the return value of the the function is in the ‘function_value’ attribute of the raised exception.

e.g.

try:
    # wait a maximum of 10.5 seconds for the
    # the objects item_count() method to return 10
    # in increments of .5 of a second
    wait_until(10.5, .5, self.item_count, 10)
except TimeoutError as e:
    print("timed out")
pywinauto.timings.wait_until_passes(timeout, retry_interval, func, exceptions=<class 'Exception'>, *args)

Wait until func(*args) does not raise one of the exceptions in exceptions

  • timeout how long the function will try the function
  • retry_interval how long to wait between retries
  • func the function that will be executed
  • exceptions list of exceptions to test against (default: Exception)
  • args optional arguments to be passed to func when called

Returns the return value of the function If the operation times out then the original exception raised is in the ‘original_exception’ attribute of the raised exception.

e.g.

try:
    # wait a maximum of 10.5 seconds for the
    # window to be found in increments of .5 of a second.
    # P.int a message and re-raise the original exception if never found.
    wait_until_passes(10.5, .5, self.Exists, (ElementNotFoundError))
except TimeoutError as e:
    print("timed out")
    raise e.