从 AutoIT 验证 windows 应用程序上的文本

Verify for text on windows application from AutoIT

我有一个使用 AutoIT 工具自动化的 Windows 应用程序。 我已经完成了脚本编写,现在我需要一个命令来验证应用程序上的特定文本?

例如:我打开应用程序, 然后我执行一些任务。 一旦任务完成,应用程序屏幕上就会显示成功。 我想验证任务完成时是否显示成功。

请告诉我如何通过 AutoIT 完成此操作

这在很大程度上取决于应用程序的设计方式。对于大多数基于 windows 的 uis,您可以使用 autoit window 信息工具来检查元素,然后使用该信息,使用

获取控件的文本或值

controlGetText [1]

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Set the edit control in Notepad with some text. The handle returned by WinWait is used for the "title" parameter of ControlSetText.
    ControlSetText($hWnd, "", "Edit1", "This is some text")

    ; Retrieve the text of the edit control in Notepad. The handle returned by WinWait is used for the "title" parameter of ControlGetText.
    Local $sText = ControlGetText($hWnd, "", "Edit1")

    ; Display the text of the edit control.
    MsgBox($MB_SYSTEMMODAL, "", "The text in Edit1 is: " & $sText)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example

从这里开始,如果您需要更多帮助,请告诉我!

[1] https://www.autoitscript.com/autoit3/docs/functions/ControlGetText.htm