JohnOne Posted January 10, 2011 Posted January 10, 2011 I was asking about scite, as It spawns a new instance of the script other than the one you run if #RequireAdmin is used. Wernt sure if this could have been affecting it. But there is definately something strange going on. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
MrPPP Posted January 11, 2011 Author Posted January 11, 2011 I'm sorry. I did not understand what you meant by sorting by image. And I wasn't clear enough. The first time I run the script there is no iexplorer.exe running ( I checked, like you said, with taskmanager). Then, I run the script. Run(@ProgramFilesDir&"\internet explorer\iexplore.exe "&$sURL, "",@SW_SHOW) will open 1 IE window. But 2 iexplorer.exe processes are opened. That is why you see two iexplorer.exe processes in the list that is returned by the script. Now, I do not know why it opens two iexplorer.exe processes. I guess there is one process for every tab or window and one to collect them all together. But I don't know why that changes the PID. I'll now run your version of the script and post the results. I'll first close my browser to have the least amount of interference (even if I dont use IE normally). See you in 5;)
MrPPP Posted January 11, 2011 Author Posted January 11, 2011 Same result: expandcollapse popupPid as returned by Run: 4180 [System Process] 0 ACEngSvr.exe 2668 ACMON.exe 2252 alg.exe 3572 ATI2EVXX.EXE 1228 ATI2EVXX.EXE 1752 ATKOSD.exe 2672 AutoIt3.exe 4312 ccc.exe 2416 CLCapSvc.exe 300 CLMLServer.exe 460 CLMLService.exe 496 CLSched.exe 2124 CSRSS.EXE 984 ctfmon.exe 3248 DMedia.exe 1888 Dot1XCfg.exe 2568 ehmsas.exe 1472 ehtray.exe 1148 EOUWiz.exe 3208 EvtEng.exe 1700 Explorer.EXE 356 gnotify.exe 516 GoogleUpdate.exe 3340 HControl.exe 612 iexplore.exe 4180 iexplore.exe 4628 iFrmewrk.exe 3116 JQS.EXE 568 LSASS.EXE 1072 MOM.exe 3528 MsMpEng.exe 1484 msseces.exe 3160 NOTEPAD.EXE 4556 PnkBstrA.exe 1416 RegSrvc.exe 1452 RTHDCPL.EXE 3428 S24EvMon.exe 1824 SciTE.exe 5172 services.exe 1060 Skype.exe 2368 skypePM.exe 3440 smss.exe 924 spoolsv.exe 1140 svchost.exe 1260 svchost.exe 1340 svchost.exe 1636 svchost.exe 1856 svchost.exe 1932 svchost.exe 1996 svchost.exe 204 svchost.exe 456 SynTPEnh.exe 3052 System 4 wcourier.exe 4000 winlogon.exe 1016 wmiapsrv.exe 2084 wuauclt.exe 1480 ZCfgSvc.exe 2296 expandcollapse popup[System Process] 0 ACEngSvr.exe 2668 ACMON.exe 2252 alg.exe 3572 ATI2EVXX.EXE 1228 ATI2EVXX.EXE 1752 ATKOSD.exe 2672 AutoIt3.exe 4980 ccc.exe 2416 CLCapSvc.exe 300 CLMLServer.exe 460 CLMLService.exe 496 CLSched.exe 2124 CSRSS.EXE 984 ctfmon.exe 3248 DMedia.exe 1888 Dot1XCfg.exe 2568 ehmsas.exe 1472 ehtray.exe 1148 EOUWiz.exe 3208 EvtEng.exe 1700 Explorer.EXE 356 gnotify.exe 516 GoogleUpdate.exe 3340 HControl.exe 612 iexplore.exe 4180 iexplore.exe 4628 iexplore.exe 5076 iFrmewrk.exe 3116 JQS.EXE 568 LSASS.EXE 1072 MOM.exe 3528 MsMpEng.exe 1484 msseces.exe 3160 NOTEPAD.EXE 4556 NOTEPAD.EXE 5048 PnkBstrA.exe 1416 RegSrvc.exe 1452 RTHDCPL.EXE 3428 S24EvMon.exe 1824 SciTE.exe 5172 services.exe 1060 Skype.exe 2368 skypePM.exe 3440 smss.exe 924 spoolsv.exe 1140 svchost.exe 1260 svchost.exe 1340 svchost.exe 1636 svchost.exe 1856 svchost.exe 1932 svchost.exe 1996 svchost.exe 204 svchost.exe 456 SynTPEnh.exe 3052 System 4 wcourier.exe 4000 winlogon.exe 1016 wmiapsrv.exe 2084 wuauclt.exe 1480 ZCfgSvc.exe 2296 If you have any clue why this happens or how we could find some more hints as to find out why/how it happens... I'm very interested... Greetings!
JohnOne Posted January 11, 2011 Posted January 11, 2011 Forgive me if I'm wrong but those PIDs are different, all 3 of them, an you have the PID of the one you started. ps it is normal for 2 processes to show when running IE, (well at least it has been in my experience. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
MrPPP Posted January 11, 2011 Author Posted January 11, 2011 (edited) Btw, If I do: sleep ( 1000 ) $hIE1 = WinGetHandle ( "[TITLE:Google; INSTANCE:1]" ) $hIE2 = WinGetHandle ( "[TITLE:Google; INSTANCE:2]" ) WinSetState ( $hIE1, "", @SW_MINIMIZE ) ; just to make sure I have the good windows. sleep ( 2000 ) WinSetState ( $hIE2, "", @SW_MINIMIZE ) $pid1 = WInGetProcess ( $hIE1 ) $pid2 = WInGetProcess ( $hIE2 ) MsgBox ( 0, "1", $hIE1&" "&$pid1 ) MsgBox ( 0, "2", $hIE2&" "&$pid2 ) Both windows return 4180 as PID (and have different HWND) (no idea if that helps). Greetz! Edited January 13, 2011 by MrPPP
JohnOne Posted January 11, 2011 Posted January 11, 2011 PsaltDS said in post that its normal to have multiplr windows with the same PID.And as I recall, you were after the windows handle, were you not? which you have gotten.This thread is confusing me I need a cup of tea AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Ascend4nt Posted January 12, 2011 Posted January 12, 2011 This is all quite amusing. MrPPP, I've seen this happen myself - you run a few instances of Internet Explorer, they shows up in Task Manager, but the Windows themselves get attached to only a single process. This is more or less causing one of the processes to be like a 'server' which handles the window messages, while the other processes are there for the internal processing (I guess). In any case, the simplest method here is to run the process using @SW_HIDE, then get a WinList with a "[CLASS:IEFrame]", find the one window that is hidden and identify that as the one you created. Here's some code (you may have to adjust the first sleep..): ConsoleWrite("Process ID:"&Run(@ProgramFilesDir & "\internet explorer\iexplore.exe")&@LF) ConsoleWrite("Process ID:"&Run(@ProgramFilesDir & "\internet explorer\iexplore.exe",'',@SW_HIDE)&@LF) ProcessWait("iexplore.exe") WinWait("[CLASS:IEFrame]") ; For some reason, even with the 'Waits' above, it still catches the wrong window without a sleep Sleep(500) $hWnd=0 While 1 $aWinList=WinList("[CLASS:IEFrame]") For $i=1 To $aWinList[0][0] If BitAND(WinGetState($aWinList[$i][1]),2)=0 Then $hWnd=$aWinList[$i][1] ExitLoop 2 EndIf Next Sleep(100) WEnd If $hWnd<>0 Then WinSetState($hWnd,'',@SW_SHOW) ConsoleWrite("Window found, handle:"&$hWnd&", PID #:"&WinGetProcess($hWnd)&@LF) EndIf My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
bo8ster Posted January 12, 2011 Posted January 12, 2011 (edited) I had a cup of coffee so now I am good. 1. PIDs do not change while a process is instantiated, I don't know why you proceed to argue the point when you are wrong. 2. Running IE 7 on XP only runs only one process for me. I have seen java apps require more that one process to run however one process spawned the second, thus once process has overall control of the rest, they are not acting completely independently. There are many examples of this however I have never seen IE do this, this is not say IE does not do this, IE is stupid and does stupid stuff sometimes. Edit: @Ascend4nt, this is true and in the case it should not matter which process is referenced as it is still the same "program" even though it is broken into different process. I would use that ever the autoit info tool gave me. I have not put this into practice however I assume this to be true. 3. Post #23 is not the same result as what was posted in post #17. Post 23 had 3 processes running after the first run while post 17 had two processes running after the first run. Not the same result. If the code is the same (which I can only assume it is) then the only other possibility is the environment it is running on. 4. Re Post# 25, as stated before Window Handles are very different from PIDs. If that code is working (and $hIE2 is being assigned with a valid address that is in WinList) then it means there is more that one instance of IE running, and I know this because I know how the function (WinGetHandle) works under the hood. If you were to put error checking and print out all the results you would fund a logic error, it may execute however it does not mean it is correct. 5. I have re-done the code, give this a try. expandcollapse popup#include <Array.au3> If (ProcessExists("iexplore.exe") <> 0) Then ConsoleWrite("iexplore.exe process is open, killing now ...." &@CRLF) Run("taskkill /F /IM iexplore.exe") if (ProcessWaitClose("iexplore.exe", 10) <> 1) Then ConsoleWriteError("iexplore.exe could not be killed, ending program") Exit (1) EndIf EndIf $sURL = "www.google.nl" Local Const $pid = Run(@ProgramFilesDir & "\internet explorer\iexplore.exe " & $sURL, "", @SW_SHOW) ; ensures it cannot be change once set ConsoleWrite($pid & @CRLF) ; print out to ensure your search is correct. ;~ Run("notepad.exe") ; why is this where? Sleep(1000) ;~ Global $hOut = WinGetTitle("Naamloos") ConsoleWrite("Pid as returned by Run: " & $pid & @CRLF) ;~ ControlSend($hOut, "", "[CLASS:Edit; INSTANCE:1]", "Pid as returned by Run: " & $pid & "{ENTER}{ENTER}") Local $aProcessList = ProcessList() For $i = 1 To $aProcessList[0][0] If ($aProcessList[$i][0] == "iexplore.exe") Then ConsoleWrite($aProcessList[$i][0] & " " & $aProcessList[$i][1] & @CRLF) EndIf ;~ ControlSend($hOut, "", "[CLASS:Edit; INSTANCE:1]", $aProcessList[$i][0] & " " & $aProcessList[$i][1] & "{ENTER}") Next sleep ( 1000 ) Local $hIE1 = WinGetHandle ( "[TITLE:Google; INSTANCE:1]" ) Local $hIE2 = WinGetHandle ( "[TITLE:Google; INSTANCE:2]" ) WinSetState ( $hIE1, "", @SW_MINIMIZE ) ; just to make sure I have the good windows. sleep ( 2000 ) WinSetState ( $hIE2, "", @SW_MINIMIZE ) $pid1 = WInGetProcess ( $hIE1 ) $pid2 = WInGetProcess ( $hIE2 ) ConsoleWrite ( "1: " & $hIE1&" "&$pid1 & @CRLF ) ConsoleWrite ( "2: "& $hIE2&" "&$pid2 & @CRLF) 6. Try this for for something different. #include <IE.au3> _IECreate("www.google.nl") Local $aProcessList = ProcessList() For $i = 1 To $aProcessList[0][0] If ($aProcessList[$i][0] == "iexplore.exe") Then ConsoleWrite($aProcessList[$i][0] & " " & $aProcessList[$i][1] & @CRLF) EndIf ;~ ControlSend($hOut, "", "[CLASS:Edit; INSTANCE:1]", $aProcessList[$i][0] & " " & $aProcessList[$i][1] & "{ENTER}") Next Edited January 12, 2011 by bo8ster Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]
MrPPP Posted January 13, 2011 Author Posted January 13, 2011 This is all quite amusing. MrPPP, I've seen this happen myself - you run a few instances of Internet Explorer, they shows up in Task Manager, but the Windows themselves get attached to only a single process. This is more or less causing one of the processes to be like a 'server' which handles the window messages, while the other processes are there for the internal processing (I guess). In any case, the simplest method here is to run the process using @SW_HIDE, then get a WinList with a "[CLASS:IEFrame]", find the one window that is hidden and identify that as the one you created. Here's some code (you may have to adjust the first sleep..): ConsoleWrite("Process ID:"&Run(@ProgramFilesDir & "\internet explorer\iexplore.exe")&@LF) ConsoleWrite("Process ID:"&Run(@ProgramFilesDir & "\internet explorer\iexplore.exe",'',@SW_HIDE)&@LF) ProcessWait("iexplore.exe") WinWait("[CLASS:IEFrame]") ; For some reason, even with the 'Waits' above, it still catches the wrong window without a sleep Sleep(500) $hWnd=0 While 1 $aWinList=WinList("[CLASS:IEFrame]") For $i=1 To $aWinList[0][0] If BitAND(WinGetState($aWinList[$i][1]),2)=0 Then $hWnd=$aWinList[$i][1] ExitLoop 2 EndIf Next Sleep(100) WEnd If $hWnd<>0 Then WinSetState($hWnd,'',@SW_SHOW) ConsoleWrite("Window found, handle:"&$hWnd&", PID #:"&WinGetProcess($hWnd)&@LF) EndIf This might be a good solution. I'm sick today so I will try it a bit later when I'm feeling better. I'll get back to you if I got it. Thanks!
AGlassman Posted March 31, 2016 Posted March 31, 2016 Old thread, but very helpful. And still relevant. I can confirm, that for IE11 on Win7, the PID you get back from a RUN of IE is NOT the PID associated with the new window that opens. Doesn't matter if IE is running already or not. Ascend4nt's idea of opening the new IE window Hidden and then looking for the only Hidden IE Window is clever. I'll try a similar approach.
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