Jump to content

pctechtv

Members
  • Posts

    12
  • Joined

  • Last visited

Reputation Activity

  1. Like
    pctechtv got a reaction from Exit in List of program names like Window Alt Tab switcher   
    Thank you all again for the great help on this forum. I have to say I am always impressed when I come here. I was able to get exactly what I want with the help I received. I will mention to any novice like myself pay attention to the dependencies the AutoIt functions need at the top of the code (e.g. “#include <WinAPIProc.au3>”). The example I post gave me more than what I needed in my text file; however, I post to be useful to other members. Thanks
    #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <WinAPISysWin.au3> #include <WinAPIProc.au3> Example() Func Example() ; Create a constant variable in Local scope of the filepath that will be read/written to. Local Const $sFilePath = "C:\PSUtil\AutoItTest.txt" Local $aList = WinList() ; Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.") Return False EndIf FileWrite($hFileOpen, "") ; Loop through the array displaying only visable windows with a title. For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then ; Retrieve the handle of the Notepad window using the classname of Notepad. Local $hWnd = WinGetHandle($aList[$i][0]) ; Retrieve the identifier of the thread and pass a variable to the $iPID parameter to store the PID. Local $iPID = 0 Local $iThread = _WinAPI_GetWindowThreadProcessId($hWnd, $iPID) ; This is more than I needed for my text file... I just wanted the Processname... I post to be useful to others FileWrite($hFileOpen, ' Process thread:' & $iThread & ' Process ID (PID): ' & $iPID & " Processname:" & _WinAPI_GetProcessName($iPID) & " filename:" & _WinAPI_GetProcessFileName($iPID) & @CRLF ) EndIf Next ; Close the handle returned by FileOpen. FileClose($hFileOpen) EndFunc ;==>Example  
×
×
  • Create New...