Jump to content

Recommended Posts

Posted

#include <array.au3>

$PID = Run(@ProgramFilesDir&'\Internet Explorer\iexplore.exe "' & "http://google.com" & '"', "", @SW_SHOW)

MsgBox(0, 0, $PID)
MsgBox(0, 0, ProcessExists($PID))

This code will first return $pid then it will also return $pid with processexists() function, but it will only work if there are no other instances of "iexplore.exe" openned before its run.

If there is already iexplore.exe open and you run this then it will return 0 with processexists($pid), which means i cant check if processexists if user already has one iexplore.exe instance while he runs this, any ideas?

Posted

In your example you're looking for the exact PID created by the Run() function. If you want to catch any instance of the Internet Explorer use ProcessExists("iexplore.exe") instead, even better would be ProcessList("iexplore.exe") if you're looking for more than one instance.

Posted

Kafu,

if i use processexists("iexplore.exe") it doesnt mean much to me if there are multiple iexplore processes there, understand what i mean? I need to check for the $pid that i retrieve with RUn()

Also whats weird is that when i get this $pid with run and afterwards i do processlist("iexplore.exe") it doesnt show up on the list at all ... FOr some reason it dissapears

I need a way to check when is this $pid returned by run() opened or not but seems it dissapears right away if there are already multiple iexplore.exe instances opened before run() is used

Posted (edited)

I don't use IE 9 but here is a way to get the new PID created for iexplore.exe.

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include <Array.au3>

Global $aArrayPrevious[1][2] = [[0]]

Global $iPID = Run(@ProgramFilesDir & 'Internet Exploreriexplore.exe "' & "http://duckduckgo.com" & '"', "", @SW_SHOW)

ConsoleWrite("PID >> " & $iPID & @LF)
Sleep(1000) ; Wait for the previous process to close and spawn a new process.
ConsoleWrite("ProcessExists >> " & ProcessExists(_GetIEProcess()) & @LF)

Func _GetIEProcess($sProcess = "iexplore.exe") ; By guinness. [Find the newest process created]
    Local $aArray, $iPID

    $aArray = ProcessList($sProcess)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    $iPID = _ArrayDiff($aArrayPrevious, $aArray)
    $aArrayPrevious = $aArray
    Return $iPID
EndFunc   ;==>_GetIEProcess

Func _ArrayDiff(ByRef $aArrayMin, ByRef $aArrayMax) ; By Yashied.
    For $A = $aArrayMax[0][0] To 1 Step -1
        For $B = $aArrayMin[0][0] To 1 Step -1
            If $aArrayMax[$A][1] = $aArrayMin[$B][1] Then
                ContinueLoop 2
            EndIf
        Next
        Return $aArrayMax[$A][1]
    Next
    Return 0
EndFunc   ;==>_ArrayDiff
Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

thanks guinness for the effort, it is still weird that pid is different then whats returned by

_GetIEProcess(), it could work but i didnt test since i use another method to validate stuff now, relying on _IE.au3

Posted (edited)

I've never really had a need to use the IE functions, but what I did notice is it creates a second instance of iexplore.exe and then closes the first instance, couldn't tell you why it does that though, maybe someone who uses IE could elaborate.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...