Sign in to follow this  
Followers 0
XGhosT

How to catch click on elements from IE?

5 posts in this topic

Good afternoon!

How i can catch click on elements (links,button, images) from IE ?

Can i post event from IE JScript to Auto It script (of course, IE opened via Auto It script)?

I find some examples with IE, but all of them use

While True

...

Wend

loop construction and eat all of my CPU resources :-(

Share this post


Link to post
Share on other sites



yes, _IE is a professtional way to express your idea but if you feel hard or don't want to waste time on it, just try

Send("{TAB}") & Mouse*()

you can have more here : http://www.autoitscript.com/autoit3/docs/a...ix/SendKeys.htm


[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

yes, _IE is a professtional way to express your idea

Thanks a lot!

I know about _IE methods, but all of them intend for control IE elements and objects from Auto It.

But i want to send events from IE to Auto It script.

For example, this script doing just what I want (but while you not pressed 'bye' , its eat more system resources, CPU average loading is 100%):

CODE
#include <GUIConstants.au3>

#include <IE.au3>

$Win = GUICreate("Win", 200, 100, 200, 100, $WS_POPUP)

$Obj1 = ObjCreate("Shell.Explorer.2")

$Obj1_ctrl = GUICtrlCreateObj($Obj1, 0, 0, 200, 100)

GUISetState(@SW_SHOW)

$Obj1.navigate("about:blank")

$Obj1.document.write("<html>")

$Obj1.document.write("<body bgcolor=000000>")

$Obj1.document.write("<input type='hidden' id='msg'/>")

$Obj1.document.write("<button onclick='msg.value=""bye"";'>press me for bye</button>")

$Obj1.document.write("</html>")

While 1

$oMsgID = _IEGetObjById($Obj1, "msg")

$oMsg = _IEFormElementGetValue($oMsgID)

$oMsg = StringSplit($oMsg, "[//]")

Switch $oMsg[1]

Case "bye"

Exit

EndSwitch

WEnd

If i find a methods for send event's directly from IE to Auto It, i reduce a CPU usage (i guess...).

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You want to use ObjEvent

$oEvt = ObjEvent($oMsg, "Event_")

Func Event_onclick()
    ConsoleWrite("I've been clicked!")
    ; other code
EndFunc

Also, in general for an idle loop (While True...Wend) embed a Sleep(some-value-like-100) into the loop.

Dale

edit: typo in example

Edited by DaleHohm

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

You want to use ObjEvent

Thanks a lot. I've use ObjEvent and modify my sample. All is OK.

#include <GUIConstants.au3>
#include <IE.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode 


$Win = GUICreate("Win", 200, 100, 200, 100, $WS_POPUP)
$Obj1 = ObjCreate("Shell.Explorer.2")
$Obj1_ctrl = GUICtrlCreateObj($Obj1, 0, 0, 200, 100)

$Obj1.navigate("about:blank")
$Obj1.document.write("<html>")
$Obj1.document.write("<body bgcolor=000000>")
$Obj1.document.write("<input type='hidden' id='msg'/>")
$Obj1.document.write("<button id='isbye' onclick='msg.value=""bye"";'>press me for bye</button>")
$Obj1.document.write("<button id='isok' onclick='msg.value=""OK"";'>OK</button>")
$Obj1.document.write("</html>")

GUISetState(@SW_SHOW)

$oMsgID = _IEGetObjById($Obj1, "isok")
$oEvt = ObjEvent($oMsgID, "Event_OK_")

$oMsgID = _IEGetObjById($Obj1, "isbye")
$oEvt = ObjEvent($oMsgID, "Event_BYE_")

While 1
 sleep(1000)
WEnd

Func Event_OK_onclick()
    MsgBox(4096, "Error","Click OK!")   
EndFunc

Func Event_BYE_onclick()
    MsgBox(4096, "Error","Click BYE!")   
    Exit
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