Sign in to follow this  
Followers 0
Will66

IE.au3, possible to know if a button was clicked on a embedded page?

4 posts in this topic

#1 ·  Posted (edited)

Using IE.au3 to embed and load a local html file from my hard drive in a gui using _IECreateEmbedded ().

I have setup some buttons in the html file that perform various functions.

Is it possible to return to autoit script if a button was clicked and which button?

basically i guess, how can i listen for events.

Edited by Will66

Share this post


Link to post
Share on other sites



Yes, using the AutoIt ObjEvent function. There is nothing in IE.au3 to help you with this specifically, but you do need object references to the button and IE.au3 ca help with that.

Here is a template to get you started:

$oEvent1 = ObjEvent( $oButton1, "Button1_")

Func Button1_onclick()

;do what you want to in here...

EndFunc

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Ok, that gives me some clues thanx. I'm looking at the ObjEvent helpfile but it doesn't show anything useful outside the _IE standard functions.

html "test.html":

<input type="button" name="clicker" value="click me">

autoit:

#include <GUIConstants.au3>
#include <IE.au3>
$Editor=@ScriptDir & "\test.html"

_IEErrorHandlerRegister ()
$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 300, 470)
GUISetState()
$event = _IENavigate ($oIE, $Editor)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        ;Case $event > 0
            ;MsgBox(0,"",$event)
    EndSelect
WEnd

GUIDelete()

Exit

Share this post


Link to post
Share on other sites

Got it!

Thankyou for your help, i'd never have found it. Cheers.

#include <GUIConstants.au3>
#include <IE.au3>
$Editor=@ScriptDir & "\test.html"

_IEErrorHandlerRegister ()
$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 300, 470)
GUISetState()
$event = _IENavigate ($oIE, $Editor)

$oButton1 = _IEGetObjByName ($oIE, "clicker")


$oEvent1 = ObjEvent( $oButton1, "Button1_")
;$SinkObject=ObjEvent($oIE,"IEEvent_","DWebBrowserEvents2") 
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        ;Case $SinkObject
            ;MsgBox(0,"",$SinkObject)
    EndSelect
WEnd

GUIDelete()

Exit



Func Button1_onclick()
MsgBox(0,"","test")
EndFunc

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  
Followers 0