为什么ControlGetText返回为空(传入窗口句柄) [已解决]
本帖最后由 xiehuahere 于 2010-4-11 11:59 编辑代码如下,还请帮忙找找原因:Opt("WinDetectHiddenText", 1)
Opt("WinTitleMatchMode", 4)
$windowFound = False
$controlID = ""
$matchText = "欢迎画面"
$WinArr = WinList("")
For $i = 1 To $WinArr
$text = ControlGetText($WinArr[$i], "", $controlID)
ConsoleWrite($WinArr[$i] & ": " & $text & @LF) ;不知为什么这里输出的$text都是空,难道中文不行吗?
If ControlGetText($WinArr[$i], "", $controlID) = $matchText Then
$windowFound = True
ExitLoop
EndIf
Next
If $windowFound Then
MsgBox(0, "WinExists", "The target window does indeed exist.")
Else
MsgBox(0, "Not Found", ";-(")
EndIf多谢! 发现用数字ID可以获取到控件的Text,怪了。。。
$controlID = ""
可能正如帮助里说的,数字ID - “It is generally the best method of identifying controls.”
就用这个吧。
页:
[1]