我有一个UI应用程序作为Windows服务运行,我想用AutoIt来控制它。我能够获得UI窗口的句柄,并使用WinGetHandle的WinGetHandle &命令将其激活。但我无法控制组合框和按钮。我使用下面的脚本来完成预定的任务:如何使用AutoIt控制作为Windows服务运行的UI应用程序?
Local $hWnd1 = WinGetHandle ("UI Window", "") ;to get the handle of the UI
WinActivate($hWnd1) ;to make it active
Sleep(2000)
ControlCommand($hWnd1, "", "ComboBox1", "ShowDropDown", "") ;to show the dropdown of Combo box
Sleep(3000)
ControlCommand($hWnd1, "", "ComboBox1", "SelectString", 'CollegeName') ;to select the string from dropdown list
Sleep(2000)
ControlCommand($hWnd1, "", "ComboBox1", "HideDropDown", "") ;to hide the dropdown of Combo box
Sleep(1000)
ControlClick($hWnd1, "", "[CLASS:Button; TEXT:Submit; INSTANCE:1]") ;to click on 'Submit' button
Sleep(2000)
此代码只是把激活窗口和之后的某个时间里什么也不做退出出来的方案。这个问题是否发生,因为它是作为Windows服务运行的?如果是这样,我怎么能发送命令到我的UI控件?请尽快帮助我。 PS:AutoIt Window Info能够识别UI的每一个控件(包括ComboBox &按钮)。我不想将我的脚本作为Windows服务运行。
'ControlClick( “标题”, “文本” 玩,控件ID [,按钮= “左”[,点击= 1,X [ ,y]]]])' –