Sign in to follow this  
Followers 0
KlemsonGuy

Auto Click on IE Alert Window

7 posts in this topic

I'm writing a script that will go through an Internet Explorer web page, and when you click on a particular button, a message alert box comes up. Is there a way to make it automatically click OK without using the MouseClick command? I was hoping for some way to intergrate the IE.au3 UDF's into this. Does anyone know of a way?

Share this post


Link to post
Share on other sites



try...

Send("{ENTER}")

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ha... would that it were that easy. I may be new to this, but I'm not that new. :o Yeah, I've tried that, and I also tried putting a delay before it (just in case I was sending the enter command before the message actually popped up), and it still didn't work. Any other advice?

try...

Send("{ENTER}")

8)

Edited by KlemsonGuy

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

IE.au3 to the rescue!!!

see Dale Hohm's IE.au3 Library ( its really good )

then get my IE.au3 Builder ( in my sig )

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Well, that's just it, I have both, and don't get me wrong, they work great, but I just can't figure out how to interface with a javascript alert. Do you know of a way using IE.au3?

Share this post


Link to post
Share on other sites

Two methods I've used:

#1 You CAN use Send() to close these, the trick is you have to send the window a TAB first.

If WinExists("Microsoft Internet Explorer", "") Then
  WinActivate("Microsoft Internet Explorer", "")
  Send("{TAB}{ENTER}")
Endif

#2 Sometimes (depending on the webpage) you can just bypass the javascript code popping it up in the first place. Don't forget you can actually modify the javascript of a webpage on the fly with this! Feel the power!!

Say there is some special code in the onclick event for an image link, part of the code is what pops up the alert box. You can just write your own code and substitute it!! A lot of sites it is very easy to do malicious things because they trust no one is going to monkey with their javascript. Not sure how much longer that will last...

; replace their javascript code with my own! tricky!
  $img.parentNode.setAttribute("onclick", "return 1")

Share this post


Link to post
Share on other sites

I agree with everything stated so far. I will add however that a Javascript alert may actually cause your AutoIt script to stall until the alert is processed. In this case you actually need to use the SEND command to generate a keystroke that performs the action htat results in the alert box appearing... your script can then continue to run and you are free to process the alert with other AutoIt code.

There is an example of this in reply 3 (the examples reply) of the IE.au3 thread.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
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
Sign in to follow this  
Followers 0