Jump to content

watch any browser


Recommended Posts

hello friends

i need ur helps

$_WinList = WinList ( "[REGEXPCLASS:(IEFrame|Mozilla|Chrome)]" )



 dim $pid[$_WinList[0][0]+1]
 $_l=0
For $_I = 1 To UBound ( $_WinList ) -1
    If $_WinList[$_I][0] <> '' Then
        $_Classname = _WinGetClassName ( $_WinList[$_I][1] )
        If $_Classname Then
          MsgBox(0, $_WinList[$_I][0],"Dilip" )
       ;   MsgBox ( 0, WinGetProcess($_WinList[$_I][0]) ,"Dilip" )
         
         $pid[$_l] = WinGetProcess($_WinList[$_I][0])
         

            msgbox(0,"Pid is",$pid[$_l])

         ;ProcessWaitClose($pid)

          ;   msgbox(0,"Dilip","Why U Closing !! ")
        $_l = $_l+1

        
        EndIf
    EndIf
Next
 msgbox(0,"Number of browser",$_l)
; $chk=0
; while($chk<$_l)
     
 
 
 
 ;if ProcessExists($pid[$chk]) Then
     
; else 
     
    ; MsgBox(0,"dilip","Close")
     
; EndIf
 
; $chk=$chk+1
 
 
; WEnd
 
 
 
 
Func _WinGetClassName ( $hWnd )
    If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd )
    $aClassName = DLLCall ( "user32.dll", "int", "GetClassName", "hWnd", $hWnd, "str", "", "int", 64 )
    If Not @error And $aClassName[0] <> 0 Then Return $aClassName[2]
EndFunc

Using This Code I m Able to Know How Many browser is open...

Now I Have following Problem---

1-> if i open more then 1 instance of any browser thn its PID is Same...

2-> i want That if any browser is close then it show message..

3-> and if new browser is open then it also watch by this script...

Plse give me some idea....

Thanks...

Link to comment
Share on other sites

1-> if i open more then 1 instance of any browser thn its PID is Same...

2-> i want That if any browser is close then it show message..

3-> and if new browser is open then it also watch by this script...

Plse give me some idea....

Thanks...

1-> if i open more then 1 instance of any browser thn its PID is Same...

It's Not exact, Firefox 5 use 1 Pid for several instances, but not IE.

And chrome use one Pid by Tab even in a single window.

Each browser has a different way to work...

2-> i want That if any browser is close then it show message..

So you need to monitor ProcessList And WinList...

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Try this

#Include <WinAPIEx.au3>
#Include <Array.au3>

$_BrowserProcessArray = _MultiProcessList ( 'chrome,iexplore,firefox,iron' ) ; add your browser executable name 
_ArrayDisplay ( $_BrowserProcessArray )  

For $_I = 1 To UBound ( $_BrowserProcessArray ) -1
    ConsoleWrite ( '!->-- ' & $_BrowserProcessArray[$_I][0] & ", Pid : " & $_BrowserProcessArray[$_I][1] & @Crlf )
    $aWnd = _WinAPI_EnumProcessWindows ( $_BrowserProcessArray[$_I][1], False )
    If IsArray ( $aWnd ) Then
        For $_J = 1 To UBound ( $aWnd ) -1
            $_Title = WinGetTitle ( $aWnd[$_J][0] )
            If $_Title And _IsVisible ( $aWnd[$_J][0] ) Then _
            ConsoleWrite ( "-->--            WinGetTitle ( $aWnd[" & $_J & "][0] ) : " & $_Title & @Crlf )
        Next
    EndIf
Next

Func _IsVisible ( $_Hwnd )
    If BitAnd ( WinGetState ( $_Hwnd ), 2 ) Then Return 1
EndFunc ;==> _IsVisible ( )

Func _MultiProcessList ( $_Filter )
    $_FilterArray = StringSplit ( $_Filter, ',' )
    If @error Then Return
    Local $_GlobalList[1][1]
    For $_I = 1 To UBound ( $_FilterArray ) -1
        $_List = ProcessList ( $_FilterArray[$_I] & '.exe' )
        If Not @error Then _Array2DConcatenate ( $_GlobalList, $_List )
    Next
    Return $_GlobalList
EndFunc ;==> _MultiProcessList ( )

Func _Array2DConcatenate ( ByRef $_Array2dOutput, Const ByRef $_Array2dToAdd )
    Local $_UBound1 = UBound ( $_Array2dOutput ) - 1
    Local $_UBound2 = UBound ( $_Array2dToAdd ) -1
    ReDim $_Array2dOutput[$_UBound1 + $_UBound2 + 1][2]
    For $_I = 1 To $_UBound2
        For $_J = 0 To 1
            $_Array2dOutput[$_UBound1 + $_I][$_J] = $_Array2dToAdd[$_I][$_J]
        Next
    Next
    $_Array2dOutput[0][0]=UBound ( $_Array2dOutput ) -1
EndFunc ;==> _Array2DConcatenate ( )

With this, you get the list of browsers process and their (visible) windows.

!->-- iexplore.exe, Pid : 2600

-->-- WinGetTitle ( $aWnd[12][0] ) : GImageX - AutoItScript

!->-- iexplore.exe, Pid : 2920

-->-- WinGetTitle ( $aWnd[12][0] ) : Google Actualités

!->-- firefox.exe, Pid : 3896

-->-- WinGetTitle ( $aWnd[10][0] ) : Google Images - Mozilla Firefox

-->-- WinGetTitle ( $aWnd[11][0] ) : YouTube - Broadcast Yourself. - Mozilla Firefox

!->-- iron.exe, Pid : 348

-->-- WinGetTitle ( $aWnd[5][0] ) : AutoIt Français • Afficher le sujet - [..] Titre de fenêtre / processus / variable - Iron

!->-- iron.exe, Pid : 3552

!->-- iron.exe, Pid : 3940

!->-- iron.exe, Pid : 1664

So you can see :

For Firefox if a process is detected you need to monitoring the windows because there is only one process.

For Iron ( or chrome it's the same ) If a window is detected you need to monitoring the process because there is only one window. ( may be depends of browser settings )

And IE you can monitoring process or windows !

I hope it help ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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