Search code examples
pywinauto

Clicking a control with modifier keys using pywinauto


I need to click a control using modifier keys like, SHIFT, CTRL and ALT, etc. So CTRL+ Left Click, or CTRL + SHIFT+ Left Click. I haven't found a way to do that. How would a I do that?


Solution

  • Mouse click with keyboard modifiers could be done using click_input() method.

    # Ctrl+Shift + left mouse click
    ui_ctrl.click_input(button='left', pressed='control shift')
    

    The docs for click_input missed this param values description (possible values are: "control", "shift", "alt" or combined by space in one string). Will update the docs soon.

    If you need these modifiers for method .type_keys() this is described in the keyboard module docs.