python实现根据窗口标题调用窗口的方法

WBOY
Release: 2016-06-06 11:22:50
Original
1849 people have browsed it

本文实例讲述了python实现根据窗口标题调用窗口的方法。分享给大家供大家参考。具体分析如下:

当你知道一个windows窗口的标题后,可以用下面的代码调用窗口,甚至向窗口内写入内容。

#-*-coding:utf-8-*-
import win32gui,win32con
#下面的是窗口的标题名称,这样是一定错的,但在控制台就可以正常使用
#写在文件里要用U编码
a=u"bitsCN.com"
dlg=win32gui.FindWindow(None,a)
//用控件的ID取得控件的句柄,模拟写入输入框文本并按下提交按键
t1=win32gui.GetDlgItem(dlg,1012)
t2=win32gui.GetDlgItem(dlg,1001)
k1=win32gui.GetDlgItem(dlg,1605)
win32gui.SendMessage(t1,win32con.WM_SETTEXT,None,'902723')
win32gui.SendMessage(t2,win32con.WM_SETTEXT,None,'761209')
win32gui.SendMessage(k1,win32con.BM_CLICK,None,None)
Copy after login

希望本文所述对大家的Python程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!