Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • December 05, 2016, 06:41:44 AM
  • Proudly celebrating 10 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: Qatapult  (Read 108687 times)

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 409
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Qatapult
« Reply #250 on: March 16, 2012, 12:19:09 PM »
I had a look at it. I thought is would be possible to use the stream property, but there seem to be no access to bytes. There seems to be ways to do that with ADODB objects, but using properties of objects that are not made for that purpose is not really nice.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 409
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Qatapult
« Reply #251 on: March 16, 2012, 04:04:10 PM »
Also I've tried to read the registry though WMI calls and it was painfully slow... My original idea was that libffi was the solution. The issue was that it would be relatively long to implement.

However I've also found this activex component that might be easier to integrate as it already provide the activescripting binding :

http://www.borncity....aar1/WSHDynaCall.htm

It's a script component that allows to do native call to dll. It's not as clean as libffi but if it works for you I might integrate that into Qatapult. That would make possible to build a javascript library to read files, etc... I've not tried it but as it's a component you should be able to play with it on you computer to evaluate if it's solve your problem.

If that works we could build a set of js libraries to call native functions more easily.

Let me know.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Qatapult
« Reply #252 on: March 16, 2012, 05:42:51 PM »
Thanks for the leads.  I hope to take a look soon.



I also came across ADODB.Stream, but didn't determine whether it's usable without extra installation.  I didn't try it, but found the following concerning byte-access:

  Read

Then there's access to characters:

  ReadText

It looks like at least one of these was used by:

  http://www.codeproje...-Files-Using-JScript



DynaCall looks promising!  Is it correct that using RegSvr32.exe is required to get it working?

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 409
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Qatapult
« Reply #253 on: March 16, 2012, 05:59:03 PM »
Yes regsvr is required but this is for the short term. If it proves a viable solution I can integrate it inside Qatapult.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Qatapult
« Reply #254 on: March 16, 2012, 06:27:45 PM »
Thanks for the clarification.



Below is a short sample expanding on your example -- it uses the script capability via plugin.xml.

All it does is allows one to take one-line notes via "Add Line Note", and view them via the linenote catalog item.  (BTW, is there a way to specify the name that gets used for the catalog item apart from renaming the plugin directory?)

MD5: 8f82449b43a6d27ba63c2c9a09691d7d

Tested on Windows 7 Pro 64-bit.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Qatapult
« Reply #255 on: March 16, 2012, 06:38:25 PM »
However I've also found this activex component that might be easier to integrate as it already provide the activescripting binding :

http://www.borncity....aar1/WSHDynaCall.htm

There appears to be a more recent modified version:

  http://glsft.free.fr...;id=47&Itemid=33

I suspect you will have a much easier time understanding the article than me :)

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 409
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Qatapult
« Reply #256 on: March 16, 2012, 07:00:04 PM »
I tried it and it works nicely.

I'm not sure about what you're trying to accomplish, but listing the items in you catalog can be accomplished by adding a extra rule that list objects from your collect source. It could be a rule like : List Notes,LINENOTE. This is the method I would favor as you can customise the icon etc...

When you'll type list notes, Qatapult will query all plugins for LINENOTE object. I'm not sure if this is a good idea or not you can also return TEXT object when rules expect TEXT and LINENOTE when then expect that.

I think there is something that is missing here, it should be possible to return multityped objects or something, because you can't really reuse LINENOTE objects as TEXT because they won't be recognized by rules as such... If you have some thoughts about that let me know.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Qatapult
« Reply #257 on: March 16, 2012, 07:01:46 PM »
DynaWrap worked for a simple case :)

Here is a rough summary of a test:

0. Download dynawrapNT.zip and extract the dynawrap.dll file (MD5: ca218f1aa4bf60d5deacebe0f55a2f95).

1. As admin, run cmd.exe and in the directory containing dynawrap.dll execute:

RegSvr32.exe dynawrap.dll

2. In a .js file of some Qatapult plugin, appropriately add something like:

Code: Javascript [Select]
  1. // :)
  2.   var dw;
  3.   dw = new ActiveXObject("DynamicWrapper");
  4.   dw.Register("User32.dll", "MessageBoxA", "f=s", "i=hssu", "r=l");
  5.   dw.MessageBoxA(null, "Here is a test", "So?", 0);

3. Execute plugin functionality that calls the code added above.

4. Observe a message box.

Tested with Windows 7 Pro 64-bit and Windows XP Pro SP3.



The following was helpful:

  How to use DynamicWrapper?



Attached the dynawrap zip file for the time being.

MD5: a27c9c53fb22379463b6f2e3cb812d45
« Last Edit: March 16, 2012, 08:56:43 PM by ewemoa »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Qatapult
« Reply #258 on: March 16, 2012, 09:58:45 PM »
Not sure how to use DynaCall / DynaWrap in JScript for functions requiring pointers...e.g. ReadFile:

Code: C [Select]
  1. BOOL WINAPI ReadFile(
  2.   __in         HANDLE hFile,
  3.   __out        LPVOID lpBuffer,
  4.   __in         DWORD nNumberOfBytesToRead,
  5.   __out_opt    LPDWORD lpNumberOfBytesRead,
  6.   __inout_opt  LPOVERLAPPED lpOverlapped
  7. );

The more recent DynaWrap version mentioned earlier had the following:

Quote
FormatMessage (dwMessageId)                                          
GetBSTRAddr (String)                                                  
GetLastError ()                                                      
GetMemInBSTRAddr (dwBSTRAddr, dwOffset, nDataType)                    
GetRegistered ()                                                      
GetVariantAddr (Var)                                                  
Register (DllName, Win32Api, [TypeOfCall], [ReturnDT], [InputDT])    
SetMemInBSTRAddr (dwBSTRAddr, dwOffset, nDataType, Data)              
Version

I didn't think trying GetBSTRAddr would work, but I tried it anyway -- sadly without success.

Any ideas?

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 409
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Qatapult
« Reply #259 on: March 17, 2012, 07:10:02 PM »
Correct, I can't get GetBSTRAddr to work either. May be that's a javascript issue as the component seems to be made to work with VBScript ? I asked the developer he doesn't mind to share his sources and we will not go really far without the sources.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript
« Last Edit: March 17, 2012, 07:15:46 PM by ecaradec »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Qatapult
« Reply #260 on: March 17, 2012, 07:54:51 PM »
Thanks for testing and the feedback :)

I'm not sure about what you're trying to accomplish, but listing the items in you catalog can be accomplished by adding a extra rule that list objects from your collect source. It could be a rule like : List Notes,LINENOTE. This is the method I would favor as you can customise the icon etc...

I'm feeling dense -- would you mind elaborating on what you mean by expressing it via a sample plugin.xml fragment?



Quote
I think there is something that is missing here, it should be possible to return multityped objects or something, because you can't really reuse LINENOTE objects as TEXT because they won't be recognized by rules as such... If you have some thoughts about that let me know.

I'm not sure I understand well, but may be the following code fragment is related:

To add to results currently:

Code: Javascript [Select]
  1. results.addObject('FILE', path, {'key': path, 'text': path, 'path': path});

it looks like only one type is specified.  May be there is some benefit in being able to specify multiple types for an object in this kind of context (perhaps with some way of a default being specified)?

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 409
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Qatapult
« Reply #261 on: March 22, 2012, 06:32:39 PM »
Hello,

It has been long but native calls seems to work, at least in the cases I tried. I wrote a few basic functions to read and write from the registry. There is also a function to read a file, but it's meant to do binary reading not text so it's currently not as useful as FileSystemObject is. If you want to add new functions don't forget to get debugview up and running. It makes things easier, and don't forget you're going native so expects crashes as you fine tune your parameters.

Plugins can also require libraries using the keyword require so share your libraries, I'll add them to the lib directory of Qatapult.

Have a look at the Uninstall plugin which use natives functions to read the registry to get started.

And the Qatapult website has a new developer section with rudimentary documentation and an enhanced look : http://emmanuelcaradec.com/qatapult/
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Qatapult
« Reply #262 on: March 22, 2012, 10:31:45 PM »
It has been long but native calls seems to work, at least in the cases I tried.

Woohoo!

Quote
And the Qatapult website has a new developer section with rudimentary documentation and an enhanced look : http://emmanuelcaradec.com/qatapult/

 :Thmbsup:

Hope to delve in soon :)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Qatapult
« Reply #263 on: March 23, 2012, 04:41:57 AM »
A side note...

If you want to add new functions don't forget to get debugview up and running. It makes things easier, and don't forget you're going native so expects crashes as you fine tune your parameters.

I use DebugView, but also JrDebugLogger :)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Qatapult
« Reply #264 on: March 23, 2012, 10:33:24 PM »
If you want to add new functions don't forget to get debugview up and running.

Seems to work well with:

Code: Javascript [Select]
  1. // trace (always useful, get debugview to view the result )
  2. trace(string str);

I can now replace use of text files for recording debugging info via FileSystemObject:

Code: Javascript [Select]
  1. outf.WriteLine("some message");

with:

Code: Javascript [Select]
  1. qatapult.trace("some message");

Thanks a lot for this -- extremely helpful!

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Qatapult
« Reply #265 on: March 25, 2012, 05:57:32 AM »
It's nice how "Reload" (the command, not the image) now comes up here as the first result for "re" :)

Is there any way to tweak the scores of the objects added via plugins?  This would likely improve the usefulness of the OpenWith plugin -- at the moment, the objects added for that appear pretty close to the bottom of the results list and consequently I make repeated use of the PgDn key.

FWIW, I looked at:

  http://emmanuelcaradec.com/qatapult/?p=developers

but didn't see anything that looked relevant.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Qatapult
« Reply #266 on: March 25, 2012, 06:32:09 AM »
I'm thinking about how to display results of a plugin's execution.  Below are some ideas:

One simple way at the moment is using a dialog box via <script> in plugin.xml, require('lib/files.js'); and a function that calls DW.MessageBoxA(null, "Content", "Title", 0);  (As a side note, may be it's worth having MessageBoxW too?)

Perhaps some kind of balloon tip as well?  I'm not sure how much work that might be yet.

For execution results one might want to operate on again (e.g. calculation results, conversion results, transformed URLs, etc.) placing such text in the first pane (pane 0) seems appropriate -- is there a nice way to do that (apart from the AHK hack tested eariler)?

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 409
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Qatapult
« Reply #267 on: March 25, 2012, 07:58:25 AM »
Quote
Is there any way to tweak the scores of the objects added via plugins?
It's possible to specify a bonus field to your results to boost it's score : addObject(type, {bonus:100}); A negative bonus would also works but I'm not sure if that's a good or bad idea.

Quote
As a side note, may be it's worth having MessageBoxW
Yes, just wrote it and I'll add it to the library. messagebox or msgbox would be a better name, I'd rather have simplified functions than the direct windows API as it will be easier for everyone.

For notifications, I think we should really offer some flexibility, might be we need a notify function that can have several behavior based on a settings so that the result can be handled by Qatapult, Growl or Windows, or something else.

About reoperating results, I agree with you. That's something I'd like to have several times as using qatapult. I'm wondering if what you want to place on the first pane is a typed result or just a text.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript
« Last Edit: March 25, 2012, 10:55:42 AM by ecaradec »

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 409
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Qatapult
« Reply #268 on: March 25, 2012, 01:34:45 PM »
I've uploaded a new version, the main feature is a kind of a filter. Rule arguments can now match some subproperties of object. This is very useful to add extra methods to applications. I've created a putty plugin that add a connect method and that list the server configurations availables in the registry.

The syntax of the argument looks like that :
<arg>
  <type>FILE</type>
  <pred>rfilename=PUTTY.EXE</pred>
</arg>

The pred node is a filter that will make FILE only match if rfilename is putty.exe. The value name is flexible, you can test any value available on the object : path, text, icon, or any other custom value. The match is case insensitive.

There is also a regex predicate that you can enable by typing filename~=xxx . The important difference is the operator '~='. I think that it might be useful to propose custom actions if a text match a url like "http://" or an email or math expression (starting with = with only operator expression ? ). Regex tests are case sensitive too.

Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 409
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Qatapult
« Reply #269 on: March 25, 2012, 02:28:27 PM »
I uploaded a new version again that allows to display an object as a result of a script command. It only works within a script command, you can't use it at any other moment and it can only set the first pane object. You can do something like that :

qatapult.setInput({type:"FILE",text:"c:\\",path:"c:\\"});

or

qatapult.setInput({type:"TEXT",text:"hello"});
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Qatapult
« Reply #270 on: March 25, 2012, 05:43:05 PM »
It's possible to specify a bonus field to your results to boost it's score : addObject(type, {bonus:100}); A negative bonus would also works but I'm not sure if that's a good or bad idea.

Thanks for this tip!  It seems to work well here :)

As far as negative bonuses go -- IIUC a similar thing may be done in FARR with useful results.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Qatapult
« Reply #271 on: March 25, 2012, 05:47:30 PM »
messagebox or msgbox would be a better name, I'd rather have simplified functions than the direct windows API as it will be easier for everyone.

I appreciate not having to think about appending A or W :)

Quote
For notifications, I think we should really offer some flexibility, might be we need a notify function that can have several behavior based on a settings so that the result can be handled by Qatapult, Growl or Windows, or something else.

That sounds like a good idea.

Quote
I'm wondering if what you want to place on the first pane is a typed result or just a text.

Initially I just thought text, but my brain is starting to wonder.  If any relevant-seeming ideas come up, I hope to pass them on.

Ah...I guess your latest version may have related functionality already :)

Thanks for the new version -- hope to try it soon!

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 409
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Qatapult
« Reply #272 on: March 26, 2012, 02:29:39 AM »
It seems I wasn't clear, I confirm you that setinput is the way to set the pane arguments. I struggled to find a decent name for the function and as a result I'm not sure that the final choice is a good fit. This might really be a too much thought method name.  :P

I think that it was absolutly necessary that I set type to the results : just setting the input query would have been completly unreliable, as you could have end up with the wrong result like an extra filename on some other person computer.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 409
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Qatapult
« Reply #273 on: March 29, 2012, 09:56:41 AM »
Just thinking that one of the common uses for setInput would be when you zip a file, or do something else with a file to reopen Qatapult with the ouput file focused.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 409
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Qatapult
« Reply #274 on: March 29, 2012, 11:53:09 AM »
Do you mind if I change the name of setInput to setOutput ? I think it would be more appropriate.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript