Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

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

Posted

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

Use 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 instance

Sleep(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

Posted (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 by abhayc
  • 1 month later...
Posted

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
Posted

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?

Posted (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 Posted Image

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 by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Posted

Instead of use another script you could try like this Posted Image

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?

Posted

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.0WIN 8.1 X64 - Other Example Scripts

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
  • Recently Browsing   0 members

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