win_GUI.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:Automation-Framework-for-devices 作者: tok-gogogo 项目源码 文件源码
def Find_Gui_Tree(self,str_app='New Scenario',control_class='Button',filename='test_baidu',control_name='AfxOleControl'):

        print "*********Find_Gui_Tree function**********"
        time.sleep(1)
        #self.Mousepos_print()
        print 'str_app',str_app
        hwnd = win32gui.FindWindow(None, str_app)
        if hwnd < 1:
            hwnd = self.find_main_window(str_app)
        print 'hwnd',hwnd
        win32gui.SetForegroundWindow(hwnd)

        print 'hwnd :',hwnd,str_app
        win32gui.SetForegroundWindow(hwnd)

        #self.Mousepos_print('5')
        comboHwnd = win32gui.FindWindowEx(hwnd,0,control_class,None)
        print '111111111111comboHwnd',comboHwnd
        while comboHwnd:
            print "control_class:",comboHwnd
            cla =  win32gui.GetClassName(comboHwnd)
            print "control_class_NAME:",cla
            bufLen=1024
            buf =win32gui.PyMakeBuffer(bufLen)
            n = win32gui.SendMessage(comboHwnd,win32con.WM_GETTEXT,bufLen,buf)
            str = buf[:n]
            print str
            '''
            if control_class in cla:
                n = win32gui.SendMessage(comboHwnd,win32con.WM_GETTEXT,bufLen,buf)
                str = buf[:n]
                print str
                if (len(control_name ) ==0 and n==0)  or ((len(control_name )>0 and  str.find(control_name)>-1 )):
                    win32gui.SendMessage(comboHwnd,win32con.WM_LBUTTONDOWN,0)
                    time.sleep(0.05)
                    win32gui.SendMessage(comboHwnd,win32con.WM_LBUTTONUP,0)
                    time.sleep(0.05)
                    win32gui.SendMessage(win32con.WM_CLOSE,0,0)
                    break
            '''
            comboHwnd = win32gui.GetWindow(comboHwnd,win32con.GW_HWNDNEXT)
        time.sleep(1)


        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号