Jump to content



Photo

Window Tracer


  • Please log in to reply
4 replies to this topic

#1 Monamo

Monamo

    Sushi

  • Active Members
  • PipPipPipPipPipPip
  • 476 posts

Posted 26 February 2009 - 08:48 PM

Current Build: v1.2 (27 FEB 2009)

I've had to go through hoops too many times trying to track down the originating process when a random notification/dialog pops up on my system. I wrote the following as a quick way to trace them.

Running the script provides you with a small GUI that contains a combobox of visible windows. Selecting a window from the list will provide a messagebox with process information (process executable, file location, PID) and will open the containing folder in Windows Explorer.

If it's of use to you, have at it. Otherwise, thanks for taking a look. Comments welcome.

Version History:
v1.0 (26 FEB 2009) :Note:Codebase is for AutoIt 3.2.10.0 (still at this build by work mandate), so those running the later builds will have to account for the replacement of the GUIConstants.au3 reference with GUIConstantsEx.au3 and possible others.
v1.2 (27 FEB 2009) : Codebase updated to function with AutoIt v3.3.0.0 (Yay for VMWare)

Attached File  Window_Tracer_v1_2.au3   4.08KB   274 downloads

Edit: code update

Edited by Monamo, 27 February 2009 - 05:29 PM.

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window TracerNew!







#2 trandatnh

trandatnh

    Seeker

  • Active Members
  • 39 posts

Posted 26 February 2009 - 09:47 PM

I'm a new to autoit, When run this script I get this error. Tell me how to fix it plz :P
WARNING: $CBS_DROPDOWNLIST: possibly used before declaration. $comboWindows = GUICtrlCreateCombo("", 10, 10, $GUIWidth - 20, 20,$CBS_DROPDOWNLIST) ERROR: $CBS_DROPDOWNLIST: undeclared global variable. $comboWindows = GUICtrlCreateCombo("", 10, 10, $GUIWidth - 20, 20,$CBS_DROPDOWNLIST)


#3 maqleod

maqleod

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 313 posts

Posted 27 February 2009 - 03:12 AM

I'm a new to autoit, When run this script I get this error. Tell me how to fix it plz :P

WARNING: $CBS_DROPDOWNLIST: possibly used before declaration. $comboWindows = GUICtrlCreateCombo("", 10, 10, $GUIWidth - 20, 20,$CBS_DROPDOWNLIST) ERROR: $CBS_DROPDOWNLIST: undeclared global variable. $comboWindows = GUICtrlCreateCombo("", 10, 10, $GUIWidth - 20, 20,$CBS_DROPDOWNLIST)

you need to add #include <comboconstants.au3> to the beginning of your script
You can download my projects at: Pulsar Software

#4 Monamo

Monamo

    Sushi

  • Active Members
  • PipPipPipPipPipPip
  • 476 posts

Posted 27 February 2009 - 05:33 PM

I'm a new to autoit, When run this script I get this error. Tell me how to fix it plz :P

WARNING: $CBS_DROPDOWNLIST: possibly used before declaration. $comboWindows = GUICtrlCreateCombo("", 10, 10, $GUIWidth - 20, 20,$CBS_DROPDOWNLIST) ERROR: $CBS_DROPDOWNLIST: undeclared global variable. $comboWindows = GUICtrlCreateCombo("", 10, 10, $GUIWidth - 20, 20,$CBS_DROPDOWNLIST)

The issue was because the script was written based upon AutoIt v3.2.10.0 (as noted in the original post). There were code changes made in subsequent releases that caused other #include entries to be required. The code in the original post has been updated to support AutoIt v3.3.0.0.

Enjoy!
- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window TracerNew!

#5 AZJIO

AZJIO

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,081 posts

Posted 22 March 2010 - 10:40 AM

Thank you Monamo

Plain Text         
; @AZJIO 22.03.2010 #NoTrayIcon Global $aVisibleWindows[1] = ["0"], $sTmp, $sTitle GUICreate("SaveFolders", 500, 200) GUICtrlCreateLabel("Session", 15, 15, 41, 18) $Session = GUICtrlCreateCombo("current", 15, 32, 470, 25, 0x3) ; $CBS_DROPDOWNLIST=0x3 GUICtrlCreateLabel("folders", 15, 71, 74, 18) $Folderlist = GUICtrlCreateCombo("", 15, 88, 470, 25, 0x3) $Open = GUICtrlCreateButton("Open", 390, 12, 73, 20) GUICtrlSetTip(-1, "Open session") $Save = GUICtrlCreateButton("Save", 390, 68, 73, 20) GUICtrlSetTip(-1, "Save session") $Openfolder = GUICtrlCreateButton("Open all folders", 80, 130, 130, 33) $close = GUICtrlCreateButton("Close all folders", 290, 130, 130, 33) _GetWindows() _search() GUISetState () While 1     $msg = GUIGetMsg()     Select         Case $msg = $Save             $file_save = FileSaveDialog( "Save session", @ScriptDir & "", "Session (*.inc)", 24, "Session.inc")             If @error Then ContinueLoop             $file = FileOpen($file_save, 2)             If $file = -1 Then                MsgBox(0, "Error", "Unable to open file.")                ContinueLoop             EndIf             FileWrite($file, $sTmp)             FileClose($file)                     Case $msg = $Open             $file_open = FileOpenDialog("Open session", @ScriptDir & "", "Session (*.inc)", 1 + 4 , "Session.inc")             If @error Then ContinueLoop             $file = FileOpen($file_open, 0)             If $file = -1 Then                MsgBox(0, "Error", "Unable to open file.")                ContinueLoop             EndIf             $sTmp = FileRead($file)             GUICtrlSetData($Session, $file_open)             GUICtrlSetData($Folderlist, $sTmp)             FileClose($file)                     Case $msg = $Openfolder             $aPath = StringSplit($sTmp, "|")             For $i=1 To $aPath [0]                 If FileExists($aPath[$i]) Then Run('Explorer.exe '&$aPath[$i])             Next             _GetWindows()             Sleep(300)             WinActivate ( "SaveFolders")                     Case $msg = $close             $aTitle = StringSplit($sTitle, "|")             For $i=1 To $aTitle [0]                 If WinExists ($aTitle[$i]) And $aTitle[$i] <> "Program Manager" Then WinClose ($aTitle[$i])             Next             _GetWindows()                     Case $msg = $Session             $file_open=GUICtrlRead ($Session)             If $file_open ='current' Then             _GetWindows()             Else             $file = FileOpen($file_open, 0)             If $file = -1 Then                MsgBox(0, "Error", "Unable to open file.")                ContinueLoop             EndIf             $sTmp = FileRead($file)             FileClose($file)             GUICtrlSetData($Session, $file_open)             If $sTmp <> '' Then             GUICtrlSendMsg($Folderlist, 0x14B, 0, 0)             GUICtrlSetData($Folderlist, $sTmp)             EndIf             EndIf                     Case $msg = $Folderlist                 $myFolder = GUICtrlRead($Folderlist)                 If FileExists($myFolder) Then                     Run('Explorer.exe '&$myFolder)                 EndIf             ;EndIf         Case $msg = -3             Exit     EndSelect WEnd Func _GetWindows()     GUICtrlSendMsg($Folderlist, 0x14B, 0, 0)     $AllWindows = WinList()     $sTmp = ""     For $i = 1 To $AllWindows[0][0]         If _IsVisible($AllWindows[$i][1]) Then     $iPID = WinGetProcess($AllWindows[$i][0])     $sProcessPath = _ProcessPath($iPID)             If $AllWindows[$i][0] <> "" And $AllWindows[$i][0] <> "Program Manager" And StringRight($sProcessPath, 12)='explorer.exe' Then                 $iIndex = $aVisibleWindows[0] + 1                 ReDim $aVisibleWindows[$iIndex + 1]                 $aVisibleWindows[0] = $iIndex                 $aVisibleWindows[$iIndex] = $AllWindows[$i][0]                 If $sTmp = "" Then                     $sTmp &= ControlGetText ( $aVisibleWindows[$iIndex], '', "[CLASS:Edit; INSTANCE:1]")                     $sTitle &= $aVisibleWindows[$iIndex]                 Else                     $sTmp &= "|" & ControlGetText ( $aVisibleWindows[$iIndex], '', "[CLASS:Edit; INSTANCE:1]")                     $sTitle &= "|" & $aVisibleWindows[$iIndex]                 EndIf             EndIf         EndIf     Next     If $sTmp <> "" Then         GUICtrlSetData($Folderlist, $sTmp)     Else         GUICtrlSetData($Folderlist, "<No Data>")     EndIf EndFunc Func _IsVisible($handle)     If BitAND(WinGetState($handle), 4) Then         If BitAND(WinGetState($handle), 2) Then             Return 1         Else             Return 0         EndIf     EndIf EndFunc Func _search() $sestmp='' $search = FileFindFirstFile(@ScriptDir & "\*.inc") If $search <> -1 Then While 1     $file = FileFindNextFile($search)     If @error Then ExitLoop     $sestmp&=@ScriptDir & "\"&$file&'|' WEnd EndIf FileClose($search) GUICtrlSetData($Session, $sestmp) EndFunc Func _ProcessPath($iCheckPID)     $strComputer = "."     $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")     $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process", "WQL", 0x30)     If IsObj($colItems) Then         For $objItem In $colItems             $sProcessPID = $objItem.ProcessId             If $sProcessPID = $iCheckPID Then                 $sProcessPath = $objItem.ExecutablePath                 ExitLoop             EndIf         Next     EndIf     If $sProcessPath <> "" Then Return $sProcessPath EndFunc





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users