_ProcessGetParent() function taken from MrCreatoR's post Here (thanks MrCreatoR)
AutoIt
#include <IE.au3> ;This page currently has displays a popup when you try to navigate away from the page $any_url = "aquaponics4you.com" ;$any_url = "yahoo.com" $oIE = _IECreate($any_url) $oIE = _IENavigate_kill_popup($oIE, "Google.com") Func _IENavigate_kill_popup($IEObject, $URL, $visible = 1, $wait = 1) If Not IsObj($IEObject) Then Return SetError(1, 0, 0) $closed_process = False ;gets the IE process $pid = WinGetProcess(_IEPropertyGet($IEObject, "hwnd")) ;Trys to navigate to URL _IENavigate($IEObject, $URL, 0) ;Gets list of all process $aProc_List = ProcessList() ;Checks to see if any process were opened by the IE window. If process where opened it closes them and the IE window. For $i = 1 To $aProc_List[0][0] If _ProcessGetParent($aProc_List[$i][1]) = $pid Then ProcessClose($aProc_List[$i][1]) $closed_process = True EndIf Next ;will create a new IE with old IE object varable if it no longer exists. If $closed_process = True Then $IEObject = _IECreate($URL, 0, $wait) Return $IEObject Else If $wait = 1 Then _IELoadWait($IEObject) Return $IEObject EndIf EndFunc ;==>_IENavigate_stop_pop Func _ProcessGetParent($iPID) Local $wbemFlagReturnImmediately = 0x10 Local $wbemFlagForwardOnly = 0x20 Local $colItems = "" Local $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $objItem.ProcessID = $iPID Then Return $objItem.ParentProcessID Next EndIf Return SetError(1, 0, 0) EndFunc ;==>_ProcessGetParent
Edited by Herb191, 27 October 2011 - 04:28 PM.





