topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Tuesday December 10, 2024, 10:21 pm
  • 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

Last post Author Topic: FScript Javascript SDK - Write FARR plugins in javascript and more.  (Read 113278 times)

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Fscript is a plugin that allow to write FARR plugin in javascript natively (and in others languages if they are correctly set up ). The principle is to copy the fscript.dll in a plugin folder, to add a file named fscript.js in the same folder (or fscript.rb, fscript.pl, fscript.py for others languages ).

Rem : If you are only interested in writing Javascript plugins you should consider using FSubScript plugin that does the same as FScript (actually FSubScript is itself a FScript plugin ) but can host many plugins simultaneously thus reducing the memory usage.
There is at least two version of FSubScript and the most up to date is CZB version available at : https://www.donation...ex.php?topic=17153.0

The FScript SDK is available at :
http://e.craft.free....es/FScriptSample.rar
The last FScript.dll is downloadable at :
http://e.craft.free....ipt/1.20/fscript.dll
A somewhat incomplete documentation is available at :
http://e.craft.free....rr/FScript/help.html

Here is a basic javascript plugin :
Code: Javascript [Select]
  1. // plugin script :
  2. displayname="FScript";
  3. versionstring="1.0.0";
  4. releasedatestring="Jan 1st, 2008";
  5. author="Author";
  6. updateurl="";
  7. homepageurl="";
  8. shortdescription="FScript";
  9. longdescription="FScript";
  10. advconfigstring="FScript";
  11. readmestring="FScript";
  12. iconfilename="FScript.ico";
  13.  
  14. aliasstr="fscript";
  15. regexstr="";
  16. regexfilterstr="";
  17. keywordstr="";
  18. scorestr="300";
  19.  
  20. // type
  21. UNKNOWN=0; FILE=1; FOLDER=2; ALIAS=3; URL=4; PLUGIN=5; CLIP=5;
  22. // Postprocessing
  23. IMMEDIATE_DISPLAY=0; ADDSCORE=1; MATCH_AGAINST_SEARCH=2;
  24. // search state
  25. STOPPED=0; SEARCHING=1;
  26.  
  27. function onSearchBegin(querykey, explicit, queryraw, querynokeyword, modifier, triggermethod) {    
  28.         if(!explicit) {
  29.                 return;
  30.         }
  31.         FARR.setState(querykey,SEARCHING);
  32.         FARR.emitResult(querykey,"Hello", "Hello", iconfilename,UNKNOWN,IMMEDIATE_DISPLAY,1000);
  33.         FARR.setState(querykey,STOPPED);        
  34. }

The full documentation is available on the aliases and scripts plugins wiki : http://farr.dcisv.co...script_documentation

Changelist
1.19
- restore the compatibility with previous versions. onProcessTrigger is emulated when the version of FARR use onProcessTriggerV2.
- increase the getStrValue buffer to 1 Mo allow to read bigger string
1.18 [warning incompatible change]
- onProcessTriggerV2 has change to onProcessTrigger to allow FARR plugins to behave the same way on new and old FARR versions.
=> the incompatible change is of interest for plugins writers, just rename the function in the script to get precedent behavior.
1.17
- fix a crash with the KlipKeeper plugin in AllowProcessTriggerV2.
1.16
- fix a crash in AllowProcessTrigger
1.15
- add socket support (string only, this is suitable for doing telnet like things )
1.14
- increase the size of getStrValue that could be bigger than expected
1.13
- add support for onProcessTriggerV2
1.12
- add the getObject function to access WMI facilities
1.11
- enable interprocess communication with the plugins through WM_USER+1 messages
- add support to read the keyboard state
- add support to read the current query in the input box
1.10
- add groupname and args to emitResults function and triggerResults
- add help file
- add onDoShowReadMe callback
1.8
- return a correct value on onStrValue Callback
- add ability to read .INI file (for easing compatibility with ahk )
1.6
- add support for onGetStrValue callback
- allow to not close FARR on onProcessTrigger
1.5
- support for api evolutions of FARR
- support callback for onDoAdvConfig
- support for onSearchBeginV2 and onRegexSearchMatchV2 callbacks
- support for onIdleTime
- support for onReceiveKey
- fix an incompatibility when multiple fscript plugins where loaded at the same time
- support for timers
- support for xml generated options (deprecated )


I released the sources of FScript if you want to throw an eye at it. You can grab a copy of the latest sources at http://github.com/ec.../fscript/tree/master. Adding function should not be very hard if you need them. Just look at other functions and add new ones. The scripts interface are exposed via COM so don't forget to edit the idl to add your functions too. You can ask questions too. I will certainly answer.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript
« Last Edit: January 12, 2011, 08:34 AM by ecaradec »

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
wow  :o

Armando

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 2,727
    • View Profile
    • Donate to Member
Hi Ecaradec, the download link doesn't seem to be working... Is it because you're already torturing and updating the poor thing ?  ;)

taichimaster

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 160
    • View Profile
    • Donate to Member
WOW nice!!!  :Thmbsup:  The SDK link seems to be broken though.

For plugins developed using scripting languages (ruby, perl, python) that aren't included in WSH by default, do the users need to have the ActiveState engines installed on their machines?


ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Ok the url is fixed.
For plugins developed using scripting languages (ruby, perl, python) that aren't included in WSH by default, do the users need to have the ActiveState engines installed on their machines?
Yes the active scripting engines must be installed. Look at : http://www.mvps.org/scripting/languages/
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

vitalyb

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 143
    • View Profile
    • Donate to Member
Oh man, I should really catch up with the .NET SDK

Great work mate!

rbeeger

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 72
    • View Profile
    • Donate to Member
Hi Ecaradec,

looks like you are scanning for a fixed set of suffixes (js, rb, vbs, py and pl). So you don't allow for other scripting languages that are integrated into the windows scripting host.
Could you change that and make the plugin try to execute any fscript.* that exists in the same directory the DLL is in.
Or there could be a config file that specifies which script to call.

Cheers,
  Robert

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Looks like you are scanning for a fixed set of suffixes (js, rb, vbs, py and pl).
I could search for fscript.* but it would not give me the language that I need to tell to the script control. I could set it in the config file, but I like beeing able to just define a file and have a working plugin. If you want to write a plugin in a language not the list, tell me and I'll add it.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

rbeeger

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 72
    • View Profile
    • Donate to Member
Hi ecaradec,

As I tried out the todoTXT plugin which is based on Python and FScript, I discovered that it didn't work, it didn't even show up in the plugin list. The page at mvps.org lists the python.org-variant of Python which I have installed and prefer over the ActiveState variant as a valid Windows scripting language.
I don't know anything about how you enable a scripting language in FScript but I suspect that the python and ActiveState variants use different ids or names or something like that and that FScript only checks for the ActiveState ones. Would it be hard to make it configurable what veriant of Python is used or release a version of fscript that uses the python.org variant?

Cheers,
  Robert

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
The normal Python installation do not install automatically the activescripting support. You must install the Python for windows extension. Download it at :

http://sourceforge.n...s.php?group_id=78018

However I tried this and the activestate python and I wasn't able to make the plugin work in any case. How did you install your python czechboy ?
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

czb

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 336
    • View Profile
    • My open-source online piano game
    • Donate to Member
Well I downloaded ActivePython 2.5.2.2 for Windows (x86) and then just pressing next all the time during installation ;) I must say that before ActivePython I had there normal python for a while (like two hours :) ) which I have uninstalled before ActivePython installation. I have WinXP SP2 ;) I have also installed Kudos or how it is called (from the same site) but it was just because I wanted somehow to turn JIT debugging on for python - was not succesful. But python script was working even without it...
My open-source online piano game: https://github.com/musicope/game

rbeeger

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 72
    • View Profile
    • Donate to Member
Yes, with ActiveState Python it also works here.

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
Download link seems to be down..

reckoner

  • Supporting Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 22
    • View Profile
    • Donate to Member
Hi,

I am interested in getting this working with Python. I have followed the instructions exactly and created both a fscript.rb and fscript.py in the directory

C:\Program Files\FindAndRunRobot\Plugins\FScript

that contains the  following:

FScript.dll
fscript.rb
fscript.js
fscript.py

However, it only recognizes the fscript.js plugin and not the ruby or python one. I got the ruby script from your example above. I uninstalled and re-installed activestate python and installed ruby, but these had not effect.

I'm getting the feeling that there is something else missing here, maybe some kind of SDK that I don't have installed. I have the NET 2.0 framework installed on my Windows XP(SP2).

Little 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
Hi Reckoner and welcome!! Nothing makes me happier than seeing new potential plugin coders post.  Ecaradec is the coder who wrote this fscript sdk, and i know he will be by soon to help answer this and also release an update to the sdk soon i think.

czb

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 336
    • View Profile
    • My open-source online piano game
    • Donate to Member
reckoner: Do you have one fscript file in the folder? I do not think you can have py,js,rb together. Try to take a look at my TodoTXT plugin => it is python plugin ;)
My open-source online piano game: https://github.com/musicope/game

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
reckoner: Do you have one fscript file in the folder? I do not think you can have py,js,rb together. Try to take a look at my TodoTXT plugin => it is python plugin ;)
Yes. You must remove the fscript.js and put a fscript.py. It should work. Happy coding :)
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

reckoner

  • Supporting Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 22
    • View Profile
    • Donate to Member
thanks for your feedback.

I downloaded TodoTXT and put in in the plugins folder and refreshed the plugins. I'm having the same problem however: td is not recognized as a plugin.

I would say there's something weird with my python installation, but I did reinstall the activestate version and I did install Ruby for the first time to try the above example.

Any other ideas?

Perry Mowbray

  • N.A.N.Y. Organizer
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,817
    • View Profile
    • Donate to Member
1. Is it possible to stop FARR closing when a result is double-clicked?

What I'm wanting to do is have the ability to further define the search in the edit box by the item clicked on.

2. Can I get information from the found item into the EditBox?
  • When I select the item's context menu and select "Jump to directory in EditBox" nothing happens  :-\
  • When I drag the item to the EditBox the correct "path" is entered BUT it's prefixed with a "/", which I don't want.

So what's happening is I've entered a search "tz .*" which matches stuff, I'd like to select one of the matches and "search" again with that.
  • My Alias String is tz.
  • The path for both of #2 items is something like "TZ Pacific/Auckland": I added the Alias String to the path in the hope that I could get that data into the edit box.

Perry Mowbray

  • N.A.N.Y. Organizer
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,817
    • View Profile
    • Donate to Member
Another quick question:

I'm not sure what the effects of the PostProcessing options are:
IMMEDIATE_DISPLAY=0; ADDSCORE=1; MATCH_AGAINST_SEARCH=2

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
When a plugin returns a result item, it gives it a score.  The score determines where the result is ranked in the result list.  The PostProcessing option tells FARR how to use this score:

  • IMMEDIATE_DISPLAY=0 -- this tells FARR to use the plugin's score directly and do nothing more with the score
  • ADDSCORE=1 -- this tells FARR to take the score given by the plugin and then add its own score to it based on how well it matches other stuff, BUT also instructs FARR to never reject the result (it will be shown no matter what the score)
  • MATCH_AGAINST_SEARCH=2 -- this tells FARR to add it's own score to the plugin score and to reject the result if it doesnt match the rest of the search string.  this would be the method of choice if you want FARR to figure out whether to show the result or not based on the search string.  i guess this option is the most common and useful one.

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
1. Is it possible to stop FARR closing when a result is double-clicked?
add " /stayopen" to the end of the launch result to tell FARR to stay open after launching.

2. Can I get information from the found item into the EditBox?
there may be something i can do to improve the case of dragging and dropping into edit box or chooding jump to directory for these cases, but regardless, i think what you are wanting to, if i understand it which i might not, is to populate your results like this:
choice 1 | restartsearch tz pacific/auckland
choice 2 | restartsearch tz usa
etc

the restartsearch launch command will put the text that follows into the edit box when the item is selected, so it lets you build things like menus in FARR results.

Perry Mowbray

  • N.A.N.Y. Organizer
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,817
    • View Profile
    • Donate to Member
1. Is it possible to stop FARR closing when a result is double-clicked?
add " /stayopen" to the end of the launch result to tell FARR to stay open after launching.

OK: pretty sure that that option is not available in this Plugin? Could onProcessTrigger return a result??

2. Can I get information from the found item into the EditBox?
there may be something i can do to improve the case of dragging and dropping into edit box or chooding jump to directory for these cases, but regardless, i think what you are wanting to, if i understand it which i might not, is to populate your results like this:
choice 1 | restartsearch tz pacific/auckland
choice 2 | restartsearch tz usa
etc

the restartsearch launch command will put the text that follows into the edit box when the item is selected, so it lets you build things like menus in FARR results.

yes, that sounds perfect: but again, I'm pretty sure that that command is not available in the Fscript plugin?

ecaradec?? I'd love to have that command  :-*

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
couple of things:
you can create an .alias file and include it inside your plugin directory.
this can be extremely useful in terms of building helper menus like those shown above to work hand-in-hand with your plugin.

as far as stayopen not being available in the plugin, two things:
you specify /stayopen when you call from the plugin the set_strval("launch","file_to_launch /stayopen") like that
or add it to the end of your result that you return from your plugin.

OR if you are doing a takeover of the OnProcessTrigger, ecaradec just added the ability to tell farr not to close -- you return a value of 1 from that event function. BUT BUT BUT -- i don't think ecaradec has made that new version of fscript public yet (1.6) so you need that first.

Perry Mowbray

  • N.A.N.Y. Organizer
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,817
    • View Profile
    • Donate to Member
Thanks for the tip on .alias files. Wasn't aware.

What I'm trying to do is present some matches from the user entered query. The user can select one of the matches, which will be added to the EditBox (Like what happens when you are browsing the FileSystem in FARR). Then FARR reSearches on the new string and presents other options. So very similar to browsing the filesystem in FARR.