zoukankan      html  css  js  c++  java
  • win32gui.EnumWindows

    python2

    import win32gui, win32con, win32api
    import time, math, random
      
    def _MyCallback( hwnd, extra ):
        windows = extra
        temp=[]
        temp.append(hex(hwnd))
        temp.append(win32gui.GetClassName(hwnd))
        temp.append(win32gui.GetWindowText(hwnd))
        windows[hwnd] = temp
      
    def TestEnumWindows():
        windows = {}
        win32gui.EnumWindows(_MyCallback, windows)
        print "Enumerated a total of  windows with %d classes" ,(len(windows))
        print '------------------------------'
        #print classes
        print '-------------------------------'
        for item in windows :
            print  windows[item]
     
    print "Enumerating all windows..."
    h=win32gui.FindWindow(None,'xbaxecxcexe5')
    print hex(h)
    #TestEnumWindows()
    print "All tests done!"
    

    python3

    import win32gui
    def _MyCallback(hwnd, extra):
        windows = extra
        temp = []
        temp.append(hex(hwnd))
        temp.append(win32gui.GetClassName(hwnd))
        temp.append(win32gui.GetWindowText(hwnd))
        windows[hwnd] = temp
    windows = {}
    win32gui.EnumWindows(_MyCallback, windows)
    hld=win32gui.FindWindow("TXGuiFoundation",'实时加速工具')
    
    hldb=win32gui.FindWindow("TXGuiFoundation",'实时加速工具2')
    

    img

    import win32gui
    
    
    def _MyCallback(hwnd, extra):
        windows = extra
        temp = []
        temp.append(hex(hwnd))
        temp.append(win32gui.GetClassName(hwnd))
        temp.append(win32gui.GetWindowText(hwnd))
        windows[hwnd] = temp
    
    
    windows = {}
    win32gui.EnumWindows(_MyCallback, windows)
    hld = win32gui.FindWindow("TXGuiFoundation", '实时加速工具')
    
    hldb = win32gui.FindWindow("TXGuiFoundation", '实时加速工具2')
    """
    手动确定ClassName-WindowText  窗口组名-单独名
    生成临时文件,检索
    with open('tmp.txt', 'w', encoding='utf-8') as fo:
        for i in windows:
            s = '%s%s' % (str(i), str(windows[i]))
            fo.write(s)
    """
    """
    8064026['0x7b0c1a', 'BS2CHINAUI', '']
    201748['0x31414', 'BS2CHINAUI', 'BSCNKEYMAPWND_Android']
    660380['0xa139c', 'BS2CHINAUI', '']
    529522['0x81472', 'BS2CHINAUI', '']
    922564['0xe13c4', 'BS2CHINAUI', 'BlueStacks App Player']
    
    4390956['0x43002c', 'BS2CHINAUI', 'soui tooltip']
    988220['0xf143c', 'BS2CHINAUI', 'soui tooltip']
    660518['0xa1426', 'BS2CHINAUI', 'soui tooltip']
    
    """
    
    windowstext = 'BlueStacks App Player'
    
    hld_a,hld_b = win32gui.FindWindow('BS2CHINAUI', 'BSCNKEYMAPWND_Android'),win32gui.FindWindow('BS2CHINAUI', 'BlueStacks App Player')
    
  • 相关阅读:
    []==![] 为什么等于true?
    this指向问题
    Git的基本了解与使用、向github提交代码
    Javascript实现多行字符串
    常见浏览器兼容性问题与解决方案?
    Scapy——Scrapy shell的使用
    Python中单下划线和双下划线
    Python中@staticmethod和@classmethod的作用和区别
    Python多进程、多线程和协程简介
    精简Docker镜像的几个方法
  • 原文地址:https://www.cnblogs.com/zhizhao/p/11489684.html
Copyright © 2011-2022 走看看