注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

chunwaihome 的博客

 
 
 

日志

 
 

Window Titles and Text (Advanced)  

2010-02-17 19:26:44|  分类: AutoIt |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

 

AutoIt operates in one of four "Window matching"(窗口匹配) modes.  The modes are set with the AutoItSetOption function using the WinTitleMatchMode option.

 Powerpro以萬字元來定義AutoIt的Mode1和Mode2的

  • Mode 1 (default)

Matches partial titles from the start.       (只匹配标题的前面部分)

In this mode the a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Un", etc. 

eg.  WinWait("Untitled")

 

  • Mode 2

Matches any substring in the title.      ( 标题的任意子串皆可)

In this mode a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Notepad", "pad", etc.

eg. WinWait("Notepad")

 

  • Mode 3

Exact title match.

In this mode a window titled Untitled - Notepad would only be matched by "Untitled - Notepad"

 

  • Mode 4   (Advanced mode)

In this mode special sequences(特殊的字符串) are used in the title parameter so that window classnames(类别名) and handles(句柄) can be used.  The text parameter remains the same.

The special sequences must contain no whitespace (这些特殊的字符串不能含有空白符(whitespace,一般指空格、制表符、回车等))

    "classname=CLASSNAME"                       Powerpro是C=ClassName

 "classname=" matches a window based on its classname. 

$size = wingetpos("classname=notepad")
msgbox(0,"",$size[0])

"active"

matches the currently active window (same as "" in the default WinTitleMatchMode).

"last"                          Powerpro沒有此功能

uses the last successful window match so you don't have to keep specifying the title and text again and again. e.g.

    AutoItSetOption("WinTitleMatchMode", 4)

    WinWaitActive("Untitled - Notepad")

    WinClose("last")    ; Closes the previously matched notepad window

Note: If "classname=", "active", "last" or "" are not used as the title then the window matching takes place as in Mode 1 making this a good mode for general use.

 

  • Window Handles / HWNDs

A window handle is a special value that windows assigns to a window each time it is created.

The advantage of using window handles is that if you have multiple copies of an application open - which have the same title/text - you can uniquely identify them when using handles. When you use a window handle for the title parameter then the text parameter is completely ignored.

Various functions such as WinGetHandle, WinList and GUICreate return these handles.

 It is important to note that a window handle is not classed as a number or string - it is it's own special type.

 Note: Window handles will work no matter what WinTitleMatchMode is currently in use.

 Example

$handle = WinGetHandle("Untitled - Notepad", "")

WinClose($handle)

 

  评论这张
 
阅读(458)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017