Python: 'Right click' a file in File Explorer to bring up context menu and 'left click' an option from that menu

╄→гoц情女王★ 提交于 2019-12-11 16:03:24

问题


My goal is to be able to 'right click' a file in file explorer, bring up the context menu and 'left click' to select an option from that menu.

My, so far unsuccessful idea, has been to use os.system to get into command prompt

from os import system

system(r'cd C:\Users\UserName\Documents && RIGHT CLICK SOME DOCUMENT AND SELECT AN OPTION')

But my idea falls short after the && in the above raw string. Where usually just putting a filename e.g. 'doc.txt' after the && would left click and open the file, I want to right click.

I realise that my solution so far is not strictly python related but an issue with the command line.

However I'm very open to and would be very appreciative of pointers towards a python module that might help.

(I'm talking about Windows 10 command line here)

Thanks!

来源:https://stackoverflow.com/questions/49673685/python-right-click-a-file-in-file-explorer-to-bring-up-context-menu-and-left

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!