【发布时间】:2020-03-19 12:42:36
【问题描述】:
我的要求是使用 AutoIt 自动化 SAP 流程。当我尝试从用户名文本框下方获取值(测试)时,它没有获取文本框值并显示空值。我想从文本框中获取值,我需要与字符串进行比较。你能帮帮我吗?
输出:
我已经参考了以下链接:
- https://www.autoitscript.com/autoit3/docs/functions/ControlGetText.html
- https://www.autoitscript.com/forum/topic/177533-get-text-from-a-button/
- https://www.autoitscript.com/forum/topic/116065-get-text-from-active-window/
AutoIt finder 工具截图:
我的 AutoIt 代码:
Run("C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe")
Local $hWnd = WinWaitActive("SAP Logon 740")
WinSetState($hWnd, "", @SW_MAXIMIZE)
ControlFocus("SAP Logon 740","","SAPTreeList1")
ControlTreeView("SAP Logon 740","","[CLASS:SAPTreeList; INSTANCE:1]","Expand","#0")
ControlClick("SAP Logon 740","","[CLASS:SAPTreeList; INSTANCE:1]","left",2,47,60)
Sleep(2000)
ControlClick("SAP Logon 740","","[CLASS:SAPTreeList; INSTANCE:1]","left",2,59,115)
Sleep(2000)
ControlClick("SAP Logon 740","","[CLASS:SysListView32; INSTANCE:1]","left",1,71,573)
Sleep(1000)
ControlClick("SAP Logon 740","","Log &On")
Sleep(3000)
Local $hNewWnd = WinWaitActive("SAP")
; Retrieve the classlist of the Notepad window using the handle returned by WinWait.
Local $sClassList = WinGetClassList("SAP")
#ConsoleWrite($sClassList)
; Display the classlist.
Sleep(3000)
ControlClick("SAP","","","left",1,179,56)
# MsgBox(0, "output", $sClassList)
Send("test")
Sleep(1000)
$wrd = ControlGetText("SAP","test","")
MsgBox(0,"Display",$wrd)
控制标签:
【问题讨论】:
-
你错了。当您关注该用户名编辑框时,显示窗口信息工具中的“控制”选项卡。
-
感谢@Milos 的评论。请找到“控制选项卡”的屏幕截图。类:Afx:68570000:1008 实例:1 类名NN:Afx:68570000:10081 名称:高级(类):[类别:Afx:68570000:1008;实例:1] ID:100 文本:位置:0、104 大小:1510、653 ControlClick 坐标:192、56 样式:0x56000000 ExStyle:0x00000010 句柄:0x00020256