示例#1
0
 def click_callback(button, pressed):
     menu = CreatePopupMenu()
     AppendMenu(menu, win32con.MF_STRING, 1024, u"Generate balloon")
     AppendMenu(menu, win32con.MF_STRING, 1025, u"Exit")
     pos = POINT()
     GetCursorPos(byref(pos))
     hwnd = tray.hwnd
     user32.SetForegroundWindow(hwnd)
     user32.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos.x, pos.y, 0, hwnd, None)
     PostMessageA(hwnd, win32con.WM_NULL, 0, 0)
示例#2
0
 def click_callback(button, pressed):
     CreatePopupMenu = user32.CreatePopupMenu
     CreatePopupMenu.restype = ctypes.wintypes.HMENU
     CreatePopupMenu.argtypes = []
     AppendMenu = user32.AppendMenuW
     AppendMenu.restype = ctypes.wintypes.BOOL
     AppendMenu.argtypes = [
         ctypes.wintypes.HMENU, ctypes.wintypes.UINT, ctypes.wintypes.UINT,
         ctypes.wintypes.LPCWSTR
     ]
     menu = CreatePopupMenu()
     AppendMenu(menu, win32con.MF_STRING, 1024, u"Generate balloon")
     AppendMenu(menu, win32con.MF_STRING, 1025, u"Exit")
     pos = POINT()
     GetCursorPos(byref(pos))
     hwnd = tray.hwnd
     user32.SetForegroundWindow(hwnd)
     user32.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos.x, pos.y, 0,
                           hwnd, None)
     PostMessageA(hwnd, win32con.WM_NULL, 0, 0)