Python win32con 模块,WM_SETTEXT 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用win32con.WM_SETTEXT

项目:easytrader    作者:yuzhucu    | 项目源码 | 文件源码
def buy(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.buy_stock_code_hwnd, win32con.WM_SETTEXT, None, stock_code)  # ??????
            win32gui.SendMessage(self.buy_price_hwnd, win32con.WM_SETTEXT, None, price)  # ??????
            time.sleep(0.2)
            win32gui.SendMessage(self.buy_amount_hwnd, win32con.WM_SETTEXT, None, amount)  # ??????
            time.sleep(0.2)
            win32gui.SendMessage(self.buy_btn_hwnd, win32con.BM_CLICK, None, None)  # ????
            time.sleep(0.3)
        except:
            traceback.print_exc()
            return False
        return True
项目: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
项目: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
项目: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)
项目:autoops_for_win    作者:qiueer    | 项目源码 | 文件源码
def  SetText(cls, whd, text):
        win32api.SendMessage(whd,win32con.WM_SETTEXT,None, text)
项目:easytrader    作者:yuzhucu    | 项目源码 | 文件源码
def _set_login_name(self, user):
        time.sleep(0.5)
        input_hwnd = win32gui.GetDlgItem(self.login_hwnd, 0x5523)
        win32gui.SendMessage(input_hwnd, win32con.WM_SETTEXT, None, user)
项目:easytrader    作者:yuzhucu    | 项目源码 | 文件源码
def _set_login_password(self, password):
        time.sleep(0.5)
        input_hwnd = win32gui.GetDlgItem(self.login_hwnd, 0x5534)
        win32gui.SendMessage(input_hwnd, win32con.WM_SETTEXT, None, password)
项目:easytrader    作者:yuzhucu    | 项目源码 | 文件源码
def _input_login_verify_code(self, code):
        input_hwnd = win32gui.GetDlgItem(self.login_hwnd, 0x56b9)
        win32gui.SendMessage(input_hwnd, win32con.WM_SETTEXT, None, code)
项目:AutoTestFramework    作者:huilansame    | 项目源码 | 文件源码
def upload_by_win32(self, files):
        """win32?? —— ????????????????????files????list?"""
        self._window_open()
        self._files(files)
        self.logger.info('upload {0} by win32'.format(self.files))

        upload = win32gui.FindWindow('#32770', self.window_name)

        # find Edit
        ComboBoxEx32 = win32gui.FindWindowEx(upload, 0, 'ComboBoxEx32', None)
        ComboBox = win32gui.FindWindowEx(ComboBoxEx32, 0, 'ComboBox', None)
        Edit = win32gui.FindWindowEx(ComboBox, 0, 'Edit', None)

        # find confirm button
        button = win32gui.FindWindowEx(upload, 0, 'Button', None)

        # ????????
        if upload and Edit and button:
            self.window_open_flag = 1
        else:
            raise UploadWindowNotOpenError('???????????')

        win32gui.SendMessage(Edit, win32con.WM_SETTEXT, 0, self.files)
        win32gui.SendMessage(upload, win32con.WM_COMMAND, 1, button)

        self.window_open_flag = 0
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def dumpWindow_pos(hwnd):
    '''Dump all controls from a window into a nested list
    Useful during development, allowing to you discover the structure of the
    contents of a window, showing the text and class of all contained controls.

    Arguments:      The window handle of the top level window to dump.

    Returns         A nested list of controls. Each entry consists of the
                    control's hwnd, its text, its class, and its sub-controls,
                    if any.

    Usage example:  replaceDialog = findTopWindow(wantedText='Replace')
                    pprint.pprint(dumpWindow(replaceDialog))
    '''
    windows = []
    try:
        win32gui.EnumChildWindows(hwnd, _windowEnumerationHandler, windows)
    except win32gui.error:
        # No child windows
        return
    windows = [list(window) for window in windows]
    for window in windows:
        childHwnd, windowText, windowClass = window
        window_content = dumpWindow(childHwnd)
        if window_content:
            window.append(window_content)
            print '###################'
            print childHwnd,'pos:',win32gui.GetWindowRect(childHwnd),'window_content:',window_content
            tuple_t = win32gui.GetWindowRect(childHwnd)
            if tuple_t[0]==179 and tuple_t[2]==561:
                print window_content[0][0],'pos:',win32gui.GetWindowRect(window_content[0][0])
                if window_content[0][0]:
                    bufLen=1024
                    buf =win32gui.PyMakeBuffer(bufLen)
                    n = win32gui.SendMessage(window_content[0][0],win32con.WM_GETTEXT,bufLen,buf)
                    str = buf[:n]
                    print str
                    print getEditText(window_content[0][0])
                    time.sleep(1)
                    #win32gui.SendMessage(window_content[0][0],win32con.WM_SETTEXT,None,'Realtek 10/100/1000 Ethernet NIC')
            print '###################'
    return windows
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def Find_Gui_edit(self,str_app='´ò¿ª',control_class='ComboBox',filename='wtp_cuo1.pcap',control_name='',stop_flag='0'):

        print "*********Find_Gui_edit function**********",str_app
        time.sleep(1)
        #self.Mousepos_print()
        print 'str_app',str_app
        hwnd = win32gui.FindWindow(None, str_app)
        print 'hwnd',hwnd
        win32gui.SetForegroundWindow(hwnd)
        comboHwnd = win32gui.FindWindowEx(hwnd,0,control_class,None)
        bufLen=256
        buf =win32gui.PyMakeBuffer(bufLen)
        while comboHwnd:
            if stop_flag=='1':
                win32gui.SendMessage(comboHwnd,win32con.WM_SETTEXT,bufLen,filename)
                time.sleep(1)
                break
            print "control_class:",comboHwnd
            cla =  win32gui.GetClassName(comboHwnd)
            print cla

            if control_class in cla:
                n = win32gui.SendMessage(comboHwnd,win32con.WM_GETTEXT,bufLen,buf)
                str = buf[:n]
                if (len(control_name ) ==0 and n==0)  or (len(control_name )>0 and  str.find(control_name)>-1 ):
                    win32gui.SendMessage(comboHwnd,win32con.WM_SETTEXT,bufLen,filename)
                    time.sleep(1)
                    break
            comboHwnd = win32gui.GetWindow(comboHwnd,win32con.GW_HWNDNEXT)
        time.sleep(1)
        return True