topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Friday December 13, 2024, 11:47 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: Plugin searches but does not respond to triggers? Fscript 1.19  (Read 6112 times)

jpprater

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 90
    • View Profile
    • Donate to Member
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

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Plugin searches but does not respond to triggers? Fscript 1.19
« Reply #1 on: December 11, 2009, 11:33 AM »
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

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 90
    • View Profile
    • Donate to Member
Re: Plugin searches but does not respond to triggers? Fscript 1.19
« Reply #2 on: December 11, 2009, 11:59 AM »
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.
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.
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?)
So I might be better off taking out onProcessTrigger and implementing that behavior as part of my "search" function?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Plugin searches but does not respond to triggers? Fscript 1.19
« Reply #3 on: December 11, 2009, 12:38 PM »
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

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 90
    • View Profile
    • Donate to Member
Re: Plugin searches but does not respond to triggers? Fscript 1.19
« Reply #4 on: December 11, 2009, 01:00 PM »
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 [Select]
  1. // plugin script :
  2. displayname="ProcessInfo";
  3. versionstring="0.0.1";
  4. releasedatestring="12/11/09";
  5. author="jpprater";
  6. updateurl="";
  7. homepageurl="";
  8. shortdescription="ProcessInfo";
  9. longdescription="ProcessInfo";
  10. advconfigstring="ProcessInfo";
  11. readmestring="ProcessInfo";
  12. iconfilename="processinfo.ico";
  13.  
  14. aliasstr="processinfo";
  15. regexstr="";
  16. regexfilterstr="";
  17. scorestr="300";
  18.  
  19. // type
  20. UNKNOWN=0; FILE=1; FOLDER=2; ALIAS=3; URL=4; PLUGIN=5; CLIP=5;
  21. // Postprocessing
  22. IMMEDIATE_DISPLAY=0; ADDSCORE=1; MATCH_AGAINST_SEARCH=2;
  23. // search state
  24. STOPPED=0; SEARCHING=1;
  25.  
  26. function onSearchBegin(querykey, explicit, queryraw, querynokeyword, modifier, triggermethod) {
  27.         if(!explicit) {
  28.                 return;
  29.         }
  30.         if (queryraw.match(/get/)) {
  31.                 FARR.setState(querykey,SEARCHING);
  32.                 var wbemsrv = GetObject('winmgmts://./root/cimv2');
  33.                 var p = queryraw.split(' ')[2];
  34.                 var procs = wbemsrv.ExecQuery("select * from Win32_Process where ProcessID = " + p.toString());
  35.                 var numer = new Enumerator(procs);
  36.                 if(numer.item()) {
  37.                         var proc += numer.item().Name + " - ";
  38.                         var ws = numer.item().WorkingSetSize/(1024*1024);
  39.                         proc += ws.toString() + " MB";
  40.                 }
  41.                 FARR.setStrValue('launch', 'showmemo ' + proc);
  42.                 FARR.setState(querykey,STOPPED);
  43.         } else {
  44.                 FARR.setState(querykey,SEARCHING);
  45.                 var wbemsrv = GetObject('winmgmts://./root/cimv2');
  46.                 var p = queryraw.split(' ')[1];
  47.                 var procs = wbemsrv.ExecQuery("select * from Win32_Process where Name LIKE '%" + p + "%'");
  48.                 var proclist = "";
  49.                 for (var numer = new Enumerator(procs); !numer.AtEnd; numer.moveNext()) {
  50.                         if(numer.item()) {
  51.                                 FARR.emitResult(querykey, numer.item().Name + " - ID " + numer.item().ProcessID.toString(), "dosearch processinfo get " + numer.item().ProcessID, iconfilename, FILE, IMMEDIATE_DISPLAY, 1000);
  52.                         } else {
  53.                                 break;
  54.                         }
  55.                 }
  56.                 FARR.setState(querykey,STOPPED);
  57.         }
  58. }

Everything I've read thus far indicates that this ought to work perfectly except for the crazy error I've mentioned above.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Plugin searches but does not respond to triggers? Fscript 1.19
« Reply #5 on: December 11, 2009, 01:09 PM »
mail me the a full plugin zip file so i can play with it while i help.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Plugin searches but does not respond to triggers? Fscript 1.19
« Reply #6 on: December 11, 2009, 01:12 PM »
the real fscript pros are ewemoa, czb, and ecaradec -- maybe we can get them to stop by here and help.

jpprater

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 90
    • View Profile
    • Donate to Member
Re: Plugin searches but does not respond to triggers? Fscript 1.19
« Reply #7 on: December 11, 2009, 02:55 PM »
... :o You know what I did?  Look at line 37 above.  That += should have been a plain =. :D :-[
It's always the little things, isn't it?
Here's a zip if you want to play with it.  It works perfectly now, though it doesn't provide nearly the feature set I intend for it to.