XYplorer Messenger - Rev. 1.20 / 2013/02/08

Discuss and share scripts and script files...
Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

XYplorer Messenger - Rev. 1.20 / 2013/02/08

Post by Marco »

[This first post gets updated from time to time, particularly when a new revision is released. You are strongly advised to read this post carefully!]

Latest release notes

Code: Select all

Rev. 1.20 / 2013/02/08
 * A NULL character was appended to every command, leading
   to unpredictable results. Fixed.
A little executable that remotely controls XYplorer by sending it messages (hence the name) using the WM_COPYDATA command.

Features

[*]Open source: the AutoIt v3 code is available below.
[*]Customizable: all the parameters are neatly gathered on top, so you could tweak this basic utility to work with other applications.
[*]No external dependencies: all the necessary code is contained inside the script.

General structure

The first four lines of the script contain the working parameters, namely

[*]$Script: the command that will be passed to XYplorer. According to XYplorer 12.00 help, page 305,
The syntax is identical to the one of the command line switch /
script=<script resource>, so you can either pass the path to a script file (commonly
called *.xys), or pass the script directly (must be preceded by ::).
[*]$WM_COPYDATA: the identifying code of such Windows command.
[*]$hWnd: the handle of XYplorer window, which is identified by its class, i.e. "ThunderRT6FormDC".
[*]$dwData: another parameter, set according to the aforementioned help file.

Follows service code to parse all these parameters and then send the desired message.

Usage

Technically, you run the compiled executable with the desired script as parameter, following the rules quoted above. Period.
Try starting XY and minimizing it. Then create a shortcut to the executable, set the target like this and see what happens...

Code: Select all

"C:\path\xyplorer_messenger.exe" :: $Freddie = "Who wants<crlf>to live<crlf>forever?"; text $Freddie
But my psychic powers are telling me that 99% of you is still thinking "WTF?". So I better describe my real-world usage scenario. Quick background can be found at http://www.xyplorer.com/xyfc/viewtopic.php?f=3&t=9205 and http://forum.voidtools.com/viewtopic.php?f=2&t=1643 . Everything (the MFT search engine) requires admin privileges, but I run under a limited account. So whenever I double click on a item among the search results an elevated instance of the related software (Winamp for mp3's, Word for docx's) is run. And that's no good. But here comes the trick where this code comes in handy. I always have a running XYplorer instance as limited user in background, and I set these values in Everything's ini file:

Code: Select all

explore_folder_command=$exec("C:\path\XYplorer\XYplorer.exe" "%1")
open_folder_path_command=$exec("C:\path\XYplorer\XYplorer.exe" "%1")
explore_folder_path_command=$exec("C:\path\XYplorer\XYplorer.exe" "%1")
open_file_command=$exec("C:\path\xyplorer_messenger.exe" ::open "%1")
open_folder_command=$exec("C:\path\xyplorer_messenger.exe" ::open "%1")
The first three lines tell Everything to explore paths with XYplorer: XYplorer will popup showing the content of the selected folder.
The last two lines instead tell Everything that, upon double click on a file or folder, the path should be embedded in a ::open "path" quick script and passed as a parameter to the messenger, which will in turn send this message to XYplorer.
Bottom line benefits:
-no more elevated instances of various software
-no more XYplorer window popping up unnecessarily
-you can use your PFAs!

Tested on

* Microsoft® Windows® 7 Ultimate SP1 x64 ITA

Requirements

* XYplorer with
- scripting enabled

Notes


* :!: :!: :!: I absolutely take no responsibility for whatever damage, direct or indirect, the usage of this script may cause. This code is provided as-is, use at your own risk. You are advised.

Possible future updates

* Switching to C/C++/C#, which should provide faster execution times;

Previous releases notes

Code: Select all

Rev. 1.10 / 2013/02/07
 * Now the command to be passed is handled verbatim.
   This means no more quotes hell.

Rev. 1.00 / 2013/02/06
 * The first version.
 :D :D :D Special thanks to...

* http://rainmeter.net/cms/Developers-API-WindowMessage, for providing the AutoIt v3 code base
* Channing, who indirectly suggested to identify XYplorer window by its class

Code

Code: Select all

$Script = $CmdLineRaw
$WM_COPYDATA = 0x004A
$hWnd = WinGetHandle("[CLASS:ThunderRT6FormDC]")
$dwData = 0x00400001

$iSize = StringLen($Script)
$pMem = DllStructCreate("wchar[" & $iSize & "]")
DllStructSetData($pMem, 1, $Script)

$pCds = DllStructCreate("dword;dword;ptr")
DllStructSetData($pCds, 1, $dwData)
DllStructSetData($pCds, 2, ($iSize * 2))
DllStructSetData($pCds, 3, DllStructGetPtr($pMem))

DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $WM_COPYDATA, "wparam", 0, "lparam", DllStructGetPtr($pCds))
Compiled code

Code: Select all

xyplorer_messenger.exe 
Size  : 302.343 byte
MD5   : 1a4c4683955c4838411d8d69908de16d
SHA-1 : 351962b54a0846b94cd0460fa6cfbccf6472dbb9
CRC32 : 1139DEA9

xyplorer_messenger.zip 
Size  : 286.858 byte
MD5   : f6b80b8f648811ccf79b3b27929f953a
SHA-1 : 780500ca68a806ab7a0adccec191ecd9ae90376f
CRC32 : 207C03D6
Attachments
xyplorer_messenger.zip
(280.13 KiB) Downloaded 512 times
Last edited by Marco on 08 Feb 2013 16:04, edited 6 times in total.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by serendipity »

Thanks Marco!!
I wanted to give a shot at $WM_COPYDATA too, now i don't have to.
Will try this and report back.

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by Marco »

serendipity wrote:Thanks Marco!!
I wanted to give a shot at $WM_COPYDATA too, now i don't have to.
Will try this and report back.
And if you know C you could rewrite it, so the exe size can be squeezed down to a couple of kbs.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by TheQwerty »

This is really impressive Marco!
I can't say I have a need for it or plan to use it anytime soon, but it's some fantastic work. :appl:

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by Marco »

TheQwerty wrote:This is really impressive Marco!
I can't say I have a need for it or plan to use it anytime soon, but it's some fantastic work. :appl:
Thank you. My usage scenario so far is the one I described above... Don spoils us all with fast paced beta releases, so I fear that the other developer might take a lot to change his program architecture. "A lot" according to the standards we are used over here :mrgreen:
So I had to do something, and here it is.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by Marco »

Don, all of the sudden PFAs don't work with this technique. In XY I associated *.maff files with Firefox and here's what happens:
-if I past in the address bar ":: open C:\sample.maff" the file is opened by XY as expected
-if I send ":: open C:\sample.maff" via WM_COPYDATA I get that Windows little message that estension is not recognized blah blah blah
Can you repro? It worked till 6 hours ago. Also tried a fresh install, no luck...
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

admin
Site Admin
Posts: 59751
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by admin »

I'm not aware of any changes. :|

admin
Site Admin
Posts: 59751
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by admin »

Did you already recheck with 12.00.0000?

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by Marco »

Yes, just rechecked with a fresh 12.00.0000 to which I just added said PFA, still no luck. Unfortunately I don't have another computer to test, that's why I asked if you could repro. I even rebooted, because you never can tell.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

admin
Site Admin
Posts: 59751
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by admin »

Tell me exactly how I should test this.

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by Marco »

Ok.

Requirements: XY 12.00.0000 (from homepage), XYplorer Messenger 1.00 (from the zip on the first post)

Steps:

0. Unpack XYplorer and unpack XYplorer Messenger
1. In the folder where you unpacked XYplorer Messenger create a file called new.cue. Such file should have a blank icon and upon double click should trigger the "unrecognized extension" message by Windows.
2. Still in said folder, create a link to the messenger, and in the properties set the target as

Code: Select all

C:\path\xyplorer_messenger.exe ":: open ""C:\path\new.cue"""
3. Open XYplorer and create this PFA

Code: Select all

cue>notepad
4. Now double click the link created at step 2. While you should see the notepad, but you get the unrecognized extension message instead. Typing in the address bar

Code: Select all

:: open "C:\path\new.cue"
works as expected tho.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

admin
Site Admin
Posts: 59751
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by admin »

Confirmed.

See the trailing quote in the message. Some parsing issue...
Attachments
2013-02-07_120042.png
2013-02-07_120042.png (13.89 KiB) Viewed 14085 times

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by Marco »

That's strange because I don't see any odd quotes
Immagine.png
Immagine.png (28.78 KiB) Viewed 14081 times
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

admin
Site Admin
Posts: 59751
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by admin »

Totally weird. If I use a known extension (eg *.txt) I see no odd quotes and it works as expected (file is openend). Buffling.

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: XYplorer Messenger - Rev. 1.00 / 2013/02/06

Post by Marco »

Ok, 99% solved. I notice that

Code: Select all

C:\path\xyplorer_messenger.exe ":: open ""C:\path\new.cue"","
(mind the comma) works as expected. Do your magic now!
PS: I'm going to publish an updated code (actually just one word) that will send the message to XY raw/verbatim, so there's no quoting hell involved.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

Post Reply