Jump to content

Recommended Posts

Posted

Hello All,

I am beginner in AutoIt, I am trying to make a script to handle 2 popup in application. In the script it will handle the first popup with ease 

Then the user logs in in using his credentials  and presses on the login, he will be able to login 

After the login the nextpopup will be handled by script.

 

The problem is that I have made script in such a way so as only for one instance if script will be running. If the cancel button in the login is pressed then the application will exit but still the script will be running in background, 

It would be very helpful if someone helps me with logic wherein the script should exit if the cancel button is pressed.

 

Thanks In Advance

Posted

Can't you call "Exit" in order to close the entire application closes?

Or I misunderstood the post?

My stuff

  Reveal hidden contents

 

Posted

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

 

 

Untitled.png

Posted

Hello All,

I am beginner in AutoIt, I am trying to make a script to handle 2 popup in application. In the script it will handle the first popup with ease 

Then the user logs in in using his credentials  and presses on the login, he will be able to login 

After the login the nextpopup will be handled by script.

 

The problem is that I have made script in such a way so as only for one instance if script will be running. If the cancel button in the login is pressed then the application will exit but still the script will be running in background, 

It would be very helpful if someone helps me with logic wherein the script should exit if the cancel button is pressed.

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}")

Thanks in Advance.

Untitled.png

  • Moderators
Posted

Not sure why every new person posts in the DEV forum, despite the very clear statement at the top

  Quote

Do not create AutoIt-related topics here, use AutoIt General Help and Support

Expand  

Moved to the correct forum.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

Is the window managed by other application?

If yes, does that windows close once the user clicks "Cancel"?

If so, you could check again if the window still exists with WinExists().

Part of automation work is done by watching for concurrent events that happens on each context. In other words: if you can't detect whether a button has been clicked, you probably can detect it indirectly by checking if the event that is bound to the button click has been fired.

My stuff

  Reveal hidden contents

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...