Jump to content

How to click Yes button in Alert Warning Window


Recommended Posts

I tried to use controlclick to click "Yes" button in an Alert Warning window, code is like:

WinWait("Security Warning");

WinActivate("Security Warning");

ControlClick("Security Warning", "","Yes");

what's weird is it cannot work for Yes button, but work well for No button...if change code as:

WinWait("Security Warning");

WinActivate("Security Warning");

ControlClick("Security Warning", "","No");

and I also tried ControlClick("Security Warning", "","[CLASS:Button; INSTANCE:1]");//Yes button is the first button in the alert window

but still cannot work successfully to click Yes button.

Do anyone know the reason why??

Link to comment
Share on other sites

What are the contents of the window info tool?

i don't know whether you mean ie develop tool bar as you mentioned window info tool, but it cannot work when there is popup alert window, when i tried to use the tool, always ask me to click alert window first

Edited by candyania
Link to comment
Share on other sites

To display a picture you first need to upload it to an image host.

For example http://photobucket.com/

there are many more, can you not just paste the text of the summary?

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I have checked the button with window info tool, and the Yes button is instance:2, so i modified code as:

ControlClick("Security Warning", "","[CLASS:Button; INSTANCE:2]");

However, i can see the focus moved to Yes button, but seems there is no Click action...don't understand why

Info grabbed by tool show as:

Class Button

Instance 2

ClassnameNN Button2

Advanced Mode [CLASS:Button; INSTANCE:2]

ID 1

Text Yes

Link to comment
Share on other sites

I have checked the button with window info tool, and the Yes button is instance:2, so i modified code as:

ControlClick("Security Warning", "","[CLASS:Button; INSTANCE:2]");

However, i can see the focus moved to Yes button, but seems there is no Click action...don't understand why

Info grabbed by tool show as:

Class Button

Instance 2

ClassnameNN Button2

Advanced Mode [CLASS:Button; INSTANCE:2]

ID 1

Text Yes

More info of this button:

Advanced Mode [CLASS:Button; INSTANCE:2]

ID 1

Text Yes

Position 215,96

I tried to locate the Yes button by adding x, y like:

ControlClick("Security Warning", "","[CLASS:Button; INSTANCE:2]",,215,96);

but seems the format is not correct, function reference for controlclick is like:

ControlClick("title","text",controlID [, button [, clicks [, x[, y]]]])

do anyone know how to resolve this?

Edited by candyania
Link to comment
Share on other sites

This looks like IE security window.

You can configure IE to not display such warnings.

Put the original site in the trusted zone - this may solve your issue.

I do add the site into my trust list, but still the warning msg will popup.

Link to comment
Share on other sites

  • 3 months later...

I have a similar issue.

Here is my code:

ShellExecuteWait("folder\file.reg")
    WinWait("[Class:#32770]")
    WinActivate("[Class:#32770]")
    ControlClick("[Class:#32770]", "","[CLASS:Button; INSTANCE:1]");

I also tried with the name of the window - "Registry editor" instead of the class, but still nothing happens.

What I'm trying to do:

-Use ShellExecuteWait in order to run a reg file - this works fine

-When the Registry Editor confirmation window appears "Are you sure you want to add the information .... into the registry" I want to click on the Yes Button, but using the above code has no results.

Link to comment
Share on other sites

Usually with the security warnings I've found that the program that launched it cannot click the buttons - So I just create a simple While...WEnd loop in another script compile it and call it before that security warning appears. Its not the best solution but it works.

Edit:

And for John H - Change ShellExecuteWait to just ShellExecute - The msgbox is still considered part of the program you told it to run so AutoIT won't continue until the MsgBoxs are gone.

Edited by LurchMan

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Link to comment
Share on other sites

Hey LurchMan,

Thanks for the tip.

It's working fine now.

For future reference as well, Don't piggy back on a topic with your issue - they weren't quite the same. Just create a new post next time.

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Link to comment
Share on other sites

  • 3 years later...

Hi John,

I am very new to Autoit. I was having a problem(see the attachment) while handling the java security warning popup window but it is fixed now using the below code.

 
JavaSecurityWarning.png?part=4&view=1&vt
I am able to click on Allow button using the below code. 
ShellExecuteWait("folder\file.reg")
    WinWait("[Class:#32770]")
    WinActivate("[Class:#32770]")
    ControlClick("[Class:#32770]", "","[CLASS:Button; INSTANCE:1]"); 

 But my question is : I want to verify whether that warning popup window is coming or not in the page using "if" condition. If it will come then only i will click on Allow otherwise no need to click on simply ignore. Can anyone please suggest me How to accomplish this?

With Best Regards,

Sudhansu.

 
 
 
Link to comment
Share on other sites

Welcome to AutoIt and the forum!

This thread is more than 3 years old and the user hasn't been active for 2 1/2 years.

So I suggest not to necro such an old thread but to open a new one ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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