0Camus0 Posted January 15, 2016 Share Posted January 15, 2016 Hello, I want to open one IExplorer, set a page, then next open IExplorer and have control over their pids and hwnd.I found out that once you open once instance of iexplorer, the next instance wont appear on WinList(). Similarly WinGetProcess wont return the pid.I'm attaching my code but you can check by doing this:expandcollapse popup#include <MsgBoxConstants.au3> Local $InternetExplorer_PID_1 = Run("iexplore.exe") Sleep(4000) Local $InternetExplorer_PID_2 = Run("iexplore.exe") Sleep(4000) Local $found_1_pid = ExistIEProcess($InternetExplorer_PID_1) Local $found_2_pid = ExistIEProcess($InternetExplorer_PID_2) Local $found_1_hwnd =FindCurrentIE($InternetExplorer_PID_1) Local $found_2_hwnd =FindCurrentIE($InternetExplorer_PID_2) MsgBox($MB_SYSTEMMODAL, "ExistIEProcess", "PID 1 found: " & $found_1_pid & @CRLF & " PID 2 found: " & $found_2_pid) MsgBox($MB_SYSTEMMODAL, "FindCurrentIE ", "HWND 1 found: " & $found_1_hwnd & @CRLF & "HWND 2 found: " & $found_2_hwnd) Func ExistIEProcess($pid_) $found_proc = 0 Local $aProcessList = ProcessList() For $i_ = 1 To $aProcessList[0][0] If $aProcessList[$i_][1] == $pid_ Then $found_proc = 1 EndIf Next return $found_proc EndFunc Func FindCurrentIE($currentPID) Local $aList = WinList("[CLASS:IEFrame]") Local $found = 0 For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" Then Local $current_hwnd = $aList[$i][1] Local $current_PID = WinGetProcess($current_hwnd) If $currentPID == $current_PID Then $found = 1 EndIf EndIf Next return $found EndFunc As you can see, it succeed in finding the pid for the first only, like any other pid of the same .exe aren't registered, and I suppose it's the same map for the HWND list attached to that pids. It would be really helpful to have a similar function to WinGetProcess but something like ProcessGetHWNDListFromThisPID, in other words, a list of the HWND assotiated to that pid. This is really important for me, I was looking for the source code but I didn't find any repo or working branch. Could you help me? Thanks! HelloWorld.au3 Link to comment Share on other sites More sharing options...
0Camus0 Posted January 18, 2016 Author Share Posted January 18, 2016 Anyone? I use the process list to control specific open windows, with this issue I cannot have two instances of the same program. Thanks. Link to comment Share on other sites More sharing options...
0Camus0 Posted January 22, 2016 Author Share Posted January 22, 2016 Can I find the source somewhere to try to fix this? Thanks. Link to comment Share on other sites More sharing options...
kaisies Posted January 22, 2016 Share Posted January 22, 2016 (edited) On 1/15/2016 at 8:46 PM, 0Camus0 said: expandcollapse popup#include <MsgBoxConstants.au3> Local $InternetExplorer_PID_1 = Run("iexplore.exe") Sleep(4000) Local $InternetExplorer_PID_2 = Run("iexplore.exe") Sleep(4000) Local $found_1_pid = ExistIEProcess($InternetExplorer_PID_1) Local $found_2_pid = ExistIEProcess($InternetExplorer_PID_2) Local $found_1_hwnd =FindCurrentIE($InternetExplorer_PID_1) Local $found_2_hwnd =FindCurrentIE($InternetExplorer_PID_2) MsgBox($MB_SYSTEMMODAL, "ExistIEProcess", "PID 1 found: " & $found_1_pid & @CRLF & " PID 2 found: " & $found_2_pid) MsgBox($MB_SYSTEMMODAL, "FindCurrentIE ", "HWND 1 found: " & $found_1_hwnd & @CRLF & "HWND 2 found: " & $found_2_hwnd) Func ExistIEProcess($pid_) $found_proc = 0 Local $aProcessList = ProcessList() For $i_ = 1 To $aProcessList[0][0] If $aProcessList[$i_][1] == $pid_ Then $found_proc = 1 EndIf Next return $found_proc EndFunc Func FindCurrentIE($currentPID) Local $aList = WinList("[CLASS:IEFrame]") Local $found = 0 For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" Then Local $current_hwnd = $aList[$i][1] Local $current_PID = WinGetProcess($current_hwnd) If $currentPID == $current_PID Then $found = 1 EndIf EndIf Next return $found EndFunc Both of your returns return $found, NOT the PID... so, that'll never work. For the Hwnd, look into WinGetHandle. Edited January 22, 2016 by kaisies Link to comment Share on other sites More sharing options...
0Camus0 Posted January 22, 2016 Author Share Posted January 22, 2016 (edited) The example is just to show 0 if isn't found or 1 if it is found, it's just a flag, the comparison of the PID is here: If $currentPID == $current_PID Then $found = 1 EndIf Edit: I used WinGetHandle but it only retrieves the last active window, if you have more than 2 instances of the same program it only returns the latest, thats why I'm using this. Edited January 22, 2016 by 0Camus0 Link to comment Share on other sites More sharing options...
kaisies Posted January 22, 2016 Share Posted January 22, 2016 (edited) 6 minutes ago, 0Camus0 said: The example is just to show 0 if isn't found or 1 if it is found, it's just a flag, the comparison of the PID is here: If $currentPID == $current_PID Then $found = 1 EndIf I see. When I run this, it properly finds both the PID's of IExplore. Edited January 22, 2016 by kaisies Link to comment Share on other sites More sharing options...
water Posted January 22, 2016 Share Posted January 22, 2016 This shows all processes started by _IECreate: #include <ie.au3> #include <array.au3> $oIE1 = _iecreate() $oIE2 = _iecreate() $aList = ProcessList("iexplore.exe") _ArrayDisplay($aList) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted January 22, 2016 Share Posted January 22, 2016 BTW: Why don't you use the IE UDF that comes with AutoIt? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
0Camus0 Posted January 22, 2016 Author Share Posted January 22, 2016 1 hour ago, kaisies said: I see. When I run this, it properly finds both the PID's of IExplore. Really? My output is one for the first process and zero for the second, in other words the second PID is not in the ProcessList() Can you run my example and paste the output just to confirm? Quote BTW: Why don't you use the IE UDF that comes with AutoIt? Because I want to do this for every other programs, not just IE. My purpose with this is to have co related the PIDs and the HWND, that way I can say, instance_x of X program, give me your HWND so I can minimize it or whatever. If you know a way of have control (HWND) over several instances of the same program let me know. Thanks in advance. Link to comment Share on other sites More sharing options...
0Camus0 Posted January 22, 2016 Author Share Posted January 22, 2016 I closed all my instances of Iexplorer and run the example I posted above and I got this results, see the attachment. You see something wrong with my example, it clearly fail to find the second PID and the second HWND. Link to comment Share on other sites More sharing options...
PACaleala Posted January 23, 2016 Share Posted January 23, 2016 @0Camus0 this is called GIGO: For the start you do not run IE (one instance or two), do not check the help file and do not have any error checking. Do not be surprised by the results You get what you deserve. water 1 Link to comment Share on other sites More sharing options...
0Camus0 Posted January 25, 2016 Author Share Posted January 25, 2016 On 1/23/2016 at 8:57 PM, PACaleala said: @0Camus0 this is called GIGO: For the start you do not run IE (one instance or two), do not check the help file and do not have any error checking. Do not be surprised by the results You get what you deserve. Can you elaborate, I posted here because there are no more functions to deal with HWND/PID. Why I should not have one or more instances of IE? The program I posted is an example, not the actual code I'm using. Quote You get what you deserve. Ok I'm done asking for help here. Link to comment Share on other sites More sharing options...
0Camus0 Posted January 25, 2016 Author Share Posted January 25, 2016 On 1/23/2016 at 8:57 PM, PACaleala said: @0Camus0 this is called GIGO: For the start you do not run IE (one instance or two), do not check the help file and do not have any error checking. Do not be surprised by the results You get what you deserve. Can you elaborate, I posted here because there are no more functions to deal with HWND/PID. Why I should not have one or more instances of IE? The program I posted is an example, not the actual code I'm using. Quote You get what you deserve. Ok I'm done asking for help here. Link to comment Share on other sites More sharing options...
0Camus0 Posted January 25, 2016 Author Share Posted January 25, 2016 On 1/23/2016 at 8:57 PM, PACaleala said: @0Camus0 this is called GIGO: For the start you do not run IE (one instance or two), do not check the help file and do not have any error checking. Do not be surprised by the results You get what you deserve. Can you elaborate, I posted here because there are no more functions to deal with HWND/PID. Why I should not have one or more instances of IE? The program I posted is an example, not the actual code I'm using. Quote You get what you deserve. Ok I'm done asking for help here. 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