filter_alias - the FARR alias filter autohotkey helper script
Useful especially if you are a FARR power user (which you should be!
) with a lot of custom aliases.
Useful especially if you are a FARR power user (which you should be!
) with a lot of custom aliases.Code: (autohotkey)
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance force
;filter_alias - FARR alias filter helper script
;WHY?
;When a user has many aliases it can be a hassle to find and edit one of them
;because the FARR options list isn't autosorted and has no filter/searchbox.
;SETUP
;run the script (tip: make it autostart it on boot)
;USAGE
;- open FARR options > aliases and press Ctrl+Space to show a filter box
;- Type in box to filter alias name/regex rows
;- Select a row and press Enter to jump to that row in FARR options
;- Press Esc pr Ctrl+Space again to close filter_alias
;by Nod5 - version 161122
;Listview filter code adapted from
;https://autohotkey.com/boards/viewtopic.php?p=72578#p72578
#IfWinActive, ahk_class TOptionsForm
^Space::
gui, destroy
if !winexist("filter_alias ahk_class AutoHotkeyGUI")
goto showgui
return
#IfWinActive
#IfWinActive, filter_alias ahk_class AutoHotkeyGUI
Esc:: gui, destroy
^Space:: gui, destroy
#IfWinActive
showgui:
name = filter_alias
FileRead, f, %A_MyDocuments%\DonationCoder\FindAndRunRobot\AliasGroups\MyCustom\myaliases.alias
f := StrReplace(f, "</AliasText>", "")
f := StrReplace(f, "</Regex>", "")
xarr := []
xarr2 := []
ControlGetPos, cx, cy,,, TListView1, ahk_class TOptionsForm
WinGetPos, wx, wy,,, ahk_class TOptionsForm
gx := cx+wx, gy := cy+wy
Gui, Add, Edit, r1 vsearch gsearch,
Gui, Add, ListView, r20 w400 h200 grid, Alias|Regex
Loop, Parse, f, `n, `r
{
If InStr(A_LoopField, "<AliasText>")
xali := SubStr(A_LoopField, InStr(A_LoopField, "<AliasText>") + 11)
If InStr(A_LoopField, "<Regex>")
xreg := SubStr(A_LoopField, InStr(A_LoopField, "<Regex>") + 7)
If InStr(A_LoopField, "<AliasEntry>")
xali := xreg := "" ;clear vars for new alias
if xali and (xreg or InStr(A_LoopField, "<Results>") ) ;stop at Result if no Regex
{
xreg := xreg ? xreg : a_space
LV_Add("", xali, xreg), xarr.push(xali) , xarr2.push(xreg)
xali := xreg := "" ;clear vars for new alias
}
}
LV_ModifyCol(1, 120)
LV_ModifyCol(2, 250)
Gui, Show, x%gx% y%gy%, %name%
return
search:
Gui, Submit, NoHide
LV_Delete()
For key, val In xarr
{
If (search == "")
LV_Add("", val, xarr2[key])
Else
If InStr(val, search) or InStr(xarr2[key], search) ;match
LV_Add("", val, xarr2[key])
}
GuiControl, +Redraw, LV
Return
#IfWinActive, filter_alias ahk_class AutoHotkeyGUI
PgDn::
Down::
ControlGetFocus, contr, A
if !(contr == "Edit1")
send {%a_thishotkey%}
else if (LV_GetNext() == 0)
send {Tab}{Down}
else
send {Tab}
return
Enter::
selrow := !LV_GetNext() ? 1 : LV_GetNext()
LV_GetText(seltext, selrow, 1)
gui, destroy
winactivate, ahk_class TOptionsForm
controlfocus, TListView1, ahk_class TOptionsForm
sleep 50
RegExMatch(seltext, "^[^ ]+",seldo)
send % seldo ? seldo : seltext
return
#IfWinActive




