當前位置: 首頁>>代碼示例>>Python>>正文


Python win32gui.SendMessage方法代碼示例

本文整理匯總了Python中win32gui.SendMessage方法的典型用法代碼示例。如果您正苦於以下問題:Python win32gui.SendMessage方法的具體用法?Python win32gui.SendMessage怎麽用?Python win32gui.SendMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在win32gui的用法示例。


在下文中一共展示了win32gui.SendMessage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: OnCommand

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def OnCommand(self, hwnd, msg, wparam, lparam):
        id = win32api.LOWORD(wparam)
        if id == IDC_BUTTON_SEARCH:
            self.ClearListItems()
            def fill_slowly(q, hwnd):
                import time
                for i in range(20):
                    q.put(("whatever", str(i+1), "Search result " + str(i) ))
                    win32gui.PostMessage(hwnd, WM_SEARCH_RESULT, 0, 0)
                    time.sleep(.25)
                win32gui.PostMessage(hwnd, WM_SEARCH_FINISHED, 0, 0)

            import threading
            self.result_queue = Queue.Queue()
            thread = threading.Thread(target = fill_slowly, args=(self.result_queue, self.hwnd) )
            thread.start()
        elif id == IDC_BUTTON_DISPLAY:
            print "Display button selected"
            sel = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETNEXTITEM, -1, commctrl.LVNI_SELECTED)
            print "The selected item is", sel+1

    # These function differ based on how the window is used, so may be overridden 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:24,代碼來源:win32gui_dialog.py

示例2: CreateViewWindow

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def CreateViewWindow(self, prev, settings, browser, rect):
        print "FileSystemView.CreateViewWindow", prev, settings, browser, rect
        self.cur_foldersettings = settings
        self.browser = browser
        self._CreateMainWindow(prev, settings, browser, rect)
        self._CreateChildWindow(prev)

        # This isn't part of the sample, but the most convenient place to
        # test/demonstrate how you can get an IShellBrowser from a HWND
        # (but ONLY when you are in the same process as the IShellBrowser!)
        # Obviously it is not necessary here - we already have the browser!
        browser_ad = win32gui.SendMessage(self.hwnd_parent, win32con.WM_USER+7, 0, 0)
        browser_ob = pythoncom.ObjectFromAddress(browser_ad, shell.IID_IShellBrowser)
        assert browser==browser_ob
        # and make a call on the object to prove it doesn't die :)
        assert browser.QueryActiveShellView()==browser_ob.QueryActiveShellView() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:18,代碼來源:shell_view.py

示例3: _DoSize

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def _DoSize(self, cx, cy, repaint = 1):
        # right-justify the textbox.
        ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SEARCHTEXT)
        l, t, r, b = win32gui.GetWindowRect(ctrl)
        l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
        r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
        win32gui.MoveWindow(ctrl, l, t, cx-l-5, b-t, repaint)
        # The button.
        ctrl = win32gui.GetDlgItem(self.hwnd, IDC_BUTTON_DISPLAY)
        l, t, r, b = win32gui.GetWindowRect(ctrl)
        l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
        r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
        list_y = b + 10
        w = r - l
        win32gui.MoveWindow(ctrl, cx - 5 - w, t, w, b-t, repaint)

        # The list control
        win32gui.MoveWindow(self.hwndList, 0, list_y, cx, cy-list_y, repaint)
        # The last column of the list control.
        new_width = cx - win32gui.SendMessage(self.hwndList, commctrl.LVM_GETCOLUMNWIDTH, 0)
        win32gui.SendMessage(self.hwndList, commctrl.LVM_SETCOLUMNWIDTH, 1, new_width) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:23,代碼來源:win32gui_dialog.py

示例4: sample_one_person

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def sample_one_person(n, num_x=5, num_y=5):
    save_path = 'D:/UnityEyes_Windows/imgs'
    if os.path.exists(save_path) == False:
        os.mkdir(save_path)

    # reset
    win32gui.SendMessage(handle, win32con.WM_ACTIVATE, win32con.WA_ACTIVE, 0)
    center_x = (clt_left + clt_right) // 2
    center_y = (clt_top + clt_bottom) // 2
    win32api.SetCursorPos([center_x, center_y])

    # press 'L'
    win32api.keybd_event(KEY_LIGHT, 0, 0, 0)  # key down
    time.sleep(1)
    win32api.keybd_event(KEY_LIGHT, 0, win32con.KEYEVENTF_KEYUP, 0)  # key up
    # press 'R'
    win32api.keybd_event(KEY_RANDOM, 0, 0, 0)  # key down
    time.sleep(1)
    win32api.keybd_event(KEY_RANDOM, 0, win32con.KEYEVENTF_KEYUP, 0)  # key up

    # number of points for vertical and horizontal
    # num_x, num_y = 5, 5

    step_x, step_y = width // (num_x + 1), height // (num_y + 1)
    for i in range(1, num_y+1):
        for j in range(1, num_x+1):
            x = clt_left + j * step_x
            y = clt_top + i * step_y
            print('{},{}'.format(x, y))
            win32api.mouse_event(win32con.MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0)
            win32api.SetCursorPos([x, y])
            win32api.mouse_event(win32con.MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0)
            time.sleep(0.5)
            win32api.keybd_event(KEY_SAVE, 0, 0, 0) # key down
            win32api.keybd_event(KEY_SAVE, 0, win32con.KEYEVENTF_KEYUP, 0)  # key up 
開發者ID:BlueWinters,項目名稱:DeepWarp,代碼行數:37,代碼來源:sampler.py

示例5: doubleClickStatic

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def doubleClickStatic(hwnd):
    '''Simulates a double mouse click on a static

    Parameters
    ----------
    hwnd
        Window handle of the required static.

    Usage example:  TODO
    '''
    _sendNotifyMessage(hwnd, win32con.STN_DBLCLK)


# def getEditText(hwnd):
#     bufLen = win32gui.SendMessage(hwnd, win32con.WM_GETTEXTLENGTH, 0, 0) + 1
#     print(bufLen)
#     buffer = win32gui.PyMakeBuffer(bufLen)
#     win32gui.SendMessage(hwnd, win32con.WM_GETTEXT, bufLen, buffer)
#
#     text = buffer[:bufLen]
#     return text 
開發者ID:ynzheng,項目名稱:pyautotrade_tdx,代碼行數:23,代碼來源:winguiauto.py

示例6: foreach_child

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def foreach_child(self):
        def callback(hwnd, window_hwnd):
            classname = win32gui.GetClassName(hwnd).lower()

            buffer_len = win32gui.SendMessage(hwnd, win32con.WM_GETTEXTLENGTH, 0, 0) + 1
            text = array('b', b'\x00\x00' * buffer_len)
            text_len = win32gui.SendMessage(hwnd, win32con.WM_GETTEXT, buffer_len, text)
            text = win32gui.PyGetString(text.buffer_info()[0], buffer_len - 1).lower()

            for match in self._windows[window_hwnd]['matches']:
                if match["text"] in text:
                    self._windows[window_hwnd]['to_click'].append(match["button"])

            if "button" in classname:
                self._windows[window_hwnd]['buttons'].append({
                    'text': text,
                    'handle': hwnd,
                })

            return True

        return callback 
開發者ID:certsocietegenerale,項目名稱:fame_modules,代碼行數:24,代碼來源:cutthecrap.py

示例7: mouse_drag_bg

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def mouse_drag_bg(self, pos1, pos2):
        """
        後台鼠標拖拽
            :param pos1: (x,y) 起點坐標
            :param pos2: (x,y) 終點坐標
        """
        if self.client == 0:
            move_x = np.linspace(pos1[0], pos2[0], num=20, endpoint=True)[0:]
            move_y = np.linspace(pos1[1], pos2[1], num=20, endpoint=True)[0:]
            win32gui.SendMessage(self.hwnd, win32con.WM_LBUTTONDOWN,
                                 0, win32api.MAKELONG(pos1[0], pos1[1]))
            for i in range(20):
                x = int(round(move_x[i]))
                y = int(round(move_y[i]))
                win32gui.SendMessage(
                    self.hwnd, win32con.WM_MOUSEMOVE, 0, win32api.MAKELONG(x, y))
                time.sleep(0.01)
            win32gui.SendMessage(self.hwnd, win32con.WM_LBUTTONUP,
                                 0, win32api.MAKELONG(pos2[0], pos2[1]))
        else:
            command = str(pos1[0])+' ' + str(pos1[1]) + \
                ' '+str(pos2[0])+' '+str(pos2[1])
            os.system('adb shell input swipe '+command) 
開發者ID:AcademicDog,項目名稱:onmyoji_bot,代碼行數:25,代碼來源:game_ctl.py

示例8: quit_game

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def quit_game(self):
        """
        退出遊戲
        """
        self.takescreenshot()  # 保存一下現場
        self.clean_mem()    # 清理內存
        if not self.run:
            return False
        if self.quit_game_enable:
            if self.client == 0:
                win32gui.SendMessage(
                    self.hwnd, win32con.WM_DESTROY, 0, 0)  # 退出遊戲
            else:
                os.system(
                    'adb shell am force-stop com.netease.onmyoji.netease_simulator')
        logging.info('退出,最後顯示已保存至/img/screenshots文件夾')
        sys.exit(0) 
開發者ID:AcademicDog,項目名稱:onmyoji_bot,代碼行數:19,代碼來源:game_ctl.py

示例9: doubleClickStatic

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def doubleClickStatic(hwnd):
    """Simulates a double mouse click on a static

    Parameters
    ----------
    hwnd
        Window handle of the required static.

    Usage example:  TODO
    """
    _sendNotifyMessage(hwnd, win32con.STN_DBLCLK)


# def getEditText(hwnd):
#     bufLen = win32gui.SendMessage(hwnd, win32con.WM_GETTEXTLENGTH, 0, 0) + 1
#     print(bufLen)
#     buffer = win32gui.PyMakeBuffer(bufLen)
#     win32gui.SendMessage(hwnd, win32con.WM_GETTEXT, bufLen, buffer)
#
#     text = buffer[:bufLen]
#     return text 
開發者ID:drongh,項目名稱:pyAutoTrading,代碼行數:23,代碼來源:winguiauto.py

示例10: Refresh

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def Refresh(self):
        stateMask = commctrl.LVIS_SELECTED | commctrl.LVIS_DROPHILITED
        state = 0
        self.children = []
        # Enumerate and store the child PIDLs
        for cid in self.folder.EnumObjects(self.hwnd, 0):
            self.children.append(cid)
            
        for row_index, data in enumerate(self.children):
            assert len(data)==1, "expecting just a child PIDL"
            typ, path = data[0].split('\0')
            desc = os.path.exists(path) and "Yes" or "No"
            prop_vals = (path, desc)
            # first col
            data, extras = win32gui_struct.PackLVITEM(
                                        item=row_index,
                                        subItem=0,
                                        text=prop_vals[0],
                                        state=state,
                                        stateMask=stateMask)
            win32gui.SendMessage(self.hwnd_child,
                                 commctrl.LVM_INSERTITEM,
                                 row_index, data)
            # rest of the cols.
            col_index = 1
            for prop_val in prop_vals[1:]:
                data, extras = win32gui_struct.PackLVITEM(
                                            item=row_index,
                                            subItem=col_index,
                                            text=prop_val)
    
                win32gui.SendMessage(self.hwnd_child,
                                     commctrl.LVM_SETITEM,
                                     0, data)
                col_index += 1 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:37,代碼來源:shell_view.py

示例11: _SendSci

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def _SendSci(self, msg, wparam=0, lparam=0):
        return win32gui.SendMessage(self.hwnd, msg, wparam, lparam)
   # IShellView 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:5,代碼來源:shell_view.py

示例12: _SetupList

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def _SetupList(self):
        child_style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_BORDER | win32con.WS_HSCROLL | win32con.WS_VSCROLL
        child_style |= commctrl.LVS_SINGLESEL | commctrl.LVS_SHOWSELALWAYS | commctrl.LVS_REPORT
        self.hwndList = win32gui.CreateWindow("SysListView32", None, child_style, 0, 0, 100, 100, self.hwnd, IDC_LISTBOX, self.hinst, None)

        child_ex_style = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
        child_ex_style |= commctrl.LVS_EX_FULLROWSELECT
        win32gui.SendMessage(self.hwndList, commctrl.LVM_SETEXTENDEDLISTVIEWSTYLE, 0, child_ex_style)

        # Add an image list - use the builtin shell folder icon - this
        # demonstrates the problem with alpha-blending of icons on XP if
        # winxpgui is not used in place of win32gui.
        il = win32gui.ImageList_Create(
                    win32api.GetSystemMetrics(win32con.SM_CXSMICON),
                    win32api.GetSystemMetrics(win32con.SM_CYSMICON),
                    commctrl.ILC_COLOR32 | commctrl.ILC_MASK,
                    1, # initial size
                    0) # cGrow

        shell_dll = os.path.join(win32api.GetSystemDirectory(), "shell32.dll")
        large, small = win32gui.ExtractIconEx(shell_dll, 4, 1)
        win32gui.ImageList_ReplaceIcon(il, -1, small[0])
        win32gui.DestroyIcon(small[0])
        win32gui.DestroyIcon(large[0])
        win32gui.SendMessage(self.hwndList, commctrl.LVM_SETIMAGELIST,
                             commctrl.LVSIL_SMALL, il)

        # Setup the list control columns.
        lvc = LVCOLUMN(mask = commctrl.LVCF_FMT | commctrl.LVCF_WIDTH | commctrl.LVCF_TEXT | commctrl.LVCF_SUBITEM)
        lvc.fmt = commctrl.LVCFMT_LEFT
        lvc.iSubItem = 1
        lvc.text = "Title"
        lvc.cx = 200
        win32gui.SendMessage(self.hwndList, commctrl.LVM_INSERTCOLUMN, 0, lvc.toparam())
        lvc.iSubItem = 0
        lvc.text = "Order"
        lvc.cx = 50
        win32gui.SendMessage(self.hwndList, commctrl.LVM_INSERTCOLUMN, 0, lvc.toparam())

        win32gui.UpdateWindow(self.hwnd) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:42,代碼來源:win32gui_dialog.py

示例13: ClearListItems

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def ClearListItems(self):
        win32gui.SendMessage(self.hwndList, commctrl.LVM_DELETEALLITEMS)
        self.list_data = {} 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:5,代碼來源:win32gui_dialog.py

示例14: AddListItem

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def AddListItem(self, data, *columns):
        num_items = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETITEMCOUNT)
        item = LVITEM(text=columns[0], iItem = num_items)
        new_index = win32gui.SendMessage(self.hwndList, commctrl.LVM_INSERTITEM, 0, item.toparam())
        col_no = 1
        for col in columns[1:]:
            item = LVITEM(text=col, iItem = new_index, iSubItem = col_no)
            win32gui.SendMessage(self.hwndList, commctrl.LVM_SETITEM, 0, item.toparam())
            col_no += 1
        self.list_data[new_index] = data 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:win32gui_dialog.py

示例15: AddButtons

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import SendMessage [as 別名]
def AddButtons(self,*buttons):
        tbbuttons = ''
        for button in buttons:
            tbbuttons += button.toparam()
        return win32gui.SendMessage(self.hwnd, commctrl.TB_ADDBUTTONS,
                                    len(buttons), tbbuttons) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:8,代碼來源:ietoolbar.py


注:本文中的win32gui.SendMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。