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

example/howto: alias appcapresults command with AutoHotkey

(1/1)

Nod5:
In FindAndRunRobot version 2.234.01 mouser added a useful alias command called appcapresults

appcapresults runs an external program, waits for it to output to stdout and then display that output (if correctly formatted) as FARR results lines.

This post shows examples on how to use it together with AutoHotkey to generate a results list in FARR.


--- Code: Autohotkey ---#NoEnvSetWorkingDir %A_ScriptDir%#SingleInstance forceSetBatchLines, -1 ; example AutoHotkey script for use with FARR appcapresults ; prepare a results list; each line adheres to FARR's format for lines in alias results; note: must have a blank line at the end, otherwise the last text line won't show in FARRResults =(Notepad | C:\Windows\System32\notepad.exePaint | C:\Windows\System32\mspaint.exe ); use fileappend with * to write the list to stdoutFileAppend, % Results , *
1. Save the above script as C:\folder\example.ahk and compile to C:\folder\example.exe

2. Next create a FARR alias
alias name: appcapresults example
alias regex: ^appcap$
alias results:

--- ---example | appcapresults C:\folder\example.exe
After that you can type "appcap" in FARR and press enter to get something like this



To make the alias trigger automatically, without Enter, you can change the alias to

--- ---example | dolaunch appcapresults C:\folder\example.exe
That's the basics. But this opens up the possibility of complex, conditional aliases. Some possibilities:
- Have the script present different results lists based on the current day/time
- Pass the %lasthwnd% parameter from FARR to the script and have script present different results depending on what window was active before FARR. For example we could make the alias "help" and have it show our own customized help hints based on what application is active. Related earlier post.
- Another example is to have the script search Everything via its SDK and display the search results in FARR, in effect creating an alternative Everything plugin for FARR. This works, though I don't have the code cleaned up enough to post it yet.


edit:

More complex example: alias results conditional on the active window


--- Code: Autohotkey ---#NoEnvSetWorkingDir %A_ScriptDir%#SingleInstance forceSetBatchLines, -1 ; complex example conditional AutoHotkey script for use with FARR appcapresults ; window id for active window as parameter sent from FARRLastHwnd := A_Args[1] ; if active window is FirefoxIf LastHwnd and WinExist("ahk_exe Firefox.exe ahk_id " LastHwnd){  Results =  (LTrim  Google | https://www.google.com/  Wiki | https://en.wikipedia.org/   )} ; if active window is MS PaintIf LastHwnd and WinExist("ahk_exe mspaint.exe ahk_id " LastHwnd){  Results =  (LTrim  // use FARR sendkeys command to send action shortcuts to MS Paint  Resize | sendkeys ^w  Crop selection | sendkeys ^(+x)   ) } ; use fileappend with * to write the list to stdoutFileAppend, % Results , *
1. Save the above script as C:\folder\example2.ahk and compile to C:\folder\example2.exe

2. Next create/edit a FARR alias
alias name: appcapresults example2
alias regex: ^appcap$
alias results:

--- ---example | appcapresults C:\folder\example2.exe %lasthwnd%
Type "appcap" and press enter over MS Paint and Firefox to get different results

example/howto: alias appcapresults command with AutoHotkey

example/howto: alias appcapresults command with AutoHotkey

GIF of sending the action shortcuts to MS Paint from FARR
https://i.imgur.com/0SE2wDQ.mp4

edit2: improved complex example

cranioscopical:
Ingenious, thanks!

wjamoe:
very nice, thanks!

Navigation

[0] Message Index

Go to full version