xiehuahere 发表于 2011-8-12 16:05:10

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

本帖最后由 xiehuahere 于 2011-8-13 21:53 编辑

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

title是有高级匹配模式的,可以使用正则,text可以吗?
如果可以,求个例子。
谢谢!

yjw83523 发表于 2011-8-12 18:50:43

Run("notepad.exe")
WinWaitActive("")


If WinExists("") Then
    MsgBox(0, "", "记事本窗口存在")
EndIf
你看看这个对你有什么帮助呀

yjw83523 发表于 2011-8-12 18:51:40

Run("notepad.exe")
WinWaitActive("")


If WinExists("") Then
    MsgBox(0, "", "记事本窗口存在")
EndIf
你看看这个对你有什么帮助呀

xiehuahere 发表于 2011-8-12 19:10:54

楼上你好,
首先谢谢你的热心。
title的匹配我会,title的正则匹配我也用过,而且你这个也不是正则。
我问的是匹配一个窗口中的text时能否用正则?
有些窗口的text比较多、比较长,我只想匹配关键信息。

papapa314 发表于 2011-8-13 01:09:06

没有找到winexist所调用的api,所以没办法将该函数改成可以匹配正则表达式的的。

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

WinTitleMatchMode 更改窗口函数在执行搜索操作时的标题匹配模式.
1 = 只匹配标题的前面部分(默认)
2 = 标题的任意子串皆可匹配
3 = 完全匹配标题
4 = 高级模式,详情请查看 窗口标题与文本(高级)
-1 到 -4 = 强制小写匹配.

runtium 发表于 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("")

steven_z 发表于 2011-8-13 09:51:15

学习了,谢谢!

xiehuahere 发表于 2011-8-13 21:00:50

晕倒,难道我的提问不清楚?
WinExists( "title"[,"text"] )
窗口标题,即title很简单,不用正则。我要用正则匹配的是第二个参数text。
比如,title就是软件的名称,text是出错描述(可以有多种),如获取不到license。我需要判断的是text内容。

xiehuahere 发表于 2011-8-17 20:29:10

算了,奔官网提问

cheng8457 发表于 2011-8-18 06:27:06

學習了 謝謝分享
页: [1]
查看完整版本: WinExists 函数的第二个参数 text 可以使用正则表达式吗?