Astrali Posted January 7, 2010 Share Posted January 7, 2010 Hi! I love AutoIt for years and use it every now and then when i get an idea to program. Right now i am using Windows 7 and i am not able to close an "iexplore.exe *32" process in the way i did with WinXP in the Windows Taskmanager i get listed "iexplore.exe *32" so i tried ProcessClose("iexplore.exe") and ProcessClose("iexplore.exe *32") but nothing happened! i already used the search funktion as i did the years before but this time i found really nothing to solve my problem. any ideas? Thanks! - Greets Lars - Link to comment Share on other sites More sharing options...
Astrali Posted January 7, 2010 Author Share Posted January 7, 2010 just found out i can list the iexplore processes including the PID by using the "ProcessList" example script from the AutoIt Help like this: $list = ProcessList("iexplore.exe") for $i = 1 to $list[0][0] msgbox(0, $list[$i][0], $list[$i][1]) next so .. when i can get a list of "iexplore.exe" why isn´t it possible to ProcessClose iexplore.exe!? Link to comment Share on other sites More sharing options...
KaFu Posted January 7, 2010 Share Posted January 7, 2010 Did some research, interesting .IE8 spawns multiple instances of itself to handle the tabs. You have to close the parent instance to properly close IE. Added some links in the example. expandcollapse popup; http://www.winhelponline.com/blog/multiple-instances-of-iexploreexe-run-when-using-internet-explorer-8/ ; IE8 and Loosely-Coupled IE (LCIE) ; http://blogs.msdn.com/ie/archive/2008/03/11/ie8-and-loosely-coupled-ie-lcie.aspx ;#include <array.au3> #include <Process.au3> $list = ProcessList("iexplore.exe") ;_ArrayDisplay($list) if $list[0][0] > 0 Then for $i = 1 to $list[0][0] ;MsgBox(0,"",$list[$i][1] & @crlf & _ProcessGetParent($list[$i][1]) & @crlf & _ProcessGetName(_ProcessGetParent($list[$i][1]))) if _ProcessGetName(_ProcessGetParent($list[$i][1])) = "explorer.exe" then ProcessClose($list[$i][1]) Next endif ;=================================================================================================== ; ; Function Name: _ProcessGetParent() ; ; Description: Retrieve parent process for a child process ; ; Parameter(s): $i_pid: The process identifier of the process you want to get the parent ; process identifier for ; ; Return Value(s): ; On Success: ; Parent PID (process identifier) ; ; On Failure: ; PID of process passed (Check @error to make sure it is a parent and didn't ; fail) ; ; @Error: ; (1): CreateToolhelp32Snapshot failed ; (2): Process32First failed ; ; Remark(s): Tested on Windows XP SP2 ; ; Author(s): SmOke_N (Ron Nielsen) ; ;=================================================================================================== Func _ProcessGetParent($i_pid) Local Const $TH32CS_SNAPPROCESS = 0x00000002 Local $a_tool_help = DllCall("Kernel32.dll", "long", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPPROCESS, "int", 0) If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_pid) Local $tagPROCESSENTRY32 = _ DllStructCreate _ ( _ "dword dwsize;" & _ "dword cntUsage;" & _ "dword th32ProcessID;" & _ "uint th32DefaultHeapID;" & _ "dword th32ModuleID;" & _ "dword cntThreads;" & _ "dword th32ParentProcessID;" & _ "long pcPriClassBase;" & _ "dword dwFlags;" & _ "char szExeFile[260]" _ ) DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32)) Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32) Local $a_pfirst = DllCall("Kernel32.dll", "int", "Process32First", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32) If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_pid) Local $a_pnext, $i_return = 0 If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_pid Then $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID") DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0]) If $i_return Then Return $i_return Return $i_pid EndIf While 1 $a_pnext = DLLCall("Kernel32.dll", "int", "Process32Next", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32) If IsArray($a_pnext) And $a_pnext[0] = 0 Then ExitLoop If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_pid Then $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID") If $i_return Then ExitLoop $i_return = $i_pid ExitLoop EndIf WEnd If $i_return = "" Then $i_return = $i_pid DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0]) Return $i_return EndFunc OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Astrali Posted January 7, 2010 Author Share Posted January 7, 2010 Wow O_o thats lots of stuff to close a window Thanks for your big help! i will go and study your work now (i like to understand what i do!) Thanks Thanks Thanks! - Lars - 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