jacQues Posted February 29, 2008 Share Posted February 29, 2008 (edited) There are some fantastic threads about how to use an IE object to create an animated GIF within an AutoIt GUICreate() window. It works very well etc. However, I need the picture to be clickable. FUNC AddGif($y) LOCAL $x = ObjCreate("Shell.Explorer.2") IF IsObj($x) THEN GUICtrlSetOnEvent(GUICtrlCreateObj($x,14,$y,354,58),"WebSiteGif") $x.navigate("about:blank") WHILE $x.Busy() Sleep(20) WEND $x.document.body.background = @ScriptDir&"\logo.gif" $x.document.body.scroll = "no" $x.document.body.style.border = "0px" ELSE GUICtrlSetOnEvent(GUICtrlCreatePic(@ScriptDir&"\logo.gif",14,$y,354,58),"WebSiteGif") ENDIF ENDFUNC; AddGif FUNC WebSiteGif ; determine URL and do some other stuff... ; ShellExecute($url) MsgBox(0,"test","WebSiteGif called") ENDFUNC; WebSiteGif How do I get the GUICtrlCreateObj() to run the function WebSiteGif() when the picture is clicked? I thought about using HTML (e.g. <A HREF=...) but that wouldn't work for me since the AutoIt program needs to adjust certain settings when the gif is clicked. jacQues Edited February 29, 2008 by jacQues Link to comment Share on other sites More sharing options...
jacQues Posted February 29, 2008 Author Share Posted February 29, 2008 I thought about using HTML (e.g. <A HREF=...)Another problem with this method is that IE is opened and not the "default" browser. For example, if Firefox is installed and set to be the browser to use, ShellExecute() will correctly use Firefox, but when using an IE object, IE is always opened.jacQues Link to comment Share on other sites More sharing options...
therks Posted February 29, 2008 Share Posted February 29, 2008 You can trap the clicking event. Allow me to supply some of my old code for an example. #include <GUIConstants.au3> #include <IE.au3> _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() GUICreate('Hello!', 375, 281) $ob_IE = GUICtrlCreateObj($oIE, 0, 0, 375, 281) GUISetState() _IENavigate($oIE, @ScriptDir & '\eventtest.html') _IEBodyWriteHTML($oIE, '<button name="mybutt">Click me!</button>') $oButton = _IEGetObjByName($oIE, 'mybutt') $oEvt = ObjEvent($oButton, 'ButtonEvents_') While 1 $gm = GUIGetMsg() Switch $gm Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func ButtonEvents_onclick() MsgBox(0x2000, 'AutoIt', 'You clicked the button!') EndFunc My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
DaleHohm Posted February 29, 2008 Share Posted February 29, 2008 (edited) You need ObjEvent instead. You also may also benefit from using the IE Management functions as well (IE.au3). Dale Edit: first like Saunders showed while I wrote my reply! Edited February 29, 2008 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 Link to comment Share on other sites More sharing options...
jacQues Posted February 29, 2008 Author Share Posted February 29, 2008 You can trap the clicking event. Allow me to supply some of my old code for an example.M'kay, but obviously I cannot use "$oButton = _IEGetObjByName($oIE, 'mybutt')". What value do I use instead of 'mybutt'?? I don't think I can name the background and I also doubt if its possible to set an onclick event for the background property. But then again IE stuff is not within my knowledge.jacQues Link to comment Share on other sites More sharing options...
jacQues Posted February 29, 2008 Author Share Posted February 29, 2008 Tries like 100 different things but cannot get that IE stuff working PROPERLY. Kinda works etc. but I'm a perfectionist. Got it working using this: FUNC AddGif($y) LOCAL $x = ObjCreate("Shell.Explorer.2") IF IsObj($x) THEN GUICtrlSetOnEvent(GUICtrlCreateLabel("",14,$y,354,58),"WebSiteGif") ; <=- ADDED GUICtrlCreateObj($x,14,$y,354,58) $x.navigate("about:blank") WHILE $x.Busy() Sleep(20) WEND $x.document.body.background = @ScriptDir&"\logo.gif" $x.document.body.scroll = "no" $x.document.body.style.border = "0px" ELSE GUICtrlSetOnEvent(GUICtrlCreatePic(@ScriptDir&"\logo.gif",14,$y,354,58),"WebSiteGif") ENDIF ENDFUNC; AddGif FUNC WebSiteGif ; determine URL and do some other stuff... ; ShellExecute($url) MsgBox(0,"test","WebSiteGif called") ENDFUNC; WebSiteGif Thanks for your help. I must look into IE.au3 soon. Seems like fun. jacQues Link to comment Share on other sites More sharing options...
therks Posted February 29, 2008 Share Posted February 29, 2008 You can set an onclick property for the background, but I don't know how you'd capture it. Just use an actual image in your HTML. <img src="picture.gif" name="mybutt"> #include <GUIConstants.au3> #include <IE.au3> _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() GUICreate('Hello!', 375, 281) $ob_IE = GUICtrlCreateObj($oIE, 0, 0, 375, 281) GUISetState() _IENavigate($oIE, 'about:blank') _IEBodyWriteHTML($oIE, '<img src="pic.gif" name="mybutt">') $oButton = _IEGetObjByName($oIE, 'mybutt') $oEvt = ObjEvent($oButton, 'ButtonEvents_') While 1 $gm = GUIGetMsg() Switch $gm Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func ButtonEvents_onclick() MsgBox(0x2000, 'AutoIt', 'You clicked the image!') EndFunc My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
DaleHohm Posted February 29, 2008 Share Posted February 29, 2008 You can get a reference to the body element like this: $oBody = _IETagnameGetCollection($oIE, "body", 0) 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 Link to comment Share on other sites More sharing options...
jacQues Posted February 29, 2008 Author Share Posted February 29, 2008 (edited) You can get a reference to the body element like this:$oBody = _IETagnameGetCollection($oIE, "body", 0)DaleWorks like a charm!! Woohoo! One thing I did notice is that any GUICtrlCreateInput() doesn't allow Esc, Tab and Shift+Tab anymore. Is this normal when using IE functions? (edit: second GUI that uses GUIMsg() instead of OnEvent)jacQues Edited February 29, 2008 by jacQues Link to comment Share on other sites More sharing options...
therks Posted March 1, 2008 Share Posted March 1, 2008 Technically I'd have to say that it is normal, in so far as that it happens to everyone else too (as far as I know). It doesn't seem like good behaviour though, but I don't know that there's a way around it. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
DaleHohm Posted March 1, 2008 Share Posted March 1, 2008 Works like a charm!! Woohoo! One thing I did notice is that any GUICtrlCreateInput() doesn't allow Esc, Tab and Shift+Tab anymore. Is this normal when using IE functions? (edit: second GUI that uses GUIMsg() instead of OnEvent)jacQuesI really don't follow your issue here. So you have two embedded IE controls? If so, there is a bug logged in Bug Trac about the keystrokes being delivered to the wrong control.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 Link to comment Share on other sites More sharing options...
Oldschool Posted March 28, 2008 Share Posted March 28, 2008 Cool function, but I have a problem setting other controls on top of the animated gif. For example, my gif image spans the entire GUI, so I want to nest some controls right on top of it, but they are only visible on mouseover. In the example below, the button does not show...Any ideas?#include <GuiConstants.au3> HotKeySet("{TAB}", "_Terminate") Opt("GUICloseOnESC", 0) Opt("GUIOnEventMode", 1) $img = 'C:\Animated5.gif' Global $iGuiW = 1001, $iGuiH = 611, $sTitle = "Logical GUI", $aBtnText[2] = ["START", "STOP"] $hGui = GUICreate($sTitle, $iGuiW, $iGuiH, -1, -1, $WS_POPUP+$WS_BORDER, $WS_EX_TOPMOST) GUISetState() $button_run = GUICtrlCreateButton($aBtnText[0], 20, 380, 100, 20) AddGif() While 1 Sleep(100) WEnd Func _Terminate() Exit 0 EndFunc FUNC AddGif() LOCAL $x = ObjCreate("Shell.Explorer.2") IF IsObj($x) THEN GUICtrlCreateObj($x,0,0,1001,611) $x.navigate("about:blank") WHILE $x.Busy() Sleep(20) WEND $x.document.body.background = $img $x.document.body.scroll = "no" $x.document.body.style.border = "0px" ENDIF ENDFUNC; AddGif Link to comment Share on other sites More sharing options...
andygo Posted April 5, 2008 Share Posted April 5, 2008 (edited) Hello,i found a very simple solution.1.: for the animated gif, i use this method:http://www.autoitscript.com/forum/index.ph...mp;#entry2431182.: "behind" the animated gif in my GUI, i place another clickable object at the same coordinates.result: the clickable object is hidden "behind" the animated gif. you could say that you clickthrough the gif .-))FileInstall("1.gif", @windowsdir & "\temp\1.gif", 1) $sm1 = GUICtrlCreatePic (@windowsdir & "\temp\1.gif",10,250,55,32) $gif1 = @windowsdir & "\temp\1.gif" $oIE1 = ObjCreate("Shell.Explorer.2") $GUIActiveX1 = GUICtrlCreateObj($oIE1, 10, 250, 55, 32) _StartGif($GUI, $oIE1, $gif1)--Case $msg = $sm1 ...i use this to put some emotions into different forums:Greez from Germany,Andy Edited April 5, 2008 by andygo Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now