【问题标题】:Getting value from text box in SAP application custom container从 SAP 应用程序自定义容器中的文本框中获取值
【发布时间】:2020-03-19 12:42:36
【问题描述】:

我的要求是使用 AutoIt 自动化 SAP 流程。当我尝试从用户名文本框下方获取值(测试)时,它没有获取文本框值并显示空值。我想从文本框中获取值,我需要与字符串进行比较。你能帮帮我吗?

输出:

我已经参考了以下链接:

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

标签: sap autoit


【解决方案1】:

请阅读thisthis

#RequireAdmin ;sometimes this is required in order to be able to manipulate windows
Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also

$wrd = ControlGetText("[TITLE:SAP]","",100);100 is id from the WindowInfo Tool
If @error Then $wrd = ControlGetText("[TITLE:SAP]","","[CLASS:Afx:68570000:1008; INSTANCE: 1]")
;This is the advanced method. Aslo shown in the WIndowInfo Tool.
MsgBox(0,"Display",$wrd)

【讨论】:

  • 谢谢@Milos。我尝试了上面的代码,但仍然无法恢复测试值。您能否解释一下上面的代码与从 SAP 客户容器中的文本字段中获取值有何关系? ..... AutoIT v3 Window Info 选项不关注特定领域,而是关注框架.. 你能帮我们提供更多细节吗.. 请参考我上面的代码
猜你喜欢
  • 2017-06-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-26
  • 2012-12-14
  • 1970-01-01
相关资源
最近更新 更多