ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Find And Run Robot

displaying expanded user variables in aliases

(1/1)

jinxx:
So I have many aliases with user variables sandwiched in
and sometimes I want to take those aliases for use elsewhere with the user variables expanded,
the string "%uservar.folder.stuff%" isn't any use to me outside of FARR, so I'm wondering if there's some way to take an alias and expand all its FARR user variables

naturally I could go into my uservariables and copy paste etc... but this becomes cumbersome when i have aliases with 3+ user variables in them
of course I could convert my use-case to utilizing windows environment variables, which in the long term I may do

if it's not a feature then I guess consider this a feature request for the "edit group alias" window

Nod5:
I don't think FARR has that feature built in, but it would be a useful feature. I have AutoHotkey code that resolves the FARR user variables. I'l clean that up and post here as a helper tool for FARR when I have more time.

Nod5:
Save to FARR_resolve_alias_variables.ahk (with UTF-8 BOM encoding). Requires AutoHotkey

Will work in most cases, but might fail on complex alias text with e.g. escaped % characters.


--- Code: Autohotkey ---#NoEnvSetWorkingDir %A_ScriptDir%#SingleInstance forceListLines, OffSetBatchLines, -1 ; FARR_resolve_alias_variables.ahk ; by Nod5 on 2021-03-16 ; A helper tool for FARR (Find And Run Robot) written in AutoHotkey ; Reads alias result from active FARR "Edit Group Alias" window ; and resolves (converts) FARR's UserVar variables to text values ; For example the variable "%uservar.Browser.Chrome%" is replaced ; with e.g. "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ; How to use:; Run script and press F8 when FARR Options "Edit Group Alias" window is active; A MsgBox shows the results lines with resolved UserVars ; Optional: uncomment lines near end of script to also; - Copy text to clipboard; - Write text to .txt file ; Discussion;   https://www.donationcoder.com/forum/index.php?topic=51199.0  ; default path to FARR .ini file (edit this filepath if the .ini is in another location)vFarrIni := "C:\Users\" A_UserName "\Documents\DonationCoder\FindAndRunRobot\FindAndRunRobot.ini"return #IfWinActive, Edit Group Alias ahk_exe FindAndRunRobot.exe ahk_class TAliasFormF8::  if !FileExist(vFarrIni)  {    MsgBox % "Error: FindAndRunRobot.ini not found.`n`nEdit script and add correct path to it."    ExitApp  }  ; get text from results editbox  ControlGetText, vText, TMemo2, A   ; read UserVar data from FARR .ini  IniRead, vUserVars, % vFarrIni, ExtraSettings, UserVars, %A_Space%   ; split lines to array  aUserVars := StrSplit(vUserVars, ">n>")   ; object to store full variable/value pairs  aMap := Object()   For Key, vLine in aUserVars  {    vLine := TRim(vLine)        ; skip blank or comment line    if !vLine or (SubStr(vLine, 1, 2) = "//")      continue     ; [Section]    if RegExMatch(vLine, "^\[(.+)\]$", vMatch)      vSection := vMatch1     ; if variable line then get variable/value pair and add to map array    ; prefix variable name "uservar." and last found section name (if any)    if RegExMatch(vLine, "U)^(.+)=(.+)$", vMatch)    {      vVarName := "uservar." ( vSection ? vSection "." : "") vMatch1      vValue    := vMatch2      aMap["" vVarName] := vValue    }  }   ; resolve  For vVarName, vValue in aMap    vText := StrReplace(vText, "%" vVarName "%", vValue) ; replace all   ; show resolved text  MsgBox % vText   ; put on clipboard  ;Clipboard := vText   ; write to .txt file in this script's folder  ;FileAppend, % vText, % A_ScriptDir "\alias_resolved_" A_Now ".txt", UTF-8-RAWreturn#IfWinActive  ; ----------------------------; notes of FARR User Variables (UserVar); ----------------------------;   Used as variables in aliases;   Set in FARR > Options > Lists > User Variables;   Stored in FindAndRunRobot.ini;     Default path C:\Users\<username>\Documents\DonationCoder\FindAndRunRobot\FindAndRunRobot.ini ; Format in Options "User Variables" pane:; -----; TopTest=C:\folder\test.exe; [SectionName]; VarName=Value; VarName2=Value2; // comment line;; [Browser]; Chrome=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe; Firefox=C:\b\firefox.exe; -----; Note: it is allowed to create variables above the first [Section]; Note: comments must be on separate lines. Not allowed: VarName=Value //comment ; -----; Format in FARR aliases:; -----;   %uservar.TopTest%;   %uservar.SectionName.VarName%;   %uservar.Browser.Chrome%; ----- ; -----; Format in FindAndRunRobot.ini; -----; Stored as a single line, ">n>" is linebreak separator; Example:; UserVars=TopTest=C:\folder\test.exe>n>[SectionName]>n>VarName=Value>n>VarName2=Value2>n>// comment line>n>>n>[Browser]>n>Chrome=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe>n>Firefox=C:\b\firefox.exe; ----------------------------

Navigation

[0] Message Index

Go to full version