Jump to content

Recommended Posts

Posted

Question for all... I'm working on a time management program similar to rescuetime (www.rescuetime.com). It's been pretty easy to do with autoit so far, but I'm having a problem with finding the actual process that is running the active window. The window title is easy, as is the actual process ID just using the built in WinGetText and WinGetProcess. Is there a way to get the name of the executable from either the title or the PID? I've searched through the forum here and cant find anything that seems to help, so any and all suggestions appreciated!

Posted (edited)

I found this in Autoit Wrappers .. great additions to your script.

There are many, many other useful scriptlets there to help you!

Maybe...

; Get the execuatble path of a window
; Author gafrost

$path = _WinGetPath()
MsgBox(0,WinGetTitle(""),$path)

Func _WinGetPath($Title="", $strComputer='localhost')
    $win = WinGetTitle($Title)
    $pid = WinGetProcess($win)
   $wbemFlagReturnImmediately = 0x10
   $wbemFlagForwardOnly = 0x20
   $colItems = ""
   $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
   $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid, "WQL", _
         $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
   If IsObj($colItems) Then
      For $objItem In $colItems
         If $objItem.ExecutablePath Then Return $objItem.ExecutablePath
      Next
   EndIf
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Posted

Coolness. After looking around some more, I also found a udf that will work as well. The full command is _ProcessGetName(WinGetProcess(WinGetTitle("")))). Thanks all!

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...