DonationCoder.com Software > FARR Plugins and Aliases
FARRCloseSelProc -- FARR helper tool closes process matching selected filename
(1/1)
Nod5:
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.
Setup:
1 paste the code into a text editor and save as FARRCloseSelProc.ahk and then compile it (you need http://ahkscript.org/ for that).
2 store the compiled FARRCloseSelProc.exe in some folder
3 create a FARR alias like this
alias name:
--- ---proc closeregex 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.
Note:
- 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.
--- ---#NoEnv
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 =
exitapp
if y ;filename mode
splitpath, x, pname,,pext
else ;HWND mode
{
WinGetClass, xclass, ahk_id %x%
if xclass != CabinetWClass ;exit if not Explorer win
exitapp
WinActivate, ahk_id %x%,
ifwinNotactive, ahk_id %x%
exitapp
clip := ClipBoardAll
clipboard =
send ^c ;copy
clipwait, 2
if errorlevel != 0
exitapp
Loop, Parse, clipboard, `n, `r
{
p := a_loopfield
break
}
clipboard := clip ;restore
if InStr( FileExist(p), "D")
exitapp
splitpath, p, pname,,pext
}
if (pext != "exe")
exitapp
Process, close, %pname%
Loop, 10
{
Process, Exist, %pname%
if errorlevel = 0
break
sleep 100
}
Process, Exist, %pname%
if errorlevel = 0
tooltip, Closed process %pname%
else
tooltip, ERROR. Process %pname% still running.
sleep 2000
exitapp
mouser:
Awesome, thanks for sharing!! :Thmbsup:
Navigation
[0] Message Index
Go to full version