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,'\xba\xec\xce\xe5')
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')

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')

win32gui.EnumWindows的更多相关文章

  1. win32gui.EnumWindows my.os.EnumWindows.py

    import win32guidef _MyCallback(hwnd, extra): windows = extra temp = [] temp.append(hex(hwnd)) temp.a ...

  2. python 通过js控制滚动条拉取全文 通过psutil获取pid窗口句柄,通过win32gui使程序窗口前置 通过autopy实现右键菜单和另存为操作

    1.参考 利用 Python + Selenium 自动化快速截图 利用 Python + Selenium 实现对页面的指定元素截图(可截长图元素) 使用python获取系统所有进程PID以及进程名 ...

  3. Python win32gui调用窗口到最前面

    Python win32gui调用窗口到最前面 0要写一个轮询几个重要页面的程序,不停的在大屏上进行刷新,通过pywin32模块下的SetForegroundWindow函数调用时,会出现error: ...

  4. win+python+selenium实现窗口和tab切换

    这篇总结主要是关于两方面的需求:其一,在浏览器不同tab标签页之间按时间切换(同事用来不停刷新grid crontol 监控页面):其二,实现开启多个窗口,并将窗口缩放到一定范围,并齐占满整个桌面,按 ...

  5. Python之窗口操作之find_window,set_foreground等

    在自动化测试过程中,常常需要模拟按键的操作,比如像窗口发送一个按键,实现鼠标点击的功能,在上一篇文章中,我和大家讨论了python文件生成为不依赖与python库的exe文件的方式(需要了解的朋友戳这 ...

  6. Python基础系列讲解-自动控制windows桌面

    原链接:https://zhuanlan.zhihu.com/p/73001806 在使用PC时与PC交互的主要途径是看屏幕显示.听声音,点击鼠标和敲键盘等等.在自动化办公的趋势下,繁琐的工作可以让程 ...

  7. python 前置程序窗口,还原最小化的窗口

    python 前置程序窗口,还原最小化的窗口 在网上找了比较久,大多是: win32gui.FindWindow(class_name, window_name) win32gui.SetForegr ...

  8. python---win32gui、win32con、win32api:winAPI操作

    python操作winAPI 窗口操作: import sys from PyQt5.QtWidgets import QApplication, QWidget from lianxi import ...

  9. RPA项目所遇知识点

    1艺赛旗 RPA 技术分享常见问题汇总贴 2python标准库之glob介绍 3RPA基础 4RPA答疑 5python3 遍历windows下 所有句柄及窗口名称 import win32gui h ...

随机推荐

  1. C++标准异常与自定义异常

    参见https://www.runoob.com/cplusplus/cpp-exceptions-handling.html C++ 标准的异常 C++ 提供了一系列标准的异常,定义在 中,我们可以 ...

  2. [转帖]在 k8s 中自动为域名配置 https

    在 k8s 中自动为域名配置 https https://juejin.im/post/5db8d94be51d4529f73e2833 随着 web 的发展,https 对于现代网站来说是必不可少的 ...

  3. Linux学习-IP设置

    网卡命名规则 CENTOS6的网卡命名方式:它会根据情况有所改变而非唯一且固定,在CENTOS6之前,网络接口使用连续号码命名: eth0. eth1等,当增加或删除网卡时,名称可能会发生变化 CEN ...

  4. Spring全家桶注解一览(精选)

    废话 最近想整理一波Spring注解相关的文章,虽然写CURD就只涉及到那些常用的注解.但是笔者我也想去了解一下其他注解,丰富下自己的知识面(提升一下逼格!). 就想在网上搜了半天,好像大家的都差不多 ...

  5. Linux中的两个经典宏定义:获取结构体成员地址,根据成员地址获得结构体地址;Linux中双向链表的经典实现。

    倘若你查看过Linux Kernel的源码,那么你对 offsetof 和 container_of 这两个宏应该不陌生.这两个宏最初是极客写出的,后来在Linux内核中被推广使用. 1. offse ...

  6. SAS学习笔记58 单元格格式化设计

    单元格行_row_ 对于行单元格,主要就通过_row_这么一个自动变量的方式,来对单元格所有行进行格式化设计 例如,对性别为“男”的单元格所在行颜色设定为红色: 单元格列_col_ 将_row_改成_ ...

  7. java之hibernate之crud

    这篇文章主要讲解: 1>.对Hibernate使用的一些简单封装: · 2>.在单元测试中,使用Hibernate的封装的工具进行增删改查的测试 1.目录结构展示 2.代码展示 2.0 配 ...

  8. apache-httpd代理请求,selinux造成503问题的解决方法

    NameVirtualHost *:80 <VirtualHost *:80> ServerName test.baidu.com ProxyPreserveHost on ProxyPa ...

  9. Keepalived简单理解

    Keepalived Keepalived是一个基于VRRP协议来实现的LVS服务高可用方案,可以利用其来避免单点故障.一个LVS服务会有2台服务器运行Keepalived,一台为主服务器(MASTE ...

  10. 全局启动函数start_kernel函数注解

    asmlinkage void __init start_kernel(void) { char * command_line; extern struct kernel_param __start_ ...