winforms 从MenuStrip控件单击选项(托盘通知图标)

i86rm4rw  于 2023-10-23  发布在  其他
关注(0)|答案(1)|浏览(148)

我想做一些像:

这段代码打开托盘通知图标窗口:

  1. Dim Shell_TrayWnd As IntPtr = FindWindow("Shell_TrayWnd", "")
  2. Dim TrayNotifyWnd As IntPtr = FindWindowEx(Shell_TrayWnd, 0, "TrayNotifyWnd", "")
  3. Dim TrayNotifyButtonWnd As IntPtr = FindWindowEx(TrayNotifyWnd, 0, "Button", "")
  4. Dim BM_CLICK As Integer = &HF5
  5. SendMessage(TrayNotifyButtonWnd, BM_CLICK, 0, 0)

现在我想做的是:

  1. RightMouseClick(SkypetrayIcon)
  2. ClickOnOption(SkypetrayIconMenuHandle,0)

我怎么能做这种事呢?也许有另一种方法(更简单的方法)

xwbd5t1u

xwbd5t1u1#

是的,可以使用“pywinauto”模块python

  1. from pywinauto import Application
  2. desktop = Application(backend="uia").connect(class_name="Shell_TrayWnd")
  3. sys_tray = desktop.window(class_name="Shell_TrayWnd")
  4. taskbar = desktop.taskbar
  5. icon_tray = taskbar.child_window(title="Right-click for context menu") # this is your "click me"
  6. icon_tray.click_input(button="right")

相关问题