Jump to content

Automate Webpage inside AutoIt GUI Advice


 Share

Recommended Posts

Hi everyone,

I'm hoping someone can offer any advice on the best way to automate webpage interaction from inside the AutoIt GUI instead of opening a web browser.

My code is as follows

#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$var = 0
HotKeySet("{ESC}", "Terminate")

;Create Main GUI
$Main = GUICreate("Main",1024,768,-1,-1,-1,-1)
GUISetState(@SW_SHOW, $Main)

;Create browser window inside GUI
Local $oIE = ObjCreate("Shell.Explorer.2")
GUICtrlCreateObj($oIE, 5, 5, 1014, 600)

;
While 1
    Sleep(300)
        If $var = 0 Then
            $var = 1
            _GoTo_Google()
        EndIf   
WEnd

;Functions
Func _GoTo_Google()
    $oIE.navigate("http://google.co.uk")
EndFunc

Func Terminate()
    Exit
EndFunc

So in my above program, google is loaded inside the AutoIt GUI - I'd like to learn how to automate text input and button clicks inside the gui without having to launch a separate browser.

Please can anyone offer any suggestions or examples of the best way to do this please? I'd like to avoid simulating mouse movement and key presses.

Thanks

 

am632

Link to comment
Share on other sites

Hi,

Thanks for your reply. I have looked at the IE example as you recommended & I managed to get a working example using google's 'I'm feeling lucky' button for clicks. The example I am working from is as follows

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

Local $oIE = _IECreateEmbedded()
GUICreate("Google Search test", 1000,700,-1,-1)
GUICtrlCreateObj($oIE, 0, 0, 1000, 700)
GUICtrlSetColor(-1, 0xff0000)

GUISetState(@SW_SHOW) ;Show GUI

_IENavigate($oIE, "http://www.google.com")
_IEAction($oIE, "stop")

Local $oSubmit = _IEGetObjByName($oIE, "btnI")
_IEAction($oSubmit, "click")
_IELoadWait($oIE)

; Waiting for user to close the window
While 1
    Local $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

GUIDelete()

Exit

I couldn't find an example of how to send text stored in a variable to the google search box though before clicking the search button.

I'm sure there would be an example for this but as the help file is quite extensive maybe I'm just missing it - do you know how I would go about doing this please?

Many Thanks

Link to comment
Share on other sites

Hi,

I just want to ask another question relating to this code.

In the browser i'm making if I go to a website which has ads, it says 'please disable adblocker' - I only have an adblocker enabled in Chrome but it's actually disabled for the site I'm accessing anyway.

Please can you suggest why this is happening and how do I stop it from asking to disable the adblocker? 

Are the IE form controls actually piggybacking of Chrome (or my default browser should I say)?

Many Thanks

am632

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