columbia100 Posted September 11, 2010 Posted September 11, 2010 Hello! I want to automate the pressing of buttons in the script. I've run html page on it, I do click on the link - the generation of the price list. After generating matches IE gives me a message: </ body> </ html> <script LANGUAGE='Javascript' TYPE='text/javascript'> alert ('price list is formed and is available for download on the link at the bottom of the page . ') </ SCRIPT> The question, as I click "OK" button on this message? I tried to use WinWait ("Message from webpage") - does not work. Sorry for my English.
Synct Posted September 11, 2010 Posted September 11, 2010 PixelSearch() might work for detecting the OK button when it appears, (Credit to maqleod) Otherwise you can set a delay to wait (however long it usually takes to show the message plus a couple seconds) Sleep(x) might work for that method.
wakillon Posted September 11, 2010 Posted September 11, 2010 See my postIt was the same case, i wait for a message with ok... AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
columbia100 Posted September 11, 2010 Author Posted September 11, 2010 write: WinWait ('Message from webpage', 'OK') ControlClick ('Message from webpage', 'OK', 'Button1') window appears and does not want is pressed
wakillon Posted September 11, 2010 Posted September 11, 2010 (edited) Try WinWait ('Message from webpage', 'OK') WinActivate ('Message from webpage', 'OK') ControlClick ('Message from webpage', 'OK', 'Button1') Edited September 11, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
columbia100 Posted September 11, 2010 Author Posted September 11, 2010 Thank you. but not completely working. ie 1. open html page 2. pressed the inactive link - go process tseneratsii price list and the message 'Message from webpage' then the script should close the window - it does not work. but if 1. open html page 2. mouse click on the link of generation price list you will get the message 'Message from webpage' and then hit the 'OK' tried to insert sleep - does not help
Synct Posted September 11, 2010 Posted September 11, 2010 Thank you. but not completely working. ie1. open html page2. pressed the inactive link - go process tseneratsii price list and the message 'Message from webpage'then the script should close the window - it does not work.but if1. open html page2. mouse click on the link of generation price list you will get the message 'Message from webpage' and then hit the 'OK'tried to insert sleep - does not helpUse sleep to wait for the messagebox (you need to guess how long it will take, then have mouse click at position which you specify by coordinates, for instanceSleep(5000)MouseClick("left",451,274)Its not as convenient as having the program find the OK button and select it but it is sometimes the only way to make autoit work with java or flash environments. The main downside is if the window isnt full screen or is on a different resolution you will need to change the coordinates to work correctly.Hope this helped or at least gave you an idea on where to go next -Synct
abhayc Posted September 14, 2010 Posted September 14, 2010 (edited) I wrote a daemon script that checks every 1 sec if there is a Javascript Alert with a certain message .. Do WinWait("Microsoft Internet Explorer", "test on the popup") ControlClick("Microsoft Internet Explorer", "OK??", "[CLASS:Button; TEXT:OK; Instance:1;]") Sleep(1000) Until 1=2 Compile this script to exe and execute on the machine where you are running your main script .. may not be a real clean solution, but atleast worked for me. Cheers. Edited September 14, 2010 by abhayc
ConsultingJoe Posted November 8, 2010 Posted November 8, 2010 The best way to do this is to get control of the browser then get control of the dom, then you can edit the javascript in the page and just remove the alert("..."); But what ever works I wrote a daemon script that checks every 1 sec if there is a Javascript Alert with a certain message .. Do WinWait("Microsoft Internet Explorer", "test on the popup") ControlClick("Microsoft Internet Explorer", "OK??", "[CLASS:Button; TEXT:OK; Instance:1;]") Sleep(1000) Until 1=2 Compile this script to exe and execute on the machine where you are running your main script .. may not be a real clean solution, but atleast worked for me. Cheers. Check out ConsultingJoe.com
bqp2 Posted November 16, 2010 Posted November 16, 2010 I wrote a daemon script that checks every 1 sec if there is a Javascript Alert with a certain message .. Do WinWait("Microsoft Internet Explorer", "test on the popup") ControlClick("Microsoft Internet Explorer", "OK??", "[CLASS:Button; TEXT:OK; Instance:1;]") Sleep(1000) Until 1=2 Compile this script to exe and execute on the machine where you are running your main script .. may not be a real clean solution, but atleast worked for me. Cheers. Now would i put this at the beginning of the script and it will search threw enire scripts proccess or after the page you know loads it?
wakillon Posted November 16, 2010 Posted November 16, 2010 (edited) Now would i put this at the beginning of the script and it will search threw enire scripts proccess or after the page you know loads it? Instead of use another script you could try like this AdlibRegister ( '_CloseJavascriptAlert', 1000 ) ; your script... Func _CloseJavascriptAlert ( ) If WinExists("Microsoft Internet Explorer", "test on the popup") Then _ ControlClick("Microsoft Internet Explorer", "OK??", "[CLASS:Button; TEXT:OK; Instance:1;]") EndFunc Edited November 16, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
bqp2 Posted November 16, 2010 Posted November 16, 2010 Instead of use another script you could try like this AdlibRegister ( '_CloseJavascriptAlert', 1000 ) ; your script... Func _CloseJavascriptAlert ( ) If WinExists("Microsoft Internet Explorer", "test on the popup") Then _ ControlClick("Microsoft Internet Explorer", "OK??", "[CLASS:Button; TEXT:OK; Instance:1;]") EndFunc Awesome you people are to smart, One question how bad will this one sec search slow script down?
wakillon Posted November 16, 2010 Posted November 16, 2010 Awesome you people are to smart,One question how bad will this one sec search slow script down?Default is 250 ms so with 1000 it should not slow down the script...See the help file for AdlibRegister function for more details. AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now