topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Tuesday March 19, 2024, 1:44 am
  • 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: filter_alias - FARR alias filter autohotkey helper script  (Read 5220 times)

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
filter_alias - FARR alias filter autohotkey helper script
« on: November 22, 2016, 03:19 PM »
filter_alias - the FARR alias filter autohotkey helper script

Useful especially if you are a FARR power user (which you should be!  ;D ) with a lot of custom aliases.

Code: Autohotkey [Select]
  1. SetWorkingDir %A_ScriptDir%
  2.  
  3. ;filter_alias - FARR alias filter helper script
  4.  
  5. ;WHY?
  6. ;When a user has many aliases it can be a hassle to find and edit one of them
  7. ;because the FARR options list isn't autosorted and has no filter/searchbox.
  8.  
  9. ;SETUP
  10. ;run the script (tip: make it autostart it on boot)
  11.  
  12. ;USAGE
  13. ;- open FARR options > aliases and press Ctrl+Space to show a filter box
  14. ;- Type in box to filter alias name/regex rows
  15. ;- Select a row and press Enter to jump to that row in FARR options
  16. ;- Press Esc pr Ctrl+Space again to close filter_alias
  17.  
  18. ;by Nod5 - version 161122
  19. ;Listview filter code adapted from
  20. ;https://autohotkey.com/boards/viewtopic.php?p=72578#p72578
  21.  
  22. #IfWinActive, ahk_class TOptionsForm
  23. ^Space::
  24. if !winexist("filter_alias ahk_class AutoHotkeyGUI")
  25.  goto showgui
  26. return
  27.  
  28. #IfWinActive, filter_alias ahk_class AutoHotkeyGUI
  29. Esc:: gui, destroy
  30. ^Space:: gui, destroy
  31.  
  32. showgui:
  33. name = filter_alias
  34. FileRead, f, %A_MyDocuments%\DonationCoder\FindAndRunRobot\AliasGroups\MyCustom\myaliases.alias
  35. f := StrReplace(f, "</AliasText>", "")
  36. f := StrReplace(f, "</Regex>", "")
  37. xarr := []
  38. xarr2 := []
  39.  
  40. ControlGetPos, cx, cy,,, TListView1, ahk_class TOptionsForm
  41. WinGetPos, wx, wy,,, ahk_class TOptionsForm
  42. gx := cx+wx, gy := cy+wy
  43.  
  44. Gui, Add, Edit, r1 vsearch gsearch,
  45. Gui, Add, ListView, r20 w400 h200 grid, Alias|Regex
  46.  
  47. Loop, Parse, f, `n, `r
  48. {
  49. If InStr(A_LoopField, "<AliasText>")
  50.  xali := SubStr(A_LoopField, InStr(A_LoopField, "<AliasText>") + 11)
  51. If InStr(A_LoopField, "<Regex>")
  52.   xreg := SubStr(A_LoopField, InStr(A_LoopField, "<Regex>") + 7)
  53. If InStr(A_LoopField, "<AliasEntry>")
  54.  xali := xreg := ""  ;clear vars for new alias
  55. if xali and (xreg or InStr(A_LoopField, "<Results>") ) ;stop at Result if no Regex
  56.   {
  57.   xreg := xreg ? xreg : a_space
  58.   LV_Add("", xali, xreg), xarr.push(xali) , xarr2.push(xreg)
  59.   xali := xreg := ""  ;clear vars for new alias
  60.   }
  61. }
  62. LV_ModifyCol(1, 120)
  63. LV_ModifyCol(2, 250)
  64. Gui, Show, x%gx% y%gy%, %name%
  65. return
  66.  
  67. search:
  68. Gui, Submit, NoHide
  69. For key, val In xarr
  70. {
  71.    If (search == "")
  72.     LV_Add("", val, xarr2[key])
  73.    Else
  74.     If InStr(val, search) or InStr(xarr2[key], search) ;match
  75.      LV_Add("", val, xarr2[key])
  76. }
  77. GuiControl, +Redraw, LV
  78. Return
  79.  
  80. #IfWinActive, filter_alias ahk_class AutoHotkeyGUI
  81. PgDn::
  82. Down::
  83. ControlGetFocus, contr, A
  84. if !(contr == "Edit1")
  85.  send {%a_thishotkey%}
  86. else if (LV_GetNext() == 0)
  87.  send {Tab}{Down}
  88. else
  89.  send {Tab}
  90. return
  91.  
  92. Enter::
  93. selrow := !LV_GetNext() ? 1 : LV_GetNext()
  94. LV_GetText(seltext, selrow, 1)
  95. winactivate, ahk_class TOptionsForm
  96. controlfocus, TListView1, ahk_class TOptionsForm
  97. RegExMatch(seltext, "^[^ ]+",seldo)
  98. send % seldo ? seldo : seltext
  99. return
« Last Edit: November 22, 2016, 03:44 PM by Nod5, Reason: bugfix »

IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,540
  • @Slartibartfarst
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: filter_alias - FARR alias filter autohotkey helper script
« Reply #1 on: November 29, 2016, 11:15 PM »
I missed that. Thanks for cross-posting.
Nice workaround script.