XYplorer Messenger - Rev. 1.20 / 2013/02/08
Posted: 06 Feb 2013 12:12
[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!]
A little executable that remotely controls XYplorer by sending it messages (hence the name) using the WM_COPYDATA command.
[*]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.
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,
[*]$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.
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...
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:
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!
* Microsoft® Windows® 7 Ultimate SP1 x64 ITA
* XYplorer with
- scripting enabled
* 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.
* Switching to C/C++/C#, which should provide faster execution times;
* 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
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.
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,
[*]$WM_COPYDATA: the identifying code of such Windows command.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 ::).
[*]$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
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 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.
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