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

DonationCoder.com Software > FARR Plugins and Aliases

Plugin searches but does not respond to triggers? Fscript 1.19

(1/2) > >>

jpprater:
Thanks to mouser's help and reinforcement from late last night  :Thmbsup:, I'm off to a great start on my plugin.  I'm hitting a snag now where I can't get my plugin to respond to triggers.  Is there something I'm supposed to set in FARR.emitResult that tells FARR what to do when I hit enter on the selected result?

mouser:
ok let's make sure we are on same page because there are different things that go on:

SEARCHING:

FARR plugins usually search with every keypress, and the plugin is called after every keypress.
The search function sent to your plugin actually also tells you whether user hit enter at the end of their search, in case you want to handle that event as the "trigger" specially.  This is most useful when you have a plugin that is not showing a list of results but is showing some output in richtext or browser mode.

TRIGGERING:
Now if your plugin is returning standard results as the user types, like internet links, program or data file paths, clipboard text snippets, or internal search strings or aliases, etc., then your plugin never has to worry about triggering anything, since farr will do this automatically.
FARR does call a special trigger function that lets you intercept it's normal "trigger" functionality, both for your own results and results generated by normal search and plugin.

SO:
The bottom line is, if the result is returned as a normal FARR result, then you can either let FARR handle the launching of it, or you can catch it with the special trigger function.
If the results are being displayed in richtext or browser mode, then there is no official "TRIGGERING" that gets called -- instead you can either respond to the press of enter by checking the flag in the search function that is called, OR there is a new keypress function that gets called when various keys are pressed that you could use instead (cant remember the names of these functions maybe fscript gurus can help here?)

jpprater:
SEARCHING:

FARR plugins usually search with every keypress, and the plugin is called after every keypress.
The search function sent to your plugin actually also tells you whether user hit enter at the end of their search, in case you want to handle that event as the "trigger" specially.  This is most useful when you have a plugin that is not showing a list of results but is showing some output in richtext or browser mode.
-mouser (December 11, 2009, 11:33 AM)
--- End quote ---
Yup, I got that far.

TRIGGERING:
Now if your plugin is returning standard results as the user types, like internet links, program or data file paths, clipboard text snippets, or internal search strings or aliases, etc., then your plugin never has to worry about triggering anything, since farr will do this automatically.
FARR does call a special trigger function that lets you intercept it's normal "trigger" functionality, both for your own results and results generated by normal search and plugin.
-mouser (December 11, 2009, 11:33 AM)
--- End quote ---
Unless I'm mistaken in my reading of the documentation, that's onProcessTrigger(path, caption).  I've implemented that, and FARR's not responding.

SO:
The bottom line is, if the result is returned as a normal FARR result, then you can either let FARR handle the launching of it, or you can catch it with the special trigger function.
If the results are being displayed in richtext or browser mode, then there is no official "TRIGGERING" that gets called -- instead you can either respond to the press of enter by checking the flag in the search function that is called, OR there is a new keypress function that gets called when various keys are pressed that you could use instead (cant remember the names of these functions maybe fscript gurus can help here?)
-mouser (December 11, 2009, 11:33 AM)
--- End quote ---
So I might be better off taking out onProcessTrigger and implementing that behavior as part of my "search" function?

mouser:
how are you returning results from searches? what i mean is, are you using the normal farr results mode or are you showing text in memo or browser mode?

jpprater:
The normal mode (using FARR.emitResult()).  When I'm ready to actually activate a result (to get detailed information) then I go to memo mode.
Here's my code as it is now (it's producing a screwy error when I try to run this, something about "expected ';'")

--- Code: Javascript ---// plugin script :displayname="ProcessInfo";versionstring="0.0.1";releasedatestring="12/11/09";author="jpprater";updateurl="";homepageurl="";shortdescription="ProcessInfo";longdescription="ProcessInfo";advconfigstring="ProcessInfo";readmestring="ProcessInfo";iconfilename="processinfo.ico"; aliasstr="processinfo";regexstr="";regexfilterstr="";scorestr="300"; // typeUNKNOWN=0; FILE=1; FOLDER=2; ALIAS=3; URL=4; PLUGIN=5; CLIP=5;// PostprocessingIMMEDIATE_DISPLAY=0; ADDSCORE=1; MATCH_AGAINST_SEARCH=2;// search stateSTOPPED=0; SEARCHING=1; function onSearchBegin(querykey, explicit, queryraw, querynokeyword, modifier, triggermethod) {        if(!explicit) {                return;        }        if (queryraw.match(/get/)) {                FARR.setState(querykey,SEARCHING);                var wbemsrv = GetObject('winmgmts://./root/cimv2');                var p = queryraw.split(' ')[2];                var procs = wbemsrv.ExecQuery("select * from Win32_Process where ProcessID = " + p.toString());                var numer = new Enumerator(procs);                if(numer.item()) {                        var proc += numer.item().Name + " - ";                        var ws = numer.item().WorkingSetSize/(1024*1024);                        proc += ws.toString() + " MB";                }                FARR.setStrValue('launch', 'showmemo ' + proc);                FARR.setState(querykey,STOPPED);        } else {                FARR.setState(querykey,SEARCHING);                var wbemsrv = GetObject('winmgmts://./root/cimv2');                var p = queryraw.split(' ')[1];                var procs = wbemsrv.ExecQuery("select * from Win32_Process where Name LIKE '%" + p + "%'");                var proclist = "";                for (var numer = new Enumerator(procs); !numer.AtEnd; numer.moveNext()) {                        if(numer.item()) {                                FARR.emitResult(querykey, numer.item().Name + " - ID " + numer.item().ProcessID.toString(), "dosearch processinfo get " + numer.item().ProcessID, iconfilename, FILE, IMMEDIATE_DISPLAY, 1000);                        } else {                                break;                        }                }                FARR.setState(querykey,STOPPED);        }}
Everything I've read thus far indicates that this ought to work perfectly except for the crazy error I've mentioned above.

Navigation

[0] Message Index

[#] Next page

Go to full version