コード例 #1
0
	def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
		if lparam==win32con.WM_LBUTTONUP:
			print u"Tık"
			
		elif lparam==win32con.WM_LBUTTONDBLCLK:
                        global kaynak
			print u"Çift Tık"
			self.balonGoster(u"Güncelleniyor...",u"Döviz Kurları (" + kaynak + ")")
                        self.kurlariAl()
                        
			
			#win32gui.DestroyWindow(self.hwnd)

			
		elif lparam==win32con.WM_RBUTTONUP:
			print u"Sağ Tık"
			menu = win32gui.CreatePopupMenu()
			win32gui.AppendMenu( menu, win32con.MF_STRING|win32con.MF_DISABLED, 0, u"Kaynak Seçimi")
			win32gui.AppendMenu( menu, win32con.MF_STRING, 1021, u"T.C.M.B.")
			win32gui.AppendMenu( menu, win32con.MF_STRING, 1022, u"Enpara")
			win32gui.AppendMenu( menu, win32con.MF_STRING, 1023, u"Investing")
			win32gui.AppendMenu( menu, win32con.MF_SEPARATOR, 0, '')
			win32gui.AppendMenu( menu, win32con.MF_STRING, 1099, u"Çıkış" )
			pos = win32gui.GetCursorPos()
			win32gui.SetForegroundWindow(self.hwnd)
			win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None)
			win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
		return 1
コード例 #2
0
    def track(self, menudata, posx=0, posy=0):
        """
        @exception MenuTrackError Trackingをキャンセルしたor失敗した
        """
        menuhandle = menudata.get_menuhandle()
        contents = menudata.get_contents()

        # 自ウィンドウをアクティブにする.
        # これをしないとメニューを表示できなかったり,
        # 表示したメニューを閉じれなかったりするため.
        windowutil.ActivateWindow(self._hwnd)

        selected_id = win32gui.TrackPopupMenu(\
                                menuhandle,\
                                win32con.TPM_RETURNCMD, \
                                posx, \
                                posy, \
                                0, \
                                self._hwnd, \
                                None \
        )

        if selected_id==0:
            raise MenuTrackError(
                "Tracking was canceled or failed. " +
                "hwnd:" + str(self._hwnd) + " " +
                "GetLastError:" + str(win32api.GetLastError())
            )
        return contents[selected_id-1]
コード例 #3
0
 def show_menu(self):
     pos = win32gui.GetCursorPos()
     win32gui.SetForegroundWindow(self.hwnd)
     win32gui.TrackPopupMenu(self.menu, win32con.TPM_LEFTALIGN, pos[0],
                             pos[1], 0, self.hwnd, None)
     win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
     return
コード例 #4
0
 def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
     if lparam == win32con.WM_RBUTTONUP:
         menu = win32gui.CreatePopupMenu()
         win32gui.AppendMenu(menu, win32con.MF_STRING, SEARCH_MENU_ID,
                             "Search")
         win32gui.AppendMenu(menu, win32con.MF_STRING, PREFERENCES_MENU_ID,
                             "Preferences")
         win32gui.AppendMenu(menu, win32con.MF_STRING, HELP_MENU_ID, "Help")
         win32gui.AppendMenu(menu, win32con.MF_SEPARATOR, 1002, "")
         if maay.globalvars.indexer.isPaused():
             win32gui.AppendMenu(menu, win32con.MF_STRING,
                                 PAUSE_INDEXING_MENU_ID,
                                 "Pause indexing for 15 minutes more")
             win32gui.AppendMenu(menu, win32con.MF_STRING,
                                 RESUME_INDEXING_MENU_ID, "Resume indexing")
         else:
             win32gui.AppendMenu(menu, win32con.MF_STRING,
                                 PAUSE_INDEXING_MENU_ID, "Pause indexing")
         win32gui.AppendMenu(menu, win32con.MF_STRING, EXIT_MENU_ID, "Exit")
         win32gui.SetMenuDefaultItem(menu, SEARCH_MENU_ID, 0)
         pos = win32gui.GetCursorPos()
         # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
         win32gui.SetForegroundWindow(self.hwnd)
         win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0],
                                 pos[1], 0, self.hwnd, None)
         win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
     elif lparam == win32con.WM_LBUTTONDBLCLK:
         webbrowser.open("http://127.0.0.1:%d/maay/resultspool" %
                         maay.constants.MAAY_PORT,
                         autoraise=1)
     return 1
コード例 #5
0
 def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
     if lparam == win32con.WM_RBUTTONUP:
         menu = win32gui.CreatePopupMenu()
         win32gui.AppendMenu(menu, win32con.MF_STRING,
                             Win32MaayTaskbar.SEARCH_MENU_ID, "Search")
         win32gui.AppendMenu(menu, win32con.MF_STRING,
                             Win32MaayTaskbar.INDEXATION_MENU_ID,
                             "Manage Folders")
         win32gui.AppendMenu(menu, win32con.MF_SEPARATOR, 1002, "")
         win32gui.AppendMenu(menu, win32con.MF_STRING,
                             Win32MaayTaskbar.HOMEPAGE_MENU_ID,
                             "Maay Homepage")
         win32gui.SetMenuDefaultItem(menu, Win32MaayTaskbar.SEARCH_MENU_ID,
                                     0)
         pos = win32gui.GetCursorPos()
         # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
         win32gui.SetForegroundWindow(self.hwnd)
         win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0],
                                 pos[1], 0, self.hwnd, None)
         win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
     elif lparam == win32con.WM_LBUTTONDBLCLK:
         webbrowser.open("http://127.0.0.1:%s/" %
                         self.node.NODE_CONFIG.webserver_port,
                         autoraise=1)
     return 1
コード例 #6
0
 def show_menu(self):
     self.menu = win32gui.CreatePopupMenu()
     self.create_menu(self.menu, self.menu_options)
     pos = win32gui.GetCursorPos()
     win32gui.SetForegroundWindow(self.hwnd)
     win32gui.TrackPopupMenu(self.menu, win32con.TPM_LEFTALIGN, pos[0],
                             pos[1], 0, self.hwnd, None)
     win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
コード例 #7
0
 def show_menu(self):
     if self.MENU is None:
         self.create_menu()
     position = win32gui.GetCursorPos()
     win32gui.SetForegroundWindow(self.HWND)
     win32gui.TrackPopupMenu(self.MENU, win32con.TPM_LEFTALIGN, position[0],
                             position[1], 0, self.HWND, None)
     win32gui.PostMessage(self.HWND, win32con.WM_NULL, None, None)
コード例 #8
0
ファイル: win32_NotifyIcon.py プロジェクト: ilyapoz/Xpra
 def notify_callback(hwnd):
     menu = win32gui.CreatePopupMenu()
     win32gui.AppendMenu( menu, win32con.MF_STRING, 1024, "Generate balloon")
     win32gui.AppendMenu( menu, win32con.MF_STRING, 1025, "Exit")
     pos = win32api.GetCursorPos()
     win32gui.SetForegroundWindow(hwnd)
     win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, hwnd, None)
     win32api.PostMessage(hwnd, win32con.WM_NULL, 0, 0)
コード例 #9
0
 def show_menu(self):
     menu = win32gui.CreatePopupMenu()
     self.create_menu(menu, self.menu_options)
     pos = win32gui.GetCursorPos()
     # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
     win32gui.SetForegroundWindow(self.hwnd)
     win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1],
                             0, self.hwnd, None)
     win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
コード例 #10
0
    def RightMB(self):
        menu = win32gui.CreatePopupMenu()
        win32gui.AppendMenu(menu, win32con.MF_STRING, 1023, "Settings")
        win32gui.AppendMenu(menu, win32con.MF_STRING, 1024, "Exit program")

        pos = win32gui.GetCursorPos()
        # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
        win32gui.SetForegroundWindow(self.hwnd)
        win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1],
                                0, self.hwnd, None)
        win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
コード例 #11
0
def icon_wndproc(hwnd, msg, wp, lp):
    """Window proc for the tray icons"""
    if lp == win32con.WM_LBUTTONDOWN:
        ## popup menu won't disappear if you don't do this
        win32gui.SetForegroundWindow(hwnd)

        curr_desktop = win32service.OpenInputDesktop(0, True, win32con.MAXIMUM_ALLOWED)
        curr_desktop_name = win32service.GetUserObjectInformation(
            curr_desktop, win32con.UOI_NAME
        )
        winsta = win32service.GetProcessWindowStation()
        desktops = winsta.EnumDesktops()
        m = win32gui.CreatePopupMenu()
        desktop_cnt = len(desktops)
        ## *don't* create an item 0
        for d in range(1, desktop_cnt + 1):
            mf_flags = win32con.MF_STRING
            ## if you switch to winlogon yourself, there's nothing there and you're stuck
            if desktops[d - 1].lower() in ("winlogon", "disconnect"):
                mf_flags = mf_flags | win32con.MF_GRAYED | win32con.MF_DISABLED
            if desktops[d - 1] == curr_desktop_name:
                mf_flags = mf_flags | win32con.MF_CHECKED
            win32gui.AppendMenu(m, mf_flags, d, desktops[d - 1])
        win32gui.AppendMenu(m, win32con.MF_STRING, desktop_cnt + 1, "Create new ...")
        win32gui.AppendMenu(m, win32con.MF_STRING, desktop_cnt + 2, "Exit")

        x, y = win32gui.GetCursorPos()
        d = win32gui.TrackPopupMenu(
            m,
            win32con.TPM_LEFTBUTTON | win32con.TPM_RETURNCMD | win32con.TPM_NONOTIFY,
            x,
            y,
            0,
            hwnd,
            None,
        )
        win32gui.PumpWaitingMessages()
        win32gui.DestroyMenu(m)
        if d == desktop_cnt + 1:  ## Create new
            get_new_desktop_name(hwnd)
        elif d == desktop_cnt + 2:  ## Exit
            win32gui.PostQuitMessage(0)
            win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, window_info[hwnd])
            del window_info[hwnd]
            origin_desktop.SwitchDesktop()
        elif d > 0:
            hdesk = win32service.OpenDesktop(
                desktops[d - 1], 0, 0, win32con.MAXIMUM_ALLOWED
            )
            hdesk.SwitchDesktop()
        return 0
    else:
        return win32gui.DefWindowProc(hwnd, msg, wp, lp)
コード例 #12
0
ファイル: taskbar_widget.py プロジェクト: owenwaller/web2py
    def OnTaskbarNotify(
        self,
        hwnd,
        msg,
        wparam,
        lparam,
        ):
        if lparam == win32con.WM_LBUTTONUP:
            pass
        elif lparam == win32con.WM_LBUTTONDBLCLK:
            pass
        elif lparam == win32con.WM_RBUTTONUP:
            menu = win32gui.CreatePopupMenu()
            win32gui.AppendMenu(menu, win32con.MF_STRING, 1023,
                                'Toggle Display')
            win32gui.AppendMenu(menu, win32con.MF_SEPARATOR, 0, '')
            if self.serverState == self.EnumServerState.STOPPED:
                win32gui.AppendMenu(menu, win32con.MF_STRING, 1024,
                                    'Start Server')
                win32gui.AppendMenu(menu, win32con.MF_STRING
                                     | win32con.MF_GRAYED, 1025,
                                    'Restart Server')
                win32gui.AppendMenu(menu, win32con.MF_STRING
                                     | win32con.MF_GRAYED, 1026,
                                    'Stop Server')
            else:
                win32gui.AppendMenu(menu, win32con.MF_STRING
                                     | win32con.MF_GRAYED, 1024,
                                    'Start Server')
                win32gui.AppendMenu(menu, win32con.MF_STRING, 1025,
                                    'Restart Server')
                win32gui.AppendMenu(menu, win32con.MF_STRING, 1026,
                                    'Stop Server')
            win32gui.AppendMenu(menu, win32con.MF_SEPARATOR, 0, '')
            win32gui.AppendMenu(menu, win32con.MF_STRING, 1027,
                                'Quit (pid:%i)' % os.getpid())
            pos = win32gui.GetCursorPos()

            # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp

            win32gui.SetForegroundWindow(self.hwnd)
            win32gui.TrackPopupMenu(
                menu,
                win32con.TPM_LEFTALIGN,
                pos[0],
                pos[1],
                0,
                self.hwnd,
                None,
                )
            win32api.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
        return 1
コード例 #13
0
ファイル: taskbar.py プロジェクト: huap/agent_lrn
 def onRightClick(self):
     menu = win32gui.CreatePopupMenu()
     win32gui.AppendMenu(menu, win32con.MF_STRING,
                         WM_TASKBARNOTIFY_MENUITEM_SHOW, u'显示')
     win32gui.AppendMenu(menu, win32con.MF_STRING,
                         WM_TASKBARNOTIFY_MENUITEM_HIDE, u'隐藏')
     win32gui.AppendMenu(menu, win32con.MF_STRING,
                         WM_TASKBARNOTIFY_MENUITEM_EXIT, u'退出')
     pos = win32gui.GetCursorPos()
     win32gui.SetForegroundWindow(self.hwnd)
     win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1],
                             0, self.hwnd, None)
     win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
コード例 #14
0
 def on_taskbar_notify(self, hwnd, msg, wparam, lparam):
     if lparam == win32con.WM_LBUTTONDBLCLK:
         win32gui.DestroyWindow(self.hwnd)
     elif lparam == win32con.WM_RBUTTONUP:
         menu = win32gui.CreatePopupMenu()
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1024, "Show timer")
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1025, "Settings")
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1026, "Exit")
         pos = win32gui.GetCursorPos()
         win32gui.SetForegroundWindow(self.hwnd)
         win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0],
                                 pos[1], 0, self.hwnd, None)
         win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
     return 1
コード例 #15
0
    def show_menu(self):
        menu = win32gui.CreatePopupMenu()
        self.create_menu(menu, self.menu_options)
        # win32gui.SetMenuDefaultItem(menu, 1000, 0)

        try:
            pos = win32gui.GetCursorPos()
            # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
            win32gui.SetForegroundWindow(self.hwnd)
            win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None)
            win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
        except pywintypes.error:
            # Weird PyWin/win32gui bug, just ignore it for now
            pass
コード例 #16
0
 def _on_taskbar_notify(self, hwnd, msg, wparam, lparam):
     if lparam == win32con.WM_LBUTTONUP or lparam == win32con.WM_RBUTTONUP:
         log.error("You right clicked me.")
         menu = win32gui.CreatePopupMenu()
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1023,
                             "Display Dialog")
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1025, "Exit program")
         pos = win32gui.GetCursorPos()
         # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
         win32gui.SetForegroundWindow(self.hwnd)
         win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0],
                                 pos[1], 0, self.hwnd, None)
         win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
     return 1
コード例 #17
0
 def on_taskbar_notify(self, hwnd, msg, wparam, lparam):
     if lparam == win32con.WM_RBUTTONUP:
         menu = win32gui.CreatePopupMenu()
         win32gui.AppendMenu(menu,
                             self.menu_mindustry_flags[self.game_state],
                             1024, "Show Mindustry Game")
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1025,
                             "Exit Notifier")
         pos = win32gui.GetCursorPos()
         win32gui.SetForegroundWindow(self.hwnd)
         win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0],
                                 pos[1], 0, self.hwnd, None)
         win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
     return 1
コード例 #18
0
    def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
        if lparam == win32con.WM_LBUTTONUP:
            pass
        elif lparam == win32con.WM_LBUTTONDBLCLK:
            self.SwitchWindow()
            #win32gui.DestroyWindow(self.hwnd)
            #win32gui.UnregisterClass(self.wc.lpszClassName,None)
        elif lparam == win32con.WM_RBUTTONUP:
            pos = win32gui.GetCursorPos()
            # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
            win32gui.SetForegroundWindow(self.hwnd)

            win32gui.TrackPopupMenu(self.menu, win32con.TPM_LEFTALIGN, pos[0],
                                    pos[1], 0, self.hwnd, None)  #显示并获取选中的菜单
            win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)  #忽略当前事件消息
        return 1
コード例 #19
0
 def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
     if lparam == win32con.WM_RBUTTONUP:
         menu = win32gui.CreatePopupMenu()
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1024, "Show Log")
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1026, "About Us")
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1027, "Option")
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1028,
                             "Upload Offline")
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1025, "Exit program")
         pos = win32gui.GetCursorPos()
         # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
         win32gui.SetForegroundWindow(self.hwnd)
         win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0],
                                 pos[1], 0, self.hwnd, None)
         win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
     return 1
コード例 #20
0
ファイル: systemtray.py プロジェクト: youlive789/flip
 def _show_menu(self):
     self.FIRST_ID = 1023
     self.menu_options = (('종료', None, self.on_quit),)
     self._next_action_id = self.FIRST_ID
     self.menu_actions_by_id = set()
     self.menu_options = self._add_ids_to_menu_options(list(self.menu_options))
     self.menu_actions_by_id = dict(self.menu_actions_by_id)
     del self._next_action_id
     menu = win32gui.CreatePopupMenu()
     self.create_menu(menu, self.menu_options)
     
     pos = win32gui.GetCursorPos()
     win32gui.SetForegroundWindow(self.hwnd)
     win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN,
                             pos[0], pos[1], 0, self.hwnd, None)
     win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
コード例 #21
0
ファイル: trayicon.py プロジェクト: kaiCu/gbi-client
    def create_menu(self):
        menu = win32gui.CreatePopupMenu()
        item, extras = win32gui_struct.PackMENUITEMINFO(
            text = self.app_state.gettext('Close'),
            hbmpItem=win32con.HBMMENU_MBAR_CLOSE,
            wID=EXIT_COMMAND
        )
        win32gui.InsertMenuItem(
            menu,
            0,
            1,
            item
        )
        win32gui.SetMenuDefaultItem(
            menu,
            EXIT_COMMAND,
            0
        )
        item, extras = win32gui_struct.PackMENUITEMINFO(
            text = self.app_state.gettext('Open'),
            hbmpChecked = None,
            hbmpUnchecked = None,
            wID=OPEN_COMMAND
            )
        win32gui.InsertMenuItem(
            menu,
            0,
            1,
            item
        )

        win32gui.SetForegroundWindow(self.window_id)
        x, y = win32gui.GetCursorPos()
        win32gui.TrackPopupMenu(
            menu,
            win32con.TPM_LEFTALIGN,
            x, y,
            0,
            self.window_id,
            None
        )
        win32gui.PostMessage(
            self.window_id,
            win32con.WM_NULL,
            0,
            0
        )
コード例 #22
0
ファイル: __init__.py プロジェクト: vault-the/pyrexecd
 def _notify(klass, hwnd, msg, wparam, lparam):
     self = klass._instance[hwnd]
     if lparam == win32con.WM_LBUTTONDBLCLK:
         menu = self.get_popup()
         wid = win32gui.GetMenuDefaultItem(menu, 0, 0)
         if 0 < wid:
             win32gui.PostMessage(hwnd, win32con.WM_COMMAND, wid, 0)
     elif lparam == win32con.WM_RBUTTONUP:
         menu = self.get_popup()
         pos = win32gui.GetCursorPos()
         win32gui.SetForegroundWindow(hwnd)
         win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0],
                                 pos[1], 0, hwnd, None)
         win32gui.PostMessage(hwnd, win32con.WM_NULL, 0, 0)
     elif lparam == win32con.WM_LBUTTONUP:
         pass
     return True
コード例 #23
0
    def OnContextMenu(self, hwnd, msg, wparam, lparam):
        # Get the selected items.
        pidls = []
        n = -1
        while True:
            n = win32gui.SendMessage(self.hwnd_child,
                                     commctrl.LVM_GETNEXTITEM,
                                     n,
                                     commctrl.LVNI_SELECTED)
            if n == -1:
                break
            pidls.append(self.children[n][-1:])

        spt = win32api.GetCursorPos()
        if not pidls:
            print("Ignoring background click")
            return
        # Get the IContextMenu for the items.
        inout, cm = self.folder.GetUIObjectOf(
            self.hwnd_parent, pidls, shell.IID_IContextMenu, 0)
        hmenu = win32gui.CreatePopupMenu()
        sel = None
        # As per 'Q179911', we need to determine if the default operation
        # should be 'open' or 'explore'
        try:
            flags = 0
            try:
                self.browser.GetControlWindow(shellcon.FCW_TREE)
                flags |= shellcon.CMF_EXPLORE
            except pythoncom.com_error:
                pass
            id_cmd_first = 1  # TrackPopupMenu makes it hard to use 0
            cm.QueryContextMenu(hmenu, 0, id_cmd_first, -1, flags)
            tpm_flags = win32con.TPM_LEFTALIGN | win32con.TPM_RETURNCMD | \
                win32con.TPM_RIGHTBUTTON
            sel = win32gui.TrackPopupMenu(hmenu,
                                          tpm_flags,
                                          spt[0], spt[1],
                                          0, self.hwnd, None)
            print("TrackPopupMenu returned", sel)
        finally:
            win32gui.DestroyMenu(hmenu)
        if sel:
            ci = 0, self.hwnd_parent, sel - id_cmd_first, None, None, 0, 0, 0
            cm.InvokeCommand(ci)
コード例 #24
0
 def onRightClick(self):
     """Override in subclasses"""
     
     if(self.owner.watchState == True):
         statestr = u"停止"
     else:
         statestr = u"开始"
     
     menu = win32gui.CreatePopupMenu()   
     win32gui.AppendMenu( menu, win32con.MF_STRING, 1023, u"显示界面")
     win32gui.AppendMenu( menu, win32con.MF_STRING, 1024, statestr + u"监控")
     win32gui.AppendMenu( menu, win32con.MF_STRING, 1025, u"退出程序" )   
     pos = win32gui.GetCursorPos()   
     # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp   
     win32gui.SetForegroundWindow(self.hwnd)   
     win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None)   
     win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)   
     pass
コード例 #25
0
ファイル: record.py プロジェクト: songyuejs/AutomatorX
    def on_tray_notify(self, hwnd, msg, wp, lp):
        if lp == win32con.WM_LBUTTONUP:
            # print "left click"
            # win32gui.SetForegroundWindow(self.hwnd)
            pass
        elif lp == win32con.WM_RBUTTONUP:
            # print "right click"
            menu = win32gui.CreatePopupMenu()
            for cid in sorted(self.commands.keys(), reverse=True):
                name, _ = self.commands[cid]
                win32gui.AppendMenu(menu, win32con.MF_STRING, cid, name)

            pos = win32gui.GetCursorPos()
            win32gui.SetForegroundWindow(self.hwnd)
            win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0],
                                    pos[1], 0, self.hwnd, None)
            win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
        return True
コード例 #26
0
 def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
     if lparam==win32con.WM_LBUTTONUP:
         print "You clicked me."
     elif lparam==win32con.WM_LBUTTONDBLCLK:
         print "You double-clicked me - goodbye"
         win32gui.DestroyWindow(self.hwnd)
     elif lparam==win32con.WM_RBUTTONUP:
         print "You right clicked me."
         menu = win32gui.CreatePopupMenu()
         win32gui.AppendMenu( menu, win32con.MF_STRING, 1023, "Display Dialog")
         win32gui.AppendMenu( menu, win32con.MF_STRING, 1024, "Say Hello")
         win32gui.AppendMenu( menu, win32con.MF_STRING, 1025, "Exit program" )
         pos = win32gui.GetCursorPos()
         # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
         win32gui.SetForegroundWindow(self.hwnd)
         win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None)
         win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
     return 1
コード例 #27
0
 def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
     if lparam == win32con.WM_LBUTTONUP:
         print "You clicked me."
     elif lparam == win32con.WM_LBUTTONDBLCLK:
         print "You double-clicked me - goodbye"
         win32gui.DestroyWindow(self.hwnd)
     elif lparam == win32con.WM_RBUTTONUP:
         print "You right clicked me."
         menu = win32gui.CreatePopupMenu()
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1023, gbk("切换帐号"))
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1024, gbk("切换帐号"))
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1025, gbk("断开连接"))
         win32gui.AppendMenu(menu, win32con.MF_STRING, 1026, gbk("退出服务"))
         pos = win32gui.GetCursorPos()
         win32gui.SetForegroundWindow(self.hwnd)
         win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0],
                                 pos[1], 0, self.hwnd, None)
         win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
     return 1
コード例 #28
0
 def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
     if lparam==win32con.WM_LBUTTONUP:
         pass
     elif lparam==win32con.WM_LBUTTONDBLCLK:
         win32gui.DestroyWindow(self.hwnd)
     elif lparam==win32con.WM_RBUTTONUP:
         menu = win32gui.CreatePopupMenu()
         win32gui.AppendMenu( menu, win32con.MF_GRAYED | win32con.MF_STRING, TrayThermostat.Connected, "Connected" if self.__connected else "Disconnected")
         win32gui.AppendMenu( menu, self.__flag_set(TrayThermostat.Automatic), TrayThermostat.Automatic, "Automatic")
         win32gui.AppendMenu( menu, self.__flag_set(TrayThermostat.V12), TrayThermostat.V12, "12V")
         win32gui.AppendMenu( menu, self.__flag_set(TrayThermostat.V5), TrayThermostat.V5, "5V" )
         win32gui.AppendMenu( menu, self.__flag_set(TrayThermostat.V0), TrayThermostat.V0, "Off" )
         win32gui.AppendMenu( menu, win32con.MF_STRING, TrayThermostat.Exit, "Exit" )
         pos = win32gui.GetCursorPos()
         # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
         win32gui.SetForegroundWindow(self.hwnd)
         win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None)
         win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
     return 1
コード例 #29
0
    def show_menu(self):

        if DEBUG: print(sys._getframe(0).f_code.co_name)

        menu = win32gui.CreatePopupMenu()
        self.create_menu(menu, self.menu_options)
        #win32gui.SetMenuDefaultItem(menu, 1000, 0)
        
        pos = win32gui.GetCursorPos()
        # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
        win32gui.SetForegroundWindow(self.hwnd)
        win32gui.TrackPopupMenu(menu,
                                win32con.TPM_LEFTALIGN,
                                pos[0],
                                pos[1],
                                0,
                                self.hwnd,
                                None)
        win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
コード例 #30
0
 def PopupMenu(self, menu):
     if self.in_popup:
         return
     self.in_popup = True
     self.menu = menu
     try:
         pos = win32gui.GetCursorPos()
         # See remarks section under
         # https://msdn.microsoft.com/en-us/library/windows/desktop/ms648002(v=vs.85).aspx
         try:
             win32gui.SetForegroundWindow(self.hwnd)
         except win32gui.error:
             # Calls to SetForegroundWindow will fail if (e.g.) the Win10
             # start menu is currently shown
             pass
         win32gui.TrackPopupMenu(menu.hmenu, win32con.TPM_RIGHTBUTTON,
                                 pos[0], pos[1], 0, self.hwnd, None)
         win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
     finally:
         self.in_popup = False