John117 Posted December 21, 2007 Author Posted December 21, 2007 (edited) Sorry, I would edit the above post but I get funny symbols that ruin the post. This alteration of 'Stop' allows me to see the script is almost working. expandcollapse popup#include <GUIConstants.au3> #include <IE.au3> #include <Array.au3> ;#AutoIt3Wrapper_run_debug_mode=Y Global Const $WM_LBUTTONDOWN = 0x0201 Global $oIE, $oIFrame HotKeySet("{ESC}", "_Toggle") $Show = False _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() $GUI = GUICreate("", 1024, 600, Default, Default, $WS_POPUPWINDOW) $GUIActiveX = GUICtrlCreateObj($oIE, -176, -130, 800, 800) $GUI_Button_Back = GUICtrlCreateButton("Back", 650, 20, 60, 20) $GUI_Button_Forward = GUICtrlCreateButton("Forward", 650, 50, 60, 20) $GUI_Button_Home = GUICtrlCreateButton("Home", 650, 80, 60, 20) $GUI_Button_Stop = GUICtrlCreateButton("Stop", 650, 110, 60, 20) GUISetState(@SW_SHOW, $GUI);Show GUI GUIRegisterMsg($WM_LBUTTONDOWN, "_WinMove") _IENavigate($oIE, "http://traffic.houstontranstar.org/layers/#") ;_IELoadWait($oIE) sleep(10000) $oEvtMain = ObjEvent($oIE, "EvtMain_") EvtMain_onload() ; ============================================================================ ; Main Loop ; ============================================================================ While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_Button_Home _IENavigate($oIE, "http://traffic.houstontranstar.org/layers/#") Case $msg = $GUI_Button_Back _IEAction($oIE, "back") Case $msg = $GUI_Button_Forward _IEAction($oIE, "forward") Case $msg = $GUI_Button_Stop ;_IEAction($oIE, "stop") EvtIFrame_onload() EndSelect WEnd ; ============================================================================ ; Functions ; ============================================================================ Func EvtMain_onload() ConsoleWrite("----> In EvtMain_onload()" & @CR) $oEvtIFrame = 0 $oBody = _IETagNameGetCollection($oIE, "body", 0) _IEDocInsertHTML($oBody, '<iFrame name="hiddenIFrame" src="about:blank" height=0 width=0>', "afterbegin") $oIFrame = _IEFrameGetObjByName($oIE, "hiddenIFrame") $oEvtIFrame = ObjEvent($oIFrame, "EvtIFrame_") $oMaps = _IETagNameGetCollection($oIE, "map") ConsoleWrite(@extended & @CR) Dim $avArray[1] For $oMap In $oMaps $oLinks = _IETagNameGetCollection($oMap, "area") ReDim $avArray[1] $avArray[0] = "Start" For $oLink In $oLinks $sHref = String($oLink.href) ConsoleWrite("----> " & $sHref & @CR) If StringInStr($sHref, "showWin(") Then ConsoleWrite("----> Working, showWin( Found " & $sHref & @CR) $sUrl = StringTrimLeft(StringTrimRight($sHref, 10), 28) ; parse the url portion out of the href _ArrayAdd($avArray, $sUrl) $oLink.href = $sUrl $oLink.target = "hiddenIFrame" EndIf Next _ArrayDisplay($avArray, "Whole array") Next EndFunc ;==>EvtMain_onload Func EvtIFrame_onload() ConsoleWrite("----> In EvtIFrame_onload()" & @CR) ; parse and act on the contents of the iFrame ;$oIE2 = _IEFrameGetObjByName($oIE, "hiddenIFrame") ConsoleWrite(_IEDocReadHTML($oIFrame) & @CR) $oTables = _IETagNameGetCollection($oIFrame, "table") $index = 0 For $oTable In $oTables _IETagNameGetCollection($oTable, "table") If Not @extended Then $aTable = _IETableWriteToArray($oTable, True) _ArrayDisplay($aTable, "Table index: " & $index) EndIf $index += 1 Next EndFunc ;==>EvtIFrame_onload Func _Toggle() If $Show = True Then Global $Show = False GUISetState(@SW_SHOW, $GUI) Else Global $Show = True GUISetState(@SW_HIDE, $GUI) EndIf EndFunc ;==>_Toggle Func _WinMove($HWnd, $Command, $wParam, $lParam) If BitAND(WinGetState($HWnd), 32) Then Return $GUI_RUNDEFMSG DllCall("user32.dll", "long", "SendMessage", "hwnd", $HWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0) EndFunc ;==>_WinMove Only remaining issue seems to be getting everything to fire and being able to click the checkboxes. (will toy with the checkboxes later) Edited December 21, 2007 by Hatcheda
DaleHohm Posted December 21, 2007 Posted December 21, 2007 The Map Control checkboxes are in this hidden form: <FORM style="DISPLAY: inline; LINE-HEIGHT: 2.1" name=mapControl><A onclick="hideElement('mapCtl'); return false;" href="#"><IMG id=imgCloseMapControl onmouseover="swapImg('imgCloseMapControl','../images/gray_closewin_active.gif')" style="BORDER-TOP-WIDTH: 0px; PADDING-RIGHT: 4px; PADDING-LEFT: 4px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 4px; PADDING-TOP: 4px; BORDER-RIGHT-WIDTH: 0px" onmouseout="swapImg('imgCloseMapControl','../images/gray_closewin.gif')" height=12 alt="Close Menu" src="../images/gray_closewin.gif" width=12 align=right></A> <INPUT id=chkIncidents onclick=getCheckboxValues(this.id) type=checkbox CHECKED name=chkMapControl> <IMG style="MARGIN: 0px 5px 0px 0px" height=13 alt=Incidents src="../images/inc_lgd.gif" width=13>Incidents<BR><INPUT id=chkLaneClosures onclick=getCheckboxValues(this.id) type=checkbox name=chkMapControl> <IMG style="MARGIN: 0px 5px 0px 0px" height=14 alt="Lane Closures" src="../images/lc_lgd.gif" width=13>Lane Closures<BR><INPUT id=chkCameras onclick=getCheckboxValues(this.id) type=checkbox name=chkMapControl> <IMG style="MARGIN: 0px 5px 0px 0px" height=6 alt=Cameras src="../images/camera_icon.gif" width=12>Cameras<BR><INPUT id=chkDms onclick=getCheckboxValues(this.id) type=checkbox name=chkMapControl> <IMG style="MARGIN: 0px 5px 0px 0px" height=7 alt=DMS src="../images/dms_icon.gif" width=13>Message Signs<BR><IMG style="MARGIN: 0px 5px" height=13 alt="Construction Cameras" src="../images/const_cam_lgd.gif" width=13>Construction Cameras <IMG style="MARGIN: 0px 5px" height=13 alt="Zoom In" src="../images/zoomin_lgd.gif" width=13>Zoom In <IMG style="MARGIN: 0px 5px" height=13 alt="Zoom Out" src="../images/zoomout_lgd.gif" width=13>Zoom Out </FORM> You should be able to manipulate them with _IFormElementCheckboxSelect even with the form not visible. 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
John117 Posted December 21, 2007 Author Posted December 21, 2007 (edited) Great! Thanks a lot Question, can I disable the auto update? strip whatever refreshes it from the source? Edit: all below This would get rid of the need to keep the onload stuff. -Also relaxes alot of the timing issues, and my bandwidth. I could build a button refresh and press when needed I could check for left mouse down and if over gui auto run the EvtIFrame_onload Edited December 21, 2007 by Hatcheda
DaleHohm Posted December 21, 2007 Posted December 21, 2007 This is really very cool. It's great to see that all of these pieces (rewriting links, hidden iframes, onload events) all actually do work together outside the concept in my head. Depending on where your performance bottlenecks are, you might also want to experiment with redefining the showWin() function instead of rewriting all of the links. Also, if any of the URLs you are targeting to the hidden iFrame are on a different domain, you'll end up with an access is denied error if you try to read the content with script. In that case you can look at implementing XMLHTTPRequest read of the URL and then write it to the iFrame yourself so that it can be parsed... hopefully you don't need to go that road. I hope you'll consider writing up a bit about this when you are done and posting it as a learning example for others when you are done. 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
DaleHohm Posted December 21, 2007 Posted December 21, 2007 (edited) Sure! No prob, Examples section?Yes, exactly. Regarding the refresh... it is not clear what is driving that. I find no meta tags associated and I see nothing interesting in the headers. One odd thing I do see is that the <HTML> tag is getting updated with dynamic HTML with these strings: {955246E3-6933-480d-B146-2462CE868767}="true" {F92F6ACC-5E50-4482-BC62-9D8DF61E5A32}="22" They are not in the initial source, only in the interpretted source. I have not seen this before... is it perhaps instructions for refresh = true every 22 seconds? I don't know. In any case, I'm guessing that it is being driven by one of the included Javascripts. Dale Edit: looking at the headers I see taht the refresh is every 3 minutes... Edit2: ok, now I do see it in the head... <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Expires" content="0"> <meta http-equiv="Cache-Control" content="no-cache"> <meta http-equiv="refresh" content="180"> <meta name="keywords" content="Houston, traffic, map, freeway, speed, incidents"> <meta name="description" content="Houston Freeway Speed"> <meta name="GENERATOR" content="Mozilla/4.61 [en] (WinNT; I) [Netscape]"> <meta http-equiv="refresh" content="180"> Dale Edited December 21, 2007 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
John117 Posted December 21, 2007 Author Posted December 21, 2007 (edited) Well, tried all I can currently think of to get the onload to work for EvtIFrame_onload() -it works the first click, then you must click stop to see any additional road clicks. It is not detecting the new load? Edit: Below For now I'm going to use a mouse click over the gui to run the EvtIFrame section. -But I will keep at it untill I understand what is not happening. I know its a coding problem, I can feel it, just not see it. Kinda like yesterday I knew I was forgetting somthing, left home, then got to work without fixing my hair Edit: Below is a working example of the mouse click expandcollapse popup#include <GUIConstants.au3> #include <IE.au3> #include <Array.au3> #include <Misc.au3> $dll = DllOpen("user32.dll") ;#AutoIt3Wrapper_run_debug_mode=Y Global Const $WM_LBUTTONDOWN = 0x0201 Global $oIE, $oIFrame HotKeySet("{ESC}", "_Toggle") $Show = False _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() $GUI = GUICreate("", 1024, 600, Default, Default, $WS_POPUPWINDOW) $GUIActiveX = GUICtrlCreateObj($oIE, -176, -130, 800, 800) $GUI_Button_Back = GUICtrlCreateButton("Back", 650, 20, 60, 20) $GUI_Button_Forward = GUICtrlCreateButton("Forward", 650, 50, 60, 20) $GUI_Button_Home = GUICtrlCreateButton("Home", 650, 80, 60, 20) $GUI_Button_Stop = GUICtrlCreateButton("Stop", 650, 110, 60, 20) _IENavigate($oIE, "http://traffic.houstontranstar.org/layers/#") sleep(10000) $oEvtMain = ObjEvent($oIE, "EvtMain_") EvtMain_onload() GUISetState(@SW_SHOW, $GUI);Show GUI GUIRegisterMsg($WM_LBUTTONDOWN, "_WinMove") ; ============================================================================ ; Main Loop ; ============================================================================ While 1 $msg = GUIGetMsg() $size = WinGetPos($GUI) $pos = MouseGetPos() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_Button_Home _IENavigate($oIE, "http://traffic.houstontranstar.org/layers/#") Case $msg = $GUI_Button_Back _IEAction($oIE, "back") Case $msg = $GUI_Button_Forward _IEAction($oIE, "forward") Case $msg = $GUI_Button_Stop _IEAction($oIE, "stop") Case _IsPressed("01", $dll) And $pos[0] > $size[0] And $pos[0] < ($size[0] + $size[2]) And $pos[1] > $size[1] And $pos[1] < $size[3] ;MouseLeft > GuiLeft MouseRight < GuiRight MouseTop > GuiTop MouseBottom < GuiBottom EvtIFrame() EndSelect WEnd DllClose($dll) ; ============================================================================ ; Functions ; ============================================================================ Func EvtMain_onload() ConsoleWrite("----> In EvtMain_onload()" & @CR) $oEvtIFrame = 0 $oBody = _IETagNameGetCollection($oIE, "body", 0) _IEDocInsertHTML($oBody, '<iFrame name="hiddenIFrame" src="about:blank" height=0 width=0>', "afterbegin") $oIFrame = _IEFrameGetObjByName($oIE, "hiddenIFrame") ;$oEvtIFrame = ObjEvent($oIFrame, "EvtIFrame") $oMaps = _IETagNameGetCollection($oIE, "map") ConsoleWrite(@extended & @CR) Dim $avArray[1] For $oMap In $oMaps $oLinks = _IETagNameGetCollection($oMap, "area") ReDim $avArray[1] $avArray[0] = "Start" For $oLink In $oLinks $sHref = String($oLink.href) ConsoleWrite("----> " & $sHref & @CR) If StringInStr($sHref, "showWin(") Then ConsoleWrite("----> Working, showWin( Found " & $sHref & @CR) $sUrl = StringTrimLeft(StringTrimRight($sHref, 10), 28) ; parse the url portion out of the href _ArrayAdd($avArray, $sUrl) $oLink.href = $sUrl $oLink.target = "hiddenIFrame" EndIf Next _ArrayDisplay($avArray, "Whole array") Next EndFunc ;==>EvtMain_onload Func EvtIFrame() ConsoleWrite("----> In EvtIFrame_onload()" & @CR) ; parse and act on the contents of the iFrame ConsoleWrite(_IEDocReadHTML($oIFrame) & @CR) $oTables = _IETagNameGetCollection($oIFrame, "table") $index = 0 For $oTable In $oTables _IETagNameGetCollection($oTable, "table") If Not @extended Then $aTable = _IETableWriteToArray($oTable, True) _ArrayDisplay($aTable, "Table index: " & $index) EndIf $index += 1 Next EndFunc ;==>EvtIFrame_onload Func _Toggle() If $Show = True Then Global $Show = False GUISetState(@SW_SHOW, $GUI) Else Global $Show = True GUISetState(@SW_HIDE, $GUI) EndIf EndFunc ;==>_Toggle Func _WinMove($HWnd, $Command, $wParam, $lParam) If BitAND(WinGetState($HWnd), 32) Then Return $GUI_RUNDEFMSG DllCall("user32.dll", "long", "SendMessage", "hwnd", $HWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0) EndFunc ;==>_WinMove I will post on the buttons, refresh stuff later tonight or tomorrow. @Dale, Thanks for all the help! Edited December 21, 2007 by Hatcheda
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