Welcome Guest.   Make a donation to an author on the site July 28, 2014, 07:25:20 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2014! Download dozens of custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Is FARR right for me? Requesting barebones JScript example  (Read 2585 times)
dreftymac
Supporting Member
**
Posts: 13


View Profile Give some DonationCredits to this forum member
« on: June 25, 2008, 07:18:44 AM »

Hello FARR-folks!

I am impressed with FARR and I'd like a little help to
determine if FARR is the right tool for me.

I would like to be able to do a proof of concept script
using the Javascript API. I've read the documentation and
I am pretty certain this is possible, I just have not found
it yet.

=====================
Formatted for XML with the GeSHI Syntax Highlighter [copy or print]
  1. STEP1:
  2. Output the following strings to FARR results pane:
  3.  
  4. * Hello World!
  5. * Bonjour Tout le Monde!
  6. * Hola Mundo!
  7. * Guten Tag Welt!
  8.  
  9. STEP2:
  10. Allow the user to choose one item from the results pane.
  11. (e.g., user presses ENTER on Hola Mundo!)
  12.  
  13. STEP3:
  14. Take the text that the user selected and paste it into the
  15. previously-active window.
=====================

STEP3 is the one I need help with, the other steps are pretty
easy to figure out from the existing examples.

Also, I'd like to see an example of step3 where FARR launches
any arbitrary application and passes in whatever the user
chose as a cmdline argument to that application.

Any help you can provide will be appreciated, as it will be
a big step in deciding whether FARR is the right tool for
me and I can jump in here with a donation and some code to
possibly help others.

Thanks in advance,
Logged
mouser
First Author
Administrator
*****
Posts: 33,183



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: June 25, 2008, 07:24:27 AM »

assuming you don't need to generate those strings dynamically through some computation, you can do what you want much much easier than what you might be thinking.

you can make a simple alias that does exactly what you want.

just go to options, alias tab, choose myaliases.alias and create a new alias titled whatever you want (like for example "helloworld")
and then in results make a list like this:
Hello World! | paste Hello World!
Bonjour Tout le Monde! | paste Bonjour Tout le Monde!

that's all there is to it.



now if you wanted to generate those strings using some algorithm or getting them from a website or something, then you would want to write a javascript plugin like you initially said.
Logged
jgpaiva
Global Moderator
*****
Posts: 4,710



Artificial Idiocy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: June 25, 2008, 07:38:18 AM »

mouser: i think dreftymac's problem is if there's a way for a plugin to paste text on to the previous window, like it's possible through aliases... Does the SDK export this capability?
Logged

dreftymac
Supporting Member
**
Posts: 13


View Profile Give some DonationCredits to this forum member
« Reply #3 on: June 25, 2008, 11:16:59 AM »

assuming you don't need to generate those strings dynamically

*slaps forhead*

Thanks, mouser, but the "hello world" strings were just an effort to keep this discussion very simple. I am not literally interested in how to paste "Hello World" in different languages using FARR ... (my javascript will be indeed doing fancy stuff, but first I gotta lay the foundation, hence the phrase "proof of concept").

Thanks for the *paste* tip, though, as the documentation only talks about using paste with date, time and date+time, so that's an interesting tidbit you've added. I will keep that in mind also.

Just to re-cap:
* This really is a question about Javascript (I promise), a specific example doing the three steps above would be nice;
* FARR aliases are definitely great, but those are already pretty well documented, and javascript examples exist for that, so feel free to omit that from this convo;
* I am also interested in calling an external program and passing what the user selected as a cmdline argument to that program. (alternate variation of STEP3)

The reason I'm asking is because none of the existing Javascript-based examples do all three, and I'm trying to figure out how much time/money/brain-power to invest in this tool. So far it looks good, but I'd really like a bare-bones-very-simple example to start from, doing all three steps as shown above. (also with the second variation of STEP3 would be ultra-super).

Thanks in advance,

Logged
czb
Honorary Member
**
Posts: 335



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #4 on: June 25, 2008, 12:53:25 PM »

Also, I'd like to see an example of step3 where FARR launches
any arbitrary application and passes in whatever the user
chose as a cmdline argument to that application.

Hi,
this can be done easily by activexobject. Look at my "upload plugin", where I call 7zip with arguments and also call FTP commands...
You can also take a look at my "shell plugin" Wink

Quote
#
STEP3:
Take the text that the user selected and paste it into the previously-active window

alias commands can be called also from javascript so you can use "paste" command there Wink but if you need UTF-8 (chinese characters etc) support then I would use activexobject instead => take a look at my "online czech to X dictionary" where I paste text to the clipboard (unfortunately I do not know how to paste it directly to last active window)

EDIT: if you wait I will make some example on friday Wink
« Last Edit: June 25, 2008, 12:55:55 PM by czechboy » Logged

My open-source online piano game: http://musicope.com/
mouser
First Author
Administrator
*****
Posts: 33,183



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #5 on: June 25, 2008, 05:36:37 PM »

Quote
alias commands can be called also from javascript so you can use "paste" command there

just to reiterate and clarify:
any result command you can issue from an alias, like:
paste, showhtml, etc

you can run from a javascript plugin by calling
FARR->set_strvalue("launch","paste BLAH BLAH");



There was a suggestion that i hope we pursue soon to make a more generic javascript scripting system based on dqsd which would make it a LOT easier for people to make javascript-style mini-plugins/scripts, without having to go through the entire process of having a dll, etc.
Logged
czb
Honorary Member
**
Posts: 335



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #6 on: June 27, 2008, 10:57:05 AM »

try this:
Formatted for Javascript with the GeSHI Syntax Highlighter [copy or print]
  1. // plugin script :
  2. displayname="barebone";
  3. versionstring="1.01.01";
  4. releasedatestring="23.6.2008";
  5. author="Oldrich Svec";
  6. updateurl="";
  7. homepageurl="";
  8. shortdescription="barebone";
  9. longdescription="";
  10. advconfigstring="barebone";
  11. readmestring="barebone";
  12. iconfilename="icon.ico";
  13.  
  14. aliasstr="bb";
  15. regexstr="";
  16. scriptregex="";
  17. regexfilterstr="";
  18. keywordstr="";
  19. scorestr="300";
  20.  
  21. // type
  22. UNKNOWN=0; FILE=1; FOLDER=2; ALIAS=3; URL=4; PLUGIN=5; CLIP=5;
  23. // Postprocessing
  24. IMMEDIATE_DISPLAY=0; ADDSCORE=1; MATCH_AGAINST_SEARCH=2;
  25. // search state
  26. STOPPED=0; SEARCHING=1;
  27.  
  28. function onSearchBegin(querykey, explicit, queryraw, querynokeyword,modifierstring,triggermethod){
  29.  skip_value = 0;
  30.  if(!explicit) {
  31.    if(aliasstr.indexOf(querynokeyword)!=-1) {
  32.      FARR.setState(querykey,1);
  33.      FARR.emitResult(querykey,aliasstr, aliasstr, iconfilename,ALIAS,IMMEDIATE_DISPLAY,300);
  34.      FARR.setState(querykey,0);
  35.    }
  36.    return;
  37.  }
  38.  FARR.setState(querykey,SEARCHING);
  39.  FARR.emitResult(querykey,"Hello World!","1" , iconfilename,UNKNOWN,IMMEDIATE_DISPLAY,1000);
  40.  FARR.emitResult(querykey,"Bonjour Tout le Monde!","2" , iconfilename,UNKNOWN,IMMEDIATE_DISPLAY,1000);
  41.  FARR.setState(querykey,STOPPED);
  42. }
  43.  
  44. HANDLED=1; CLOSE=2;
  45. function onProcessTrigger(path, caption) {
  46.  switch (path) {
  47.    case "1":
  48.      FARR.setStrValue("launch", "paste Hello World!")
  49.      break;
  50.    case "2":
  51.      var shell = new ActiveXObject("WScript.Shell");  
  52.      shell.Run("C:\\windows\\system32\\mspaint.exe \"C:\\windows\\system32\\ntimage.gif\"",1,true);
  53.      break;
  54.    default:
  55.      break;
  56.  }
  57.  return HANDLED;
  58. }
Logged

My open-source online piano game: http://musicope.com/
dreftymac
Supporting Member
**
Posts: 13


View Profile Give some DonationCredits to this forum member
« Reply #7 on: June 27, 2008, 12:43:59 PM »

try this:

SPLENDID!

That is precisely what I was looking for. Thank you very much, sir czechboy. May honor be upon your house for all days.

Thanks,
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.059s | Server load: 0.07 ]