Jump to content

Action taken when button is pressed from external click


Recommended Posts

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

Link to comment
Share on other sites

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

Or I misunderstood the post?

My stuff

Spoiler

My UDFs  _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS ·  storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Moderators

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

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!

Link to comment
Share on other sites

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

Spoiler

My UDFs  _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS ·  storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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