python弹出窗口后卡死_【Python 操作IE的弹出窗口】

""" Get the specified Popup message box

c!t7FE'x:m]q9^j0 parameters:51Testing软件测试网o!FG6I+o5eo

[filter] - Only return elements that match this filter in format51Testing软件测试网"o#{8Aq9P6k6n)j

(title=Microsoft Internet Explorer;text=Are you sure to close the window;index:=0)51Testing软件测试网\U(]0A^NV5sriJ

The filter value to match. Regular Expressions

#]?YR"oxbS!R0 can be used by starting the val with an ! "title=!Google;text=!baidu"

ew1VJq#I0 #(Add by luchenzhi @ March 30,2010)

~Y"FV3I*g0 returns:

$kZXqh1QW#H6V_ zR0 a popup message box hwnd51Testing软件测试网9cCU(I!Dv2x.W

"""

ph*_pEFo3H0 MsgboxHwnd = 0

b'A"O/m(R0 MatchTime = 0

:QV[x

j)n)a0 MatchIndex = 0

o[UK~!vgW0 try:

m6uG3t\9tI0B0m0 for i in range(0,100) :

Kya#B(l_0 MsgboxHwnd=win32gui.FindWindowEx(0,MsgboxHwnd,"#32770",None)51Testing软件测试网Xn?UMSvdM

if MsgboxHwnd == 0 :

j6k(cwV0 break51Testing软件测试网1oa*|,n!\

if win32gui.GetParent(MsgboxHwnd) == self._ie.Hwnd:

5s)T4rU0E5]'yY0 if filter:

4BF+]S@8s0 valText = None51Testing软件测试网,R'r]&?#pT

filters = filter.split(";") 51Testing软件测试网-{(UM)@i,|s

match = False51Testing软件测试网C3H.E1M"O+d9m#Mv1v

for f in filters[:]:

8\r0Na5FoP4[7z i*Q0 atts = f.split("=")

^6_[?N9{0 if atts[0].lower() == "title":51Testing软件测试网3d)?m7cNx;W-X

valText = win32gui.GetWindowText(MsgboxHwnd)

JgV!o `bG*_0 if atts[0].lower() == "text":

~x`,Cm0 FirstStaticHwnd = win32gui.FindWindowEx(MsgboxHwnd,0,"Static",None)

%|Q7Zg/_+kN.v0 if win32gui.GetWindowText(FirstStaticHwnd):51Testing软件测试网Z)O\E'V-v

valText = win32gui.GetWindowText(FirstStaticHwnd)51Testing软件测试网ZrP k*q

else:

~S`i"w$o0 valText = win32gui.GetWindowText(win32gui.FindWindowEx(MsgboxHwnd,FirstStaticHwnd,"Static",None))51Testing软件测试网ZEh;vhNqN5v,|8p

if atts[0].lower() == "index" :

[e#@:DbI5?(oR[?0 MatchIndex=int(atts[1])51Testing软件测试网Cg,V2NlNK'A

if valText == None :

J%I){}0h`t+To0 match = True

:mWbdt

\@,{2W0 continue

M}+~eR(Ccn

U0 51Testing软件测试网 tVSHmG@t~$R(Ed

if valText != None:

E`1St9g)V"Sci0 valText = str(valText)51Testing软件测试网D$A#q$J)c,l

valText = valText.strip()51Testing软件测试网9S~G7]y

valText = valText.lower()51Testing软件测试网rDZ rk;@l0qE

wantText = atts[1].lower()

]/kOC"~ X.t,P0 if wantText[0] == "!":

7OBbmwOX0 val = wantText.replace( "!", "", 1)

_'Q \9U:|a%Ly0 myRE = re.compile(val)51Testing软件测试网fJJ]1mG/~B

m = myRE.match(valText)51Testing软件测试网3o8iPB&D kE"A

if m:

bJ&n;GY&gGrE0 match=True51Testing软件测试网+hx n1V!bc.}Y5OebY

else:51Testing软件测试网}+]|T*Q#OW

match=False51Testing软件测试网F2AY5ZE)v(v)Kq)j

break

|fDZ*rhiA"}0 elif valText == wantText :51Testing软件测试网9g8KH#O6srwQ8R0Ix7[?

match = True51Testing软件测试网6r,JP

LUzA(o

else:51Testing软件测试网2a1o-w0v6a$@0p

match = False51Testing软件测试网

B4F1z7DhA7e)x

break51Testing软件测试网h9Xy h@7O2H{r2h'G

else:

mknEkr$O3M;z0 return MsgboxHwnd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值