【问题标题】:Clicking OK in a dialog box在对话框中单击确定
【发布时间】:2018-02-24 19:21:02
【问题描述】:

Windows 10 启动后我正在运行一个程序,它给了我附加的对话框。我需要做的就是自动单击“确定”按钮。我编写的脚本不起作用:

WinActivate("RoomView Express Login")

If WinActivate("RoomView Express Login") Then
   ControlClick("RoomView Express Login", "", "[CLASS:Button; INSTANCE:3]")
EndIf

如何正确地做到这一点?我已经附上了按钮的 AutoIt Window Info。

【问题讨论】:

    标签: user-interface button automation windows-10 autoit


    【解决方案1】:

    到目前为止,我编写的脚本无法正常工作……

    可能在目标窗口出现之前执行。根据Documentation - Function Reference - WinWait()

    暂停脚本的执行,直到请求的窗口存在。

    还返回一个句柄。示例:

    Global Const $g_iTimeout  = 0
    Global Const $g_sWndTitle = 'RoomView Express Login'
    Global Const $g_sWndText  = ''
    Global Const $g_sControl  = '[CLASS:Button; INSTANCE:3]'
    
    Global       $g_hWnd      = WinWait($g_sWndTitle, $g_sWndText, $g_iTimeout)
    Global       $g_hCtrl     = ControlGetHandle($g_hWnd, $g_sWndText, $g_sControl); Or ControlGetHandle($g_sWndTitle, $g_sWndText, $g_sControl)
    
    ControlClick($g_hWnd, $g_sWndText, $g_hCtrl); Or ControlClick($g_sWndTitle, $g_sWndText, $g_sControl)
    

    Documentation - Function Reference - ControlClick().

    【讨论】:

      【解决方案2】:
      While Not WinExists("RoomView Express Login")
         Sleep(50)
      WEnd
      
      If WinActivate("RoomView Express Login") Then
         ControlClick("RoomView Express Login", "", "[CLASS:Button; INSTANCE:3]")
      EndIf
      

      这将是我的解决方案

      【讨论】:

        猜你喜欢
        • 2012-01-24
        • 2015-10-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-12-17
        • 1970-01-01
        相关资源
        最近更新 更多