Jump to content
Sign in to follow this  
Phaser

Interacting with IE

Recommended Posts

Phaser

Hi everyone, total nubee here sadly, I have been looking at automating a data entry system we use each day, the page has a button that needs pressing etc. So I decided to use googs page as my test to setup a script that will do what I want and learn at the same time, after reading and trying for the last week or so I have sort of got it working but it has a few issues.

I want to find the browser window and the button to push, heres my code so far (very basic)

#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("Update tool", 260, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "killit")
GUICtrlCreateLabel("Do you want to start the updating?", 30, 10)
$okbutton = GUICtrlCreateButton("Yes", 70, 50, 60)
GUICtrlSetOnEvent($okbutton, "goforit")
$cancelbutton = GUICtrlCreateButton("Cancel", 140, 50, 60)
GUICtrlSetOnEvent($cancelbutton, "killit")
GUISetState(@SW_SHOW)

While 1
  Sleep(1000)
WEnd

Func goforit()
    While 1
        Sleep(3000)
        ;ControlClick("Google - Windows Internet Explorer", "", "[class:submit; text:I'm Feeling Lucky]")
        MouseClick("left", 1000, 356)
        Sleep(3000)
        MouseClick("left", 550, 220)
    WEnd
EndFunc

Func killit()
    Exit
    EndFunc

As you can see the mouse coordinates are entered manually which means the browser MUST be the same size and position on the screen, not good, so I was trying to use controlclick but it doesn't find the window, thats the second problem, first problem is the while loop goforit() I need to stop the process when Cancel is clicked currently it doesn't stop after it has started as it cant get out of the loop.

Am I on the right track?

How do I break the loop?

How do I get controlclick to work for the above?

Thanks in advance to anyone who helps

Share this post


Link to post
Share on other sites
Crystall

Hello.

Have you searched in the help file?

Please see the _IEFormGetCollection function, it have an example you need.

To break the loop, use ExitLoop functionality.

Edited by Crystall

Hello World!

Share this post


Link to post
Share on other sites
Phaser

Hi crystall thanks for the reply

so in my while loop could I just add

if $cancelbutton pressed then exitloop

what value does $cancelbutton pass?

Edited by Phaser

Share this post


Link to post
Share on other sites
Crystall

I'm sorry, but may you explain, what you need of "While" loop?

I have been looking at automating a data entry system we use each day, the page has a button that needs pressing etc.

If you have a one button, the loop doesn't need.

Edited by Crystall

Hello World!

Share this post


Link to post
Share on other sites
Phaser

I have 2 buttons OK and Cancel

if I push OK it starts doing whats in the loop, if I press cancel while its running I want it to stop/exit/die/kill the mouseclicking in the while loop

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.