avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Monday July 15, 2024, 9:35 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: FARRCloseSelProc -- FARR helper tool closes process matching selected filename  (Read 9960 times)


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
FARRCloseSelProc is a FARR helper tool that closes a process that matches the filename of the file that is selected in Explorer.

This is useful if you work on some code that you need to repeatedly compile, run and later close the process of before the next test run. But it can also be used to quickly close a process that you know the name of.

1 paste the code into a text editor and save as FARRCloseSelProc.ahk and then compile it (you need for that).
2 store the compiled FARRCloseSelProc.exe in some folder
3 create a FARR alias like this

alias name:
proc close
regex pattern:
^proc(?: |)(.*|)$
result box:
CloseSelProc $$1| C:\some\folder\FARRCloseSelProc.exe $$1 %LASTHWND%

To use it open Explorer and select a file you want to close a matching process for. For example select the file program.exe if you want to close the process program.exe . Press your FARR hotkey, type "proc" and when the alias shows press enter.
To use it by typing a process name press your FARR hotkey, type "proc program.exe" and press enter.

- The typed process name must match exactly. It must not have any spaces in the name.
- If there are multiple processes with that name only the first one detected by autohotkey will be closed.

SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance force

x = %1%  ;hwnd parameter from FARR or exact name of a process from FARR
y = %2%  ;hwnd (if first param is exact name)

;FARRCloseSelProc -- a helper tool for FARR
;This tool is made to be run from a FARR alias.

if x =
if y ;filename mode
 splitpath, x, pname,,pext
else ;HWND mode
WinGetClass, xclass, ahk_id %x%
if xclass != CabinetWClass  ;exit if not Explorer win
WinActivate, ahk_id %x%,
ifwinNotactive, ahk_id %x%
clip := ClipBoardAll 
clipboard =
send ^c   ;copy
clipwait, 2
if errorlevel != 0
Loop, Parse, clipboard, `n, `r
p := a_loopfield
clipboard := clip ;restore
if InStr( FileExist(p), "D")
splitpath, p, pname,,pext

if (pext != "exe")

Process, close, %pname%
Loop, 10
Process, Exist, %pname%
if errorlevel = 0
sleep 100
Process, Exist, %pname%
if errorlevel = 0
 tooltip, Closed process %pname%
 tooltip, ERROR. Process %pname% still running.
sleep 2000


  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,911
    • View Profile
    • Mouser's Software Zone on
    • Read more about this member.
    • Donate to Member
Awesome, thanks for sharing!!  :Thmbsup: