Jump to content

Confirmation Dialog Popup


deco
 Share

Recommended Posts

I'm running a program with a progress bar. After the progressbar closes, I close the program. At some time while the progressbar window is active however, a popup can appear that asks for confirmation. I want to send a key (!y for yes) to the confirmation dialog, IF it appears. How do I handle this? The code I have now is this:

WinWait("Converting files","")
If Not WinActive("Converting files","") Then WinActivate("Converting files","")
WinWaitActive("Converting files","")

; If already targets exist: overwrite? ==> code doesn't work so I commented it
;If Not WinActive("Confirm","") Then
;   WinActivate("Confirm","")
;   Send("!y"); or !n
;EndIf

; Waiting for conversion progressbar
If WinExists("Converting files","") Then WinWaitClose("Converting files","")

; Close application
Send("!fx")
Link to comment
Share on other sites

  • Moderators

Not quite sure I understand what your doing... but here's a stab, if it's wrong maybe it will give you an idea in the right direction:

Opt('WinTitleMatchMode', 2); << may need to be changed to suit your needs
Opt('WinSearchChildren', 1)

WinWait("Converting files","")
If Not WinActive("Converting files","") Then WinActivate("Converting files","")
WinWaitActive("Converting files","")

; Waiting for conversion progressbar
Local $Confirmed = 0
If WinExists("Converting files","") Then 
    While $Confirmed = 0
        Sleep(10)
        If WinExists('Confirm') Then
            If Not WinActive('Confirm') Then 
                WinActivate('Confirm')
                Send('!y')
                $Confirmed = 1
            EndIf
        EndIf
    WEnd
;Do whatever ending thing you need to to close Converting files like maybe Send('!fx')
EndIf

; Close application
Send("!fx")

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Not quite sure I understand what your doing... but here's a stab, if it's wrong maybe it will give you an idea in the right direction:

Opt('WinTitleMatchMode', 2); << may need to be changed to suit your needs
Opt('WinSearchChildren', 1)

WinWait("Converting files","")
If Not WinActive("Converting files","") Then WinActivate("Converting files","")
WinWaitActive("Converting files","")

; Waiting for conversion progressbar
Local $Confirmed = 0
If WinExists("Converting files","") Then 
    While $Confirmed = 0
        Sleep(10)
        If WinExists('Confirm') Then
            If Not WinActive('Confirm') Then 
                WinActivate('Confirm')
                Send('!y')
                $Confirmed = 1
            EndIf
        EndIf
    WEnd
;Do whatever ending thing you need to to close Converting files like maybe Send('!fx')
EndIf

; Close application
Send("!fx")
That piece of code looks interesting, although it stays in the loop forever if the confirmation dialog doesn't popup. So basically, there is no guarantee that the confirmation dialog will appear. I'm looking for a solution that allows me to send yes if the dialog appears and continue working if it doesn't appear.
Link to comment
Share on other sites

  • Moderators

The using the AutoInfo.exe Tool, hover your mouse over the finish button when it appears of Converting files, then replace &Finished and Button2 with the Text of the Control (under ClassNameNN) and the ClassNameNN (for button2), if either occurrence is true it will exit the loop, and you can do your command

Opt('WinTitleMatchMode', 2); << may need to be changed to suit your needs
Opt('WinSearchChildren', 1)

WinWait("Converting files","")
If Not WinActive("Converting files","") Then WinActivate("Converting files","")
WinWaitActive("Converting files","")

; Waiting for conversion progressbar
Local $Confirmed = 0
If WinExists("Converting files","") Then
    While $Confirmed = 0  Or Not ControlCommand('Converting files', '&Finished', 'Button2', 'IsVisible', '')
        Sleep(10)
        If WinExists('Confirm') Then
            If Not WinActive('Confirm') Then
                WinActivate('Confirm')
                Send('!y')
                $Confirmed = 1
            EndIf
        EndIf
    WEnd
;Do whatever ending thing you need to to close Converting files like maybe Send('!fx')
EndIf

; Close application
Send("!fx")

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

The using the AutoInfo.exe Tool, hover your mouse over the finish button when it appears of Converting files, then replace &Finished and Button2 with the Text of the Control (under ClassNameNN) and the ClassNameNN (for button2), if either occurrence is true it will exit the loop, and you can do your command

Opt('WinTitleMatchMode', 2); << may need to be changed to suit your needs
Opt('WinSearchChildren', 1)

WinWait("Converting files","")
If Not WinActive("Converting files","") Then WinActivate("Converting files","")
WinWaitActive("Converting files","")

; Waiting for conversion progressbar
Local $Confirmed = 0
If WinExists("Converting files","") Then
    While $Confirmed = 0  Or Not ControlCommand('Converting files', '&Finished', 'Button2', 'IsVisible', '')
        Sleep(10)
        If WinExists('Confirm') Then
            If Not WinActive('Confirm') Then
                WinActivate('Confirm')
                Send('!y')
                $Confirmed = 1
            EndIf
        EndIf
    WEnd
;Do whatever ending thing you need to to close Converting files like maybe Send('!fx')
EndIf

; Close application
Send("!fx")
I'm automating an existing program. The program converts DTD's to XSD's. If I press "convert", a progressbar pops up and when the conversion is finished, the progress bar goes away automatically. (so there is no "finished" button or anything like that :mellow: )

What I used to do was: winwaitclosed("Converting files") -> That's the progressbar window. If the window closed, I could easily proceed my script. But now, I try to catch an extra situation: confirmation to overwrite existing xsd's in the target directory.

Old situation:

"start program"

"start conversion"

*conversion window comes up

*conversion starts

*conversion window closes

"stop program"

new situation

"start program"

"start conversion"

*conversion window comes up

*conversion starts

**a confirmation window CAN come up

*conversion window closes

"stop program"

I hope it's clear now. :) If it still is quite abstract, please let me know.

Link to comment
Share on other sites

  • Moderators

Did you try the latest example? You are waiting for 1 of 2 things... 1 the Confirm and 2 even if Confirm doesn't show, if you get the Finished button it will then continue, either way, both bases are covered.

You can fill in the gaps in the loop with what you need, but it should take care of your issues.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Did you try the latest example? You are waiting for 1 of 2 things... 1 the Confirm and 2 even if Confirm doesn't show, if you get the Finished button it will then continue, either way, both bases are covered.

You can fill in the gaps in the loop with what you need, but it should take care of your issues.

Yes the last example looks fine, but there is no finished button... The conversion progress bar only has a cancel button. If the conversion stops, the window just disappears.

Is something like this possible? (pseudo language)

while progressbarwindow_exists
        sleep(10)
        if confirm_window_exists then send("!y")
endwhile
Link to comment
Share on other sites

  • Moderators

If the conversion progress bar has a title, you could use... While WinExists('Title')

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Hello,

I found out how to do it. This is the result:

; If targets already exist: overwrite? !y for yes / !n for no
While WinExists("Converting files","")
    Sleep(10)
    if WinExists("Confirm") Then
        If Not WinActive('Confirm') Then WinActivate('Confirm')
        Send('!y')
    EndIf
WEnd

Thanks a lot for your time and help :)

Edited by deco
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...