0

So I have a shortcut to a personal area network device when I right-click the icon the context menu comes up with an option "connect Using -> access point".

Context menu image
enter image description here

I want to be able to do this operation automatically. I know that a program like AutoHotkey could do this very easily but I will be doing this operation multiple times per minute and if it is possible to do this in a command prompt or using python it would make my life easier

Pawara Siriwardhane
  • 1,873
  • 10
  • 26
  • 38
  • Does this answer your question? [How to automate a GUI application's operation using python in GNU/Linux?](https://stackoverflow.com/questions/9932489/how-to-automate-a-gui-applications-operation-using-python-in-gnu-linux) – Raymond Chen Nov 11 '21 at 05:06
  • I'm looking for a solution for windows – fearless_z Nov 11 '21 at 05:27

1 Answers1

0

I have found a relatively non invasive method using pywinauto its not ideal for my application but it still works so I thought I would share

from pywinauto import Desktop, Application

Application().start('explorer.exe "path"')

app = Application(backend="uia").connect(path="explorer.exe", title="name1")
app2 = Desktop(backend='win32')                         #for sub actions only

app.folderName.set_focus()
common_files = app.folderName.ItemsView.get_item('fileName')
common_files.right_click_input()
app.ContextMenu.actionName.click_input()
app2.PopupMenu.menu_item('subActionName').click_input() #for sub actions only
app.window(title="name1").close()