Hello Jefrey,
Thanks for update. I want to call exit if the button is pressed by user. How do i detect if button is clicked.
There are two buttons Login and cancel,
If login is pressed it should proceed to resolve the upcoming popup
If cancel is pressed then the application will terminate but i want to terminate the script along with it.
I do not know how to take action if the cancel button is pressed.
Please find the below snip of code
#include <Misc.au3>
$g_szVersion = "Scriptname"
If WinExists($g_szVersion) Then Exit ; It's already running
AutoItWinSetTitle($g_szVersion)
Run("C:\Program Files\Subex Limited\Optima v4.6\Optima.exe","")
WinWait("Popup Window1")
WinActivate("Popup Window1")
;To provide password to the client
;send("{LEFT}")
;Send("{ENTER}")
;Click on the Login Button
;If WinExists ("Component not registered") Then
; ControlSend("Component not registered", "", "[CLASS:Scintilla; INSTANCE:1]", "{ENTER}")
;EndIf
If WinWaitActive("Popup Window1") Then ; you know it is going to appear
ControlSend("Popup Window1", "", "[CLASS:Button; INSTANCE:1]", "{ENTER}") ; you can add TEXT: there too.
Send("{ENTER}")
EndIf
If WinWaitActive(" Login") Then ; you know it is going to appear
$dll = DllOpen("user32.dll")
While 1
sleep(10)
If _IsPressed("01", $dll) Then;Here i have detect when the cancel button is pressed.
Consolewrite('Pressed' & @CRLF)
Exit
EndIf
WEnd
DllClose($dll)
EndIf
;Send("{ENTER}")
If WinWaitActive("Popup window2") Then ; you know it is going to appear
ControlClick("Popup window2","", "[CLASS:WindowsForms10.BUTTON.app.0.378734a; INSTANCE:1]","left",1)
ElseIf
Exit
EndIf