Bert Posted August 13, 2007 Share Posted August 13, 2007 I have a script I made that runs 2 IE windows in a GUI. I made it to act as a viewer for a web based application. I notice when I close the script, from time to time I get a error from XP saing memory can't be read. This is happening from more than one PC, so I assuming this is happening from the software side. I notice when one uses _IECreateEmbedded, you can't use _IEQuit. I'm trying to use GUIDelete($gui) as a workaround, but I'm not sure this is the best solution. I'm wondering if there is a bug with the IE suite. code expandcollapse popup#include <GUIConstants.au3> #include <IE.au3> #Include <Constants.au3> Opt("TrayIconDebug", 1) _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() $oIE2 = _IECreateEmbedded() $w = @DesktopWidth $h = @DesktopHeight $h1 = $h - 150 $w1 = $w - 40 $w2 = $w - 60 $h2 = $h - 25 Dim $ininame, $IniButtonNames, $iniweb, $inioptions_Enable, $inioptions_apps, $x, $oIE1, $oIE2 _inisettings() $title = $ininame[1][1] $gui = GUICreate($title, $w1, $h1, -1, -1, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_CLIPCHILDREN)) ;main pane $label1 = GUICtrlCreateLabel("", 10, 68, $w - 60, $h - 230) GUICtrlSetBkColor(-1, 0xff0000) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetState(-1, $GUI_HIDE) ;marquee pane $label2 = GUICtrlCreateLabel("", 10, 40, $w1 - 20, 23) GUICtrlSetBkColor(-1, $GUI_DISABLE) GUICtrlSetState(-1, $GUI_HIDE) $oIE1 = _IECreate("about:blank", 0, 0) ; creates an invisible instance of a regular browser window $oIE1.AddressBar = 0 ; turn off all four IE Bars - works on 3rd party bars too, mostly. $oIE1.MenuBar = 0 $oIE1.StatusBar = 0 $oIE1.ToolBar = 0 $uID1 = Random(1000, 100000000) ; give it a unique name so we can grab the correct handle and process ID $oIE1.document.title = $uID1 WinWait($uID1) $hoIE1 = WinGetHandle($uID1) $mainwwindow = WinGetHandle($title) $pid1 = WinGetProcess($hoIE1) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hoIE1, "int", -16, "long", $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", $hoIE1, "hwnd", $gui) $oIE2 = _IECreate("about:blank", 0, 0) $oIE2.AddressBar = 0 $oIE2.MenuBar = 0 $oIE2.StatusBar = 0 $oIE2.ToolBar = 0 $uID2 = Random(1000, 100000000) $oIE2.document.title = $uID2 WinWait($uID2) $hoIE2 = WinGetHandle($uID2) $pid2 = WinGetProcess($hoIE2) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hoIE2, "int", -16, "long", $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", $hoIE2, "hwnd", $gui) repositionIEs() $GUI_Button_CTS_web = GUICtrlCreateButton($IniButtonNames[1][1], 10, 5, 70, 30) GUICtrlSetResizing($GUI_Button_CTS_web, 8) $GUI_Button_Depot_web = GUICtrlCreateButton($IniButtonNames[2][1], 85, 5, 80, 30) GUICtrlSetResizing($GUI_Button_Depot_web, 8) $GUI_Button_SC_web = GUICtrlCreateButton($IniButtonNames[3][1], 170, 5, 80, 30) GUICtrlSetResizing($GUI_Button_SC_web, 8) $GUI_Button_problem_board = GUICtrlCreateButton($IniButtonNames[4][1], 255, 5, 100, 30) GUICtrlSetResizing($GUI_Button_problem_board, 8) $GUI_Button_Service_request = GUICtrlCreateButton($IniButtonNames[5][1], 360, 5, 90, 30) GUICtrlSetResizing($GUI_Button_Service_request, 8) ;~ $GUI_Button_SR_Archive = GUICtrlCreateButton($IniButtonNames[6][1], 455, 5, 135, 30) ;~ GUICtrlSetResizing($GUI_Button_SR_Archive, 8) $GUI_Button_Field_operations = GUICtrlCreateButton($IniButtonNames[7][1], 595 - 140, 5, 90, 30) GUICtrlSetResizing($GUI_Button_Field_operations, 8) $GUI_Button_Document_Repository = GUICtrlCreateButton($IniButtonNames[8][1], 690 - 140, 5, 120, 30) GUICtrlSetResizing($GUI_Button_Document_Repository, 8) $GUI_Button_open_KB = GUICtrlCreateButton($IniButtonNames[9][1], 815 - 140, 5, 130, 30) GUICtrlSetResizing($GUI_Button_open_KB, 8) $GUI_Button_Search_sub = GUICtrlCreateButton($IniButtonNames[10][1], 950 - 140, 5, 130, 30) GUICtrlSetResizing($GUI_Button_Search_sub, 8) ;------------------------- ;options If $inioptions_Enable[1][1] = 1 Then Run(@ScriptDir & "\" & $inioptions_apps[1][1]) ;------------------------- AdlibEnable('_marqueecontrol', 15 * 60000) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;hotkeys HotKeySet("{F6}", "HotKeyFunc") HotKeySet("{F4}", "HotKeyFunc") HotKeySet("{F3}", "HotKeyFunc") HotKeySet("{ESC}", "HotKeyFunc") GUISetState() WinActivate($gui) $oIE1.visible = 1 _IEQuit($oIE2) $oIE3 = _IENavigate($oIE1, $iniweb[1][1]) Sleep(5000) $oIE2 = _IECreate("about:blank", 0, 0) $oIE2.AddressBar = 0 $oIE2.MenuBar = 0 $oIE2.StatusBar = 0 $oIE2.ToolBar = 0 $uID2 = Random(1000, 100000000) $oIE2.document.title = $uID2 WinWait($uID2) $hoIE2 = WinGetHandle($uID2) $pid2 = WinGetProcess($hoIE2) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hoIE2, "int", -16, "long", $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", $hoIE2, "hwnd", $gui) repositionIEs() $oIE2.visible = 1 _marqueecontrol() WinActivate($oIE1) $x = 0 While 1 $msg = GUIGetMsg() $trr = WinGetTitle($hoIE1) Select Case $trr = $ininame[3][1] ;SunTrust Intranet _IEQuit($oIE2) WinActivate($oIE1) _IENavigate($oIE1, $iniweb[1][1]) ;http://usdp/CAisd/pdmweb.exe Sleep(5000) $oIE2 = _IECreate("about:blank", 0, 0) $oIE2.AddressBar = 0 $oIE2.MenuBar = 0 $oIE2.StatusBar = 0 $oIE2.ToolBar = 0 $uID2 = Random(1000, 100000000) $oIE2.document.title = $uID2 WinWait($uID2) $hoIE2 = WinGetHandle($uID2) $pid2 = WinGetProcess($hoIE2) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hoIE2, "int", -16, "long", $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", $hoIE2, "hwnd", $gui) repositionIEs() WinActivate($oIE1) Case $msg = $GUI_EVENT_CLOSE $t1 = $ininame[3][1] $t2 = $ininame[4][1] WinActivate($hoIE1) $trr = WinGetTitle($hoIE1) If $trr = $t1 Then ExitLoop If $trr = $t2 Then ExitLoop WinActivate($hoIE1) Send("!u") Sleep(10) Send('e') Do $trr = WinGetTitle($hoIE1) Sleep(100) Until $trr = $t2 Or $trr = $t1 GUIDelete($gui) sleep(1) ExitLoop Case sizeEvent($msg) repositionIEs() Case $msg = $GUI_EVENT_RESIZED ;possible bug - taken out for the moment to test later _ResizeLimit($title, "", $w - 100, $h - 100, @DesktopWidth, @DesktopHeight) Case $msg = $GUI_Button_CTS_web _IECreate($iniweb[2][1]) WinActivate($oIE1) Case $msg = $GUI_Button_Depot_web _IECreate($iniweb[3][1]) WinActivate($oIE1) Case $msg = $GUI_Button_SC_web _IECreate($iniweb[4][1]) WinActivate($oIE1) Case $msg = $GUI_Button_problem_board _IECreate($iniweb[5][1]) WinActivate($oIE1) Case $msg = $GUI_Button_Service_request _IECreate($iniweb[6][1]) WinActivate($oIE1) ;~ Case $msg = $GUI_Button_SR_Archive ;~ _IECreate($iniweb[7][1]) WinActivate($oIE1) Case $msg = $GUI_Button_Field_operations _IECreate($iniweb[8][1]) WinActivate($oIE1) Case $msg = $GUI_Button_Document_Repository _IECreate($iniweb[9][1]) WinActivate($oIE1) Case $msg = $GUI_Button_open_KB _IECreate($iniweb[10][1]) WinActivate($oIE1) Case $msg = $GUI_Button_Search_sub _IECreate($iniweb[11][1]) WinActivate($oIE1) EndSelect WEnd _IEQuit($oIE1) _IEQuit($oIE2) GUIDelete($gui) Exit Func _ResizeLimit($title, $Text = "", $MinWidth = 150, $MinHeight = 150, $MaxWidth = @DesktopWidth, $MaxHeight = @DesktopHeight) If Not WinExists($title, $Text) Then Return SetError(1, 0, -1) Local $PosArr = WinGetPos($title, $Text), $xPos, $yPos, $wPos, $hPos If IsArray($PosArr) Then $xPos = $PosArr[0] $yPos = $PosArr[1] $wPos = $PosArr[2] $hPos = $PosArr[3] If ($wPos <> $MinWidth And $hPos <> $MinHeight) Or ($wPos <> $MaxWidth And $hPos <> $MaxHeight) Then If $wPos < $MinWidth And $hPos < $MinHeight Then WinMove($title, $Text, $xPos, $yPos, $MinWidth, $MinHeight) If $wPos < $MinWidth And $hPos >= $MinHeight Then WinMove($title, $Text, $xPos, $yPos, $MinWidth, $hPos) If $wPos >= $MinWidth And $hPos < $MinHeight Then WinMove($title, $Text, $xPos, $yPos, $wPos, $MinHeight) If $wPos > $MaxWidth And $hPos > $MaxHeight Then WinMove($title, $Text, $xPos, $yPos, $MaxWidth, $MaxHeight) If $wPos > $MaxWidth And $hPos <= $MaxHeight Then WinMove($title, $Text, $xPos, $yPos, $MaxWidth, $hPos) If $wPos <= $MaxWidth And $hPos > $MaxHeight Then WinMove($title, $Text, $xPos, $yPos, $wPos, $MaxHeight) EndIf EndIf EndFunc ;==>_ResizeLimit Func repositionIEs() $pos1 = ControlGetPos($gui, "", "Static1") $pos2 = ControlGetPos($gui, "", "Static2") WinMove($hoIE1, "", $pos1[0], $pos1[1], $pos1[2], $pos1[3]) WinMove($hoIE2, "", $pos2[0], $pos2[1], $pos2[2], $pos2[3]) EndFunc ;==>repositionIEs Func sizeEvent($event) If $event = $GUI_EVENT_MAXIMIZE Or _ $event = $GUI_EVENT_MINIMIZE Or _ $event = $GUI_EVENT_RESTORE Or _ $event = $GUI_EVENT_RESIZED Then Return True Else Return False EndIf EndFunc ;==>sizeEvent Func _marqueecontrol() Dim $aLinks[11] Local $htmlfile, $makehtml $htmlfile = @ScriptDir & "\bin\html.txm" FileOpen($htmlfile, 8 + 2) FileWrite($htmlfile, "") FileClose($htmlfile) $makehtml = FileOpen($htmlfile, 8 + 1) $oIEb = _IECreate($iniweb[5][1], 0, 0) $colTables = _IETableGetCollection($oIEb, 1) $avTable = _IETableWriteToArray($colTables) $oLinks = _IELinkGetCollection($oIEb) $iNumLinks = @extended $sHTML = "" $sHTML &= '<body scroll=no topmargin=0 BGCOLOR=LTGREEN>' $sHTML &= '<marquee behavior=scroll direction=left scrolldelay=2 scrollamount=2 onmouseover="this.stop()" onmouseout="this.start()") >' $sHTML &= '<span style="background-color: #FFFFFF">******** Solution Center Problem Board Marquee ********</span> ' For $i = 0 To $iNumLinks $sHTML &= ' #' & $i + 1 & ' ' $sHTML &= '<span style="background-color: #FFFF00"> <B>Last Update: </b>' $sHTML &= '<a target="_blank" href= "' & $oLinks.item ($i + 3).href & '">' & $avTable[0][$i + 1] & "</a> <b>Master#</b> " & $avTable[1][$i + 1] $sHTML &= " <b>Description: </b> " & $avTable[2][$i + 1] $sHTML &= " <b>Region:</b> " & $avTable[3][$i + 1] $sHTML &= " <b>Resolve Date:</b> " & $avTable[4][$i + 1] & '</span>' If $i = 9 Then ExitLoop Next $sHTML &= ' </marquee></body>' $writehtml = FileWrite($htmlfile, $sHTML) $fr = FileRead(@ScriptDir & "\bin\html.txm") $makemarquee = _IEDocWriteHTML($oIE2, $fr) FileClose($htmlfile) _IEQuit($oIEb) WinActivate($oIE1) EndFunc ;==>_marqueecontrol Func _inisettings() ;keeps all websites in ini file. This allows for updates. $iniweb = IniReadSection(@ScriptDir & "\bin\cfgusd.cud", "1") $IniButtonNames = IniReadSection(@ScriptDir & "\bin\cfgusd.cud", "2") $ininame = IniReadSection(@ScriptDir & "\bin\cfgusd.cud", "3") $inioptions_apps = IniReadSection(@ScriptDir & "\bin\options.cud", "1") $inioptions_Enable = IniReadSection(@ScriptDir & "\bin\options.cud", "2") #cs iniweb 1= Main USD 2= CTS portal 3= Depot 4= SC - internal 5= problem board 6= Service request 7= SR - archive 8= Field Operations note - make button names changeable? offer choices? #ce EndFunc ;==>_inisettings ;func _searchKB() ; to be built ;EndFunc Func HotKeyFunc() Opt("WinTitleMatchMode", 2) If WinActive("Update Incident - Unicenter ServicePlus Service Desk") Then; Set the window Switch @HotKeyPressed Case "{F4}" If WinExists("USD Configuration Item Tool", "Help") = 0 Then Run(@ScriptDir & "/CIT.exe") EndSwitch Else HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "HotKeyFunc") EndIf If WinActive("Update Request - Unicenter ServicePlus Service Desk") Then; Set the window Switch @HotKeyPressed Case "{F4}" If WinExists("USD Configuration Item Tool", "Help") = 0 Then Run(@ScriptDir & "/CIT.exe") EndSwitch Else HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "HotKeyFunc") EndIf If WinActive("Create New Incident") Then; Set the window Switch @HotKeyPressed Case "{F4}" If WinExists("USD Configuration Item Tool", "Help") = 0 Then Run(@ScriptDir & "/CIT.exe") EndSwitch Else HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "HotKeyFunc") EndIf If WinActive("Create New Request") Then; Set the window Switch @HotKeyPressed Case "{F4}" If WinExists("USD Configuration Item Tool", "Help") = 0 Then Run(@ScriptDir & "/CIT.exe") EndSwitch Else HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "HotKeyFunc") EndIf If @HotKeyPressed = "{F6}" Then If WinExists("QuickPaste 2.0", "Paste") = 0 Then Run(@ScriptDir & "/quickpaste2_0.exe") EndIf Else HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "HotKeyFunc") EndIf EndFunc ;==>HotKeyFunc The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
DaleHohm Posted August 13, 2007 Share Posted August 13, 2007 The only other thing you can do to clean up is $oIE = 0 -- this will insure that the object reference your script is holding is destroyed. 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...
Bert Posted August 13, 2007 Author Share Posted August 13, 2007 good idea. I will test tomorrow The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted August 14, 2007 Author Share Posted August 14, 2007 So far, no errors have occured since I placed in what you suggested. It seems to have fixed the issue. Thanks Dale! The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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