Search code examples
python-3.xscriptingpywinauto

How to select menu option after right clicking on folder executing python script in windows?


import pywinauto

pywinauto.Application().Start(r'explorer.exe')

Solution

  • A great tool that I use while doing stuff is inspect.exe (built in windows tool). If you look at the menu whilst using this tool, you can often see that that menu is technically part of the desktop (not part of the application). The way that I get to those items is:

        import pywinauto
    
        desk = pywinauto.Desktop()
        desk.Menu.child_window(title="Cut", control_type="MenuItem").click_input()
    

    It's the same with all of the menu items just replace the title with which command you want cut, copy, rename, paste, etc.