找回密码
 加入
搜索
查看: 3453|回复: 9

[AU3基础] WinExists 函数的第二个参数 text 可以使用正则表达式吗?

  [复制链接]
发表于 2011-8-12 16:05:10 | 显示全部楼层 |阅读模式
本帖最后由 xiehuahere 于 2011-8-13 21:53 编辑

WinExists( "title"[,"text"] )

title是有高级匹配模式的,可以使用正则,text可以吗?
如果可以,求个例子。
谢谢!
发表于 2011-8-12 18:50:43 | 显示全部楼层
Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]")


If WinExists("[CLASS:Notepad]") Then
    MsgBox(0, "", "记事本窗口存在")
EndIf
你看看这个对你有什么帮助呀
发表于 2011-8-12 18:51:40 | 显示全部楼层
Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]")


If WinExists("[CLASS:Notepad]") Then
    MsgBox(0, "", "记事本窗口存在")
EndIf
你看看这个对你有什么帮助呀
 楼主| 发表于 2011-8-12 19:10:54 | 显示全部楼层
楼上你好,
首先谢谢你的热心。
title的匹配我会,title的正则匹配我也用过,而且你这个也不是正则。
我问的是匹配一个窗口中的text时能否用正则?
有些窗口的text比较多、比较长,我只想匹配关键信息。
发表于 2011-8-13 01:09:06 | 显示全部楼层
没有找到winexist所调用的api,所以没办法将该函数改成可以匹配正则表达式的的。

只能退而求其次了,opt("WinTitleMatchMode",2)

WinTitleMatchMode 更改窗口函数在执行搜索操作时的标题匹配模式.
1 = 只匹配标题的前面部分(默认)
2 = 标题的任意子串皆可匹配
3 = 完全匹配标题
4 = 高级模式,详情请查看 窗口标题与文本(高级)
-1 到 -4 = 强制小写匹配.
发表于 2011-8-13 09:29:35 | 显示全部楼层
希望有帮助:)
TITLE - Window title
CLASS - The internal window classname
REGEXPTITLE - Window title using a regular expression (if the regular expression is wrong @error will be set to 2)
REGEXPCLASS - Window classname using a regular expression (if the regular expression is wrong @error will be set to 2)
LAST - Last window used in a previous AutoIt command
ACTIVE - Currently active window
X \ Y \ W \ H - The position and size of a window
INSTANCE - The 1-based instance when all given properties match

eg:List windows matching a classname defined by a regular expression
WinList("[REGEXPCLASS:#\d+]")
发表于 2011-8-13 09:51:15 | 显示全部楼层
学习了,谢谢!
 楼主| 发表于 2011-8-13 21:00:50 | 显示全部楼层
晕倒,难道我的提问不清楚?
WinExists( "title"[,"text"] )
窗口标题,即title很简单,不用正则。我要用正则匹配的是第二个参数text。
比如,title就是软件的名称,text是出错描述(可以有多种),如获取不到license。我需要判断的是text内容。
 楼主| 发表于 2011-8-17 20:29:10 | 显示全部楼层
算了,奔官网提问
发表于 2011-8-18 06:27:06 | 显示全部楼层
學習了 謝謝分享
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 05:20 , Processed in 0.077581 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表