Jump to content

JavaScript how click - OK


 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 1 month later...

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.

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

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