-1

I'm running a program after Windows 10 starts up and it gives me the dialog box attached. All I need to do is automate clicking the OK button. The script I've written isn't working :

WinActivate("RoomView Express Login")

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

How to correctly do this? I've attached AutoIt Window Info of the button.

user4157124
  • 2,809
  • 13
  • 27
  • 42
greyBow
  • 1,298
  • 3
  • 28
  • 62

2 Answers2

0

The script I've written isn't working so far …

Executes before targeted window's appearance possibly. As per Documentation - Function Reference - WinWait() :

Pauses execution of the script until the requested window exists.

Also returns a handle. Example:

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().

user4157124
  • 2,809
  • 13
  • 27
  • 42
0
While Not WinExists("RoomView Express Login")
   Sleep(50)
WEnd

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

this would be my solution