- sub click(win,subwin,s,c)
- dim BM_CLICK,h,api,hwnd,save_win,bh
- set api=CreateObject("VBScript.API")
- with api
- h=.FindWindow (vbNullString,win):BM_CLICK=&HF5
- save_win=.GetForegroundWindow
- for each Hwnd in .EnumSubHwnd(h,"*button*",subwin):bh=hwnd:next
- do
- if .isWindow(bh)=0 then _
- exit do
- if .GetForegroundWindow<>bh then _
- .SetForegroundWindow h
- count=count+1
- .sendmessage bh,BM_CLICK ,0,0
- wsh.sleep int(s&"E+3")
- loop while count<c
- .SetForegroundWindow save_win
- end with
- set api=nothing
- end sub
-
- call click("window","确定",1,1000) '调用过程click 1秒执行一次,持续1000次
复制代码
|