Python win32gui 模块,SendMessage() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用win32gui.SendMessage()

项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def __init__(self,hwndparent):
        styles = win32con.WS_CHILD \
                | win32con.WS_VISIBLE \
                | win32con.WS_CLIPSIBLINGS \
                | win32con.WS_CLIPCHILDREN \
                | commctrl.TBSTYLE_LIST \
                | commctrl.TBSTYLE_FLAT \
                | commctrl.TBSTYLE_TRANSPARENT \
                | commctrl.CCS_TOP \
                | commctrl.CCS_NODIVIDER \
                | commctrl.CCS_NORESIZE \
                | commctrl.CCS_NOPARENTALIGN
        self.hwnd = win32gui.CreateWindow('ToolbarWindow32', None, styles,
                                          0, 0, 100, 100,
                                          hwndparent, 0, win32gui.dllhandle,
                                          None)
        win32gui.SendMessage(self.hwnd, commctrl.TB_BUTTONSTRUCTSIZE, 20, 0)
项目:tdx    作者:sqltxt    | 项目源码 | 文件源码
def Stock_option(Index):
    try:
        #tjxg = win32gui.FindWindow('#32770','????')
        gs = win32gui.FindWindowEx(win32gui.FindWindow('#32770','????'),None,'ComboBox',None)
        #time.sleep(1)
        print(hex(gs))
        win32gui.SendMessage(gs,win32con.CB_SHOWDROPDOWN,1,0)  #??ComboBox???
        time.sleep(1)
        win32gui.SendMessage(gs,win32con.CB_SETCURSEL,Index,0)#???????
        time.sleep(1)
        win32gui.SendMessage(gs,win32con.WM_SETFOCUS,0,0)#????
        time.sleep(1)
        win32gui.SendMessage(gs,win32con.WM_KEYDOWN,0,0)#???????
        time.sleep(1)
        win32gui.SendMessage(gs,win32con.WM_KEYUP,0,0) 
        time.sleep(1)
    except Exception as e:
        ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))
#????
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def main():
    try:
        path = r'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
        reg = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
        key = OpenKey(reg, path, 0, KEY_ALL_ACCESS)

        if len(sys.argv) == 1:
            show(key)
        else:
            name, value = sys.argv[1].split('=')
            if name.upper() == 'PATH':
                value = queryValue(key, name) + ';' + value
            if value:
                SetValueEx(key, name, 0, REG_EXPAND_SZ, value)
            else:
                DeleteValue(key, name)

        win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SETTINGCHANGE, 0, 'Environment')

    except Exception, e:
        print e

    CloseKey(key)    
    CloseKey(reg)
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
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()
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def __init__(self,hwndparent):
        styles = win32con.WS_CHILD \
                | win32con.WS_VISIBLE \
                | win32con.WS_CLIPSIBLINGS \
                | win32con.WS_CLIPCHILDREN \
                | commctrl.TBSTYLE_LIST \
                | commctrl.TBSTYLE_FLAT \
                | commctrl.TBSTYLE_TRANSPARENT \
                | commctrl.CCS_TOP \
                | commctrl.CCS_NODIVIDER \
                | commctrl.CCS_NORESIZE \
                | commctrl.CCS_NOPARENTALIGN
        self.hwnd = win32gui.CreateWindow('ToolbarWindow32', None, styles,
                                          0, 0, 100, 100,
                                          hwndparent, 0, win32gui.dllhandle,
                                          None)
        win32gui.SendMessage(self.hwnd, commctrl.TB_BUTTONSTRUCTSIZE, 20, 0)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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()
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def __init__(self,hwndparent):
        styles = win32con.WS_CHILD \
                | win32con.WS_VISIBLE \
                | win32con.WS_CLIPSIBLINGS \
                | win32con.WS_CLIPCHILDREN \
                | commctrl.TBSTYLE_LIST \
                | commctrl.TBSTYLE_FLAT \
                | commctrl.TBSTYLE_TRANSPARENT \
                | commctrl.CCS_TOP \
                | commctrl.CCS_NODIVIDER \
                | commctrl.CCS_NORESIZE \
                | commctrl.CCS_NOPARENTALIGN
        self.hwnd = win32gui.CreateWindow('ToolbarWindow32', None, styles,
                                          0, 0, 100, 100,
                                          hwndparent, 0, win32gui.dllhandle,
                                          None)
        win32gui.SendMessage(self.hwnd, commctrl.TB_BUTTONSTRUCTSIZE, 20, 0)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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()
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def __init__(self,hwndparent):
        styles = win32con.WS_CHILD \
                | win32con.WS_VISIBLE \
                | win32con.WS_CLIPSIBLINGS \
                | win32con.WS_CLIPCHILDREN \
                | commctrl.TBSTYLE_LIST \
                | commctrl.TBSTYLE_FLAT \
                | commctrl.TBSTYLE_TRANSPARENT \
                | commctrl.CCS_TOP \
                | commctrl.CCS_NODIVIDER \
                | commctrl.CCS_NORESIZE \
                | commctrl.CCS_NOPARENTALIGN
        self.hwnd = win32gui.CreateWindow('ToolbarWindow32', None, styles,
                                          0, 0, 100, 100,
                                          hwndparent, 0, win32gui.dllhandle,
                                          None)
        win32gui.SendMessage(self.hwnd, commctrl.TB_BUTTONSTRUCTSIZE, 20, 0)
项目:fame_modules    作者:certsocietegenerale    | 项目源码 | 文件源码
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
项目:pyAutoTrading    作者:drongh    | 项目源码 | 文件源码
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
项目:easytrader    作者:yuzhucu    | 项目源码 | 文件源码
def sell(self, stock_code, price, amount, **kwargs):
        """
        ????
        :param stock_code: ????
        :param price: ????
        :param amount: ????
        :return: bool ????????
        """
        amount = str(amount // 100 * 100)
        price = str(price)

        try:
            win32gui.SendMessage(self.sell_stock_code_hwnd, win32con.WM_SETTEXT, None, stock_code)  # ??????
            win32gui.SendMessage(self.sell_price_hwnd, win32con.WM_SETTEXT, None, price)  # ??????
            win32gui.SendMessage(self.sell_price_hwnd, win32con.BM_CLICK, None, None)  # ??????
            time.sleep(0.2)
            win32gui.SendMessage(self.sell_amount_hwnd, win32con.WM_SETTEXT, None, amount)  # ??????
            time.sleep(0.2)
            win32gui.SendMessage(self.sell_btn_hwnd, win32con.BM_CLICK, None, None)  # ????
            time.sleep(0.3)
        except:
            traceback.print_exc()
            return False
        return True
项目:easytrader    作者:yuzhucu    | 项目源码 | 文件源码
def cancel_entrust(self, stock_code, direction):
        """
        ??
        :param stock_code: str ????
        :param direction: str 'buy' ??? 'sell' ??
        :return: bool ????????
        """
        direction = 0 if direction == 'buy' else 1

        try:
            win32gui.SendMessage(self.refresh_entrust_hwnd, win32con.BM_CLICK, None, None)  # ????
            time.sleep(0.2)
            win32gui.SendMessage(self.cancel_stock_code_hwnd, win32con.WM_SETTEXT, None, stock_code)  # ????
            win32gui.SendMessage(self.cancel_query_hwnd, win32con.BM_CLICK, None, None)  # ????
            time.sleep(0.2)
            if direction == 0:
                win32gui.SendMessage(self.cancel_buy_hwnd, win32con.BM_CLICK, None, None)  # ??
            elif direction == 1:
                win32gui.SendMessage(self.cancel_sell_hwnd, win32con.BM_CLICK, None, None)  # ??
        except:
            traceback.print_exc()
            return False
        time.sleep(0.3)
        return True
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def selectComboboxItem(hwnd, item):
    '''Selects a specified item in a Combo box control.

    Arguments:
    hwnd            Window handle of the required combo box.
    item            The reqired item. Either an index, of the text of the
                    required item.

    Usage example:  fontComboItems = getComboboxItems(fontCombo)
                    selectComboboxItem(fontCombo,
                                       random.choice(fontComboItems))
    '''
    try: # item is an index Use this to select
        0 + item
        win32gui.SendMessage(hwnd, win32con.CB_SETCURSEL, item, 0)
        _sendNotifyMessage(hwnd, win32con.CBN_SELCHANGE)
    except TypeError: # Item is a string - find the index, and use that
        items = getComboboxItems(hwnd)
        itemIndex = items.index(item)
        selectComboboxItem(hwnd, itemIndex)
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def selectListboxItem(hwnd, item):
    '''Selects a specified item in a list box control.

    Arguments:
    hwnd            Window handle of the required list box.
    item            The reqired item. Either an index, of the text of the
                    required item.

    Usage example:  TODO
    '''
    try: # item is an index Use this to select
        0 + item
        win32gui.SendMessage(hwnd, win32con.LB_SETCURSEL, item, 0)
        _sendNotifyMessage(hwnd, win32con.LBN_SELCHANGE)
    except TypeError: # Item is a string - find the index, and use that
        items = getListboxItems(hwnd)
        itemIndex = items.index(item)
        selectListboxItem(hwnd, itemIndex)
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def selectComboboxItem(hwnd, item):
    '''Selects a specified item in a Combo box control.

    Arguments:
    hwnd            Window handle of the required combo box.
    item            The reqired item. Either an index, of the text of the
                    required item.

    Usage example:  fontComboItems = getComboboxItems(fontCombo)
                    selectComboboxItem(fontCombo,
                                       random.choice(fontComboItems))
    '''
    try: # item is an index Use this to select
        0 + item
        win32gui.SendMessage(hwnd, win32con.CB_SETCURSEL, item, 0)
        _sendNotifyMessage(hwnd, win32con.CBN_SELCHANGE)
    except TypeError: # Item is a string - find the index, and use that
        items = getComboboxItems(hwnd)
        itemIndex = items.index(item)
        selectComboboxItem(hwnd, itemIndex)
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def selectListboxItem(hwnd, item):
    '''Selects a specified item in a list box control.

    Arguments:
    hwnd            Window handle of the required list box.
    item            The reqired item. Either an index, of the text of the
                    required item.

    Usage example:  TODO
    '''
    try: # item is an index Use this to select
        0 + item
        win32gui.SendMessage(hwnd, win32con.LB_SETCURSEL, item, 0)
        _sendNotifyMessage(hwnd, win32con.LBN_SELCHANGE)
    except TypeError: # Item is a string - find the index, and use that
        items = getListboxItems(hwnd)
        itemIndex = items.index(item)
        selectListboxItem(hwnd, itemIndex)
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def Bar_code(DoingFlag=True,timesleep='2'):
    print 'DoingFlag:',DoingFlag
    print "Bar_code"
    clsname ="?"
    time.sleep(string.atoi(timesleep)*2)
    lresults = findTopWindows(clsname)
    while True:
        lbutton= findControls(lresults[0],wantedText="?",wantedClass="Button")
        str_a =controls.win32_controls.ButtonWrapper(lbutton[0]).GetProperties()['IsEnabled']
        if   str_a == True:
            clickButton(lbutton[0])
        time.sleep(string.atoi(timesleep)*2)
        clsname1 ="ONUtest"
        lresults1 = findTopWindows(clsname1)
        if len(lresults1)>0:
            lbutton1= findControls(lresults1[0],wantedClass="Button") 
            clickButton(lbutton1[0])
        if  DoingFlag ==False:
            time.sleep(string.atoi(timesleep)*3)
            break
    time.sleep(string.atoi(timesleep)*3)
    win32gui.SendMessage(lresults[0],win32con.WM_CLOSE,0,0)
    return True
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def selectComboboxItemThird(hwnd, item):
    try: # item is an index Use this to select
        0 + item
        win32gui.SendMessage(hwnd, win32con.CB_SHOWDROPDOWN, 1, 0)
        win32gui.SendMessage(hwnd, win32con.CB_SETCURSEL, item, 0)
        win32gui.SendMessage(hwnd, win32con.WM_SETFOCUS, 0, 0 )
        time.sleep(1)
        tmp=win32gui.GetWindowRect(hwnd)
        #print 'selectComboboxItemThird',tmp
        '''
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0]+1, tmp[1]+1) 
        time.sleep(0.1)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0]+1, tmp[1]+1)
        '''
        win32gui.SendMessage(hwnd, win32con.WM_KEYDOWN, 13, 0 )
        time.sleep(0.1)
        win32gui.SendMessage(hwnd, win32con.WM_KEYUP, 13, 0 )
        time.sleep(0.1)
        #_sendNotifyMessage(hwnd, win32con.CBN_SELCHANGE)
    except TypeError: # Item is a string - find the index, and use that

        items = getComboboxItems(hwnd)
        itemIndex = items.index(item)
        selectComboboxItem(hwnd, itemIndex)
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def selectListboxItem(hwnd, item):
    '''Selects a specified item in a list box control.

    Arguments:
    hwnd            Window handle of the required list box.
    item            The reqired item. Either an index, of the text of the
                    required item.

    Usage example:  TODO
    '''
    try: # item is an index Use this to select
        0 + item
        win32gui.SendMessage(hwnd, win32con.LB_SETCURSEL, item, 0)
        _sendNotifyMessage(hwnd, win32con.LBN_SELCHANGE)
    except TypeError: # Item is a string - find the index, and use that
        items = getListboxItems(hwnd)
        itemIndex = items.index(item)
        selectListboxItem(hwnd, itemIndex)
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def GetChildapp(self,str_app):
        print '******** GetChildapp fuction ********'
        hwnd = win32gui.FindWindow(None, str_app)
        if hwnd < 1:
            hwnd = self.find_main_window(str_app)
        if hwnd>1:
            hChild =  win32gui.GetWindow(hwnd,win32con.GW_CHILD)
            bufLen=1024
            buf =win32gui.PyMakeBuffer(bufLen)
            totalnum = 1 
            while hChild :
                hChild = win32gui.GetWindow(hChild,win32con.GW_HWNDNEXT)
                n = win32gui.SendMessage(hChild,win32con.WM_GETTEXT,bufLen,buf)
                str = buf[:n]
                print '@@@@@@@@@@@'
                print win32gui.GetWindowText(hChild)
                print str
                '''
                if totalnum ==3:
                    win32gui.SendMessage(hChild,win32con.WM_SETTEXT,None,'Realtek 10/100/1000 Ethernet NIC')
                '''
                print  totalnum,hChild
                totalnum = totalnum + 1

        print '******** GetChildapp fuction ********',totalnum
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def OnInitDialog(self, hwnd, msg, wparam, lparam):
        self.hwnd = hwnd

        desktop = win32gui.GetDesktopWindow()
        dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
        centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)/2, (dt_b-dt_t)/2) )

        bmCtrl = win32gui.GetDlgItem(self.hwnd, IDC_BITMAP)
        win32gui.SendMessage(bmCtrl, win32con.STM_SETIMAGE, win32con.IMAGE_BITMAP, self.hSplash)

        win32gui.SetWindowPos(self.hwnd, win32con.HWND_TOPMOST, 
                              centre_x-(self.bmWidth/2), centre_y-(self.bmHeight/2), 
                              self.bmWidth, self.bmHeight, win32con.SWP_HIDEWINDOW)
        win32gui.SetForegroundWindow(self.hwnd)
项目:tdx    作者:sqltxt    | 项目源码 | 文件源码
def File_name():
    try:
        win32gui.SendMessage(win32gui.FindWindowEx(win32gui.FindWindow('#32770','???'),None,'Edit',None),win32con.WM_SETTEXT,0,'????'+str(int(time.strftime("%Y%m%d")))+'.EBK')
        time.sleep(1)
    except Exception as e:
        ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))

#??
项目:tdx    作者:sqltxt    | 项目源码 | 文件源码
def Ctrl_T():
    try:
        win32api.keybd_event(17,0,0,0)#ctrl????17
        win32api.keybd_event(84,0,0,0)#t????84
        win32api.keybd_event(84,0,win32con.KEYEVENTF_KEYUP,0)#????
        win32api.keybd_event(17,0,win32con.KEYEVENTF_KEYUP,0)
        time.sleep(3)
        #win32gui.SendMessage(Tab_handle,0x130C,1,0)#????????????????
    except Exception as e:
        ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))

#???????
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def BrowseCallbackProc(hwnd, msg, lp, data):
    if msg== shellcon.BFFM_INITIALIZED:
        win32gui.SendMessage(hwnd, shellcon.BFFM_SETSELECTION, 1, data)
    elif msg == shellcon.BFFM_SELCHANGED:
        # Set the status text of the
        # For this message, 'lp' is the address of the PIDL.
        pidl = shell.AddressAsPIDL(lp)
        try:
            path = shell.SHGetPathFromIDList(pidl)
            win32gui.SendMessage(hwnd, shellcon.BFFM_SETSTATUSTEXT, 0, path)
        except shell.error:
            # No path for this PIDL
            pass
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
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
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def AddButtons(self,*buttons):
        tbbuttons = ''
        for button in buttons:
            tbbuttons += button.toparam()
        return win32gui.SendMessage(self.hwnd, commctrl.TB_ADDBUTTONS,
                                    len(buttons), tbbuttons)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def AddButtons(self,*buttons):
        tbbuttons = ''
        for button in buttons:
            tbbuttons += button.toparam()
        return win32gui.SendMessage(self.hwnd, commctrl.TB_ADDBUTTONS,
                                    len(buttons), tbbuttons)
项目:myautotest    作者:auuppp    | 项目源码 | 文件源码
def SendMessage(self, msg):
        '''Send message to the top window'''
        logging.debug("SendMessage "+msg + " to the current top window")
        win32gui.SendMessage(self.hwnd, msg, 0, 0)
项目:myautotest    作者:auuppp    | 项目源码 | 文件源码
def get_expect_sec_window(self):
        '''return the expect window hwnd'''                

#         control = win32gui.FindWindowEx(window, 0, 'static', None)
#         buffer = win32gui.PyMakeBuffer(20)
#         length = win32gui.SendMessage(control, win32con.WM_GETTEXT, 20, buffer)
#  
#         result = buffer[:length]
#         print result
#         time.sleep(1)
        return self.expect_sec_window
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def BrowseCallbackProc(hwnd, msg, lp, data):
    if msg== shellcon.BFFM_INITIALIZED:
        win32gui.SendMessage(hwnd, shellcon.BFFM_SETSELECTION, 1, data)
    elif msg == shellcon.BFFM_SELCHANGED:
        # Set the status text of the
        # For this message, 'lp' is the address of the PIDL.
        pidl = shell.AddressAsPIDL(lp)
        try:
            path = shell.SHGetPathFromIDList(pidl)
            win32gui.SendMessage(hwnd, shellcon.BFFM_SETSTATUSTEXT, 0, path)
        except shell.error:
            # No path for this PIDL
            pass
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def ClearListItems(self):
        win32gui.SendMessage(self.hwndList, commctrl.LVM_DELETEALLITEMS)
        self.list_data = {}
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def AddButtons(self,*buttons):
        tbbuttons = ''
        for button in buttons:
            tbbuttons += button.toparam()
        return win32gui.SendMessage(self.hwnd, commctrl.TB_ADDBUTTONS,
                                    len(buttons), tbbuttons)
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_SendTextWithAt(str):
    os.system(qq_shortcut)

    try_time = 0
    while True:
        time.sleep(0.5)
        hwnd = win32gui.FindWindow(None, '??&??')
        # hwnd = win32gui.FindWindow(None, 'OSVT?O?')
        print('try_time = %d, hwnd = %d' % (try_time, hwnd))
        if hwnd != 0:
            break
        elif try_time >= 60:
            print ('SendTextToQQ Error.')
            return
        else:
            try_time = try_time + 1

    win32gui.SetForegroundWindow(hwnd)

    QQ_PrintTextWithAt(str)
    QQ_Enter()

    # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, win32con.VK_RETURN, 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, ord('v'), 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, ord('v'), 0)


    #win32gui.SendMessage(hwnd, win32con.WM_SETTEXT, None, 'aaa')
    #win32gui.SetWindowText(hwnd, 'aaa')
    #win32gui.ReplaceSel()
    #win32gui.PostMessage(hwnd, win32con.WM_CHAR, '', 3)

    # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_CONTROL, 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, ord('V'), 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, ord('V'), 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, win32con.VK_CONTROL, 0)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def BrowseCallbackProc(hwnd, msg, lp, data):
    if msg== shellcon.BFFM_INITIALIZED:
        win32gui.SendMessage(hwnd, shellcon.BFFM_SETSELECTION, 1, data)
    elif msg == shellcon.BFFM_SELCHANGED:
        # Set the status text of the
        # For this message, 'lp' is the address of the PIDL.
        pidl = shell.AddressAsPIDL(lp)
        try:
            path = shell.SHGetPathFromIDList(pidl)
            win32gui.SendMessage(hwnd, shellcon.BFFM_SETSTATUSTEXT, 0, path)
        except shell.error:
            # No path for this PIDL
            pass
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def ClearListItems(self):
        win32gui.SendMessage(self.hwndList, commctrl.LVM_DELETEALLITEMS)
        self.list_data = {}
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def AddButtons(self,*buttons):
        tbbuttons = ''
        for button in buttons:
            tbbuttons += button.toparam()
        return win32gui.SendMessage(self.hwnd, commctrl.TB_ADDBUTTONS,
                                    len(buttons), tbbuttons)
项目:fame_modules    作者:certsocietegenerale    | 项目源码 | 文件源码
def foreach_window(self):
        def callback(hwnd, lparam):
            title = win32gui.GetWindowText(hwnd).lower()

            for window in self.to_close:
                if window in title:
                    win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
                    print "Closed window ({})".format(title)

            for window in self.clicks:
                if window in title:
                    self._windows[hwnd] = {
                        "matches": self.clicks[window],
                        "to_click": [],
                        "buttons": []
                    }
                    try:
                        win32gui.EnumChildWindows(hwnd, self.foreach_child(), hwnd)
                    except:
                        print "EnumChildWindows failed, moving on."

                    for button_toclick in self._windows[hwnd]['to_click']:
                        for button in self._windows[hwnd]['buttons']:
                            if button_toclick in button['text']:
                                win32gui.SetForegroundWindow(button['handle'])
                                win32gui.SendMessage(button['handle'], win32con.BM_CLICK, 0, 0)
                                print "Clicked on button ({} / {})".format(title, button['text'])

                    del self._windows[hwnd]

            return True

        return callback
项目:pyAutoTrading    作者:drongh    | 项目源码 | 文件源码
def _readListViewItems(hwnd, column_index=0):
    # Allocate virtual memory inside target process
    pid = ctypes.create_string_buffer(4)
    p_pid = ctypes.addressof(pid)
    GetWindowThreadProcessId(hwnd, p_pid)  # process owning the given hwnd
    hProcHnd = OpenProcess(win32con.PROCESS_ALL_ACCESS, False, struct.unpack("i", pid)[0])
    pLVI = VirtualAllocEx(hProcHnd, 0, 4096, win32con.MEM_RESERVE | win32con.MEM_COMMIT, win32con.PAGE_READWRITE)
    pBuffer = VirtualAllocEx(hProcHnd, 0, 4096, win32con.MEM_RESERVE | win32con.MEM_COMMIT, win32con.PAGE_READWRITE)

    # Prepare an LVITEM record and write it to target process memory
    lvitem_str = struct.pack('iiiiiiiii', *[0, 0, column_index, 0, 0, pBuffer, 4096, 0, 0])
    lvitem_buffer = ctypes.create_string_buffer(lvitem_str)
    copied = ctypes.create_string_buffer(4)
    p_copied = ctypes.addressof(copied)
    WriteProcessMemory(hProcHnd, pLVI, ctypes.addressof(lvitem_buffer), ctypes.sizeof(lvitem_buffer), p_copied)

    # iterate items in the SysListView32 control
    num_items = win32gui.SendMessage(hwnd, commctrl.LVM_GETITEMCOUNT)
    item_texts = []
    for item_index in range(num_items):
        win32gui.SendMessage(hwnd, commctrl.LVM_GETITEMTEXT, item_index, pLVI)
        target_buff = ctypes.create_string_buffer(4096)
        ReadProcessMemory(hProcHnd, pBuffer, ctypes.addressof(target_buff), 4096, p_copied)
        item_texts.append(target_buff.value)

    VirtualFreeEx(hProcHnd, pBuffer, 0, win32con.MEM_RELEASE)
    VirtualFreeEx(hProcHnd, pLVI, 0, win32con.MEM_RELEASE)
    win32api.CloseHandle(hProcHnd)
    return item_texts
项目:pyAutoTrading    作者:drongh    | 项目源码 | 文件源码
def _sendNotifyMessage(hwnd, nofifyMessage):
    """Send a notify message to a control."""
    win32gui.SendMessage(win32gui.GetParent(hwnd),
                         win32con.WM_COMMAND,
                         _buildWinLong(nofifyMessage,
                                       win32api.GetWindowLong(hwnd,
                                                              win32con.GWL_ID)),
                         hwnd)