Page 1 of 1

Command line /win=min to respect "min" even if XY already running

Posted: 28 Jan 2025 22:10
by FluxTorpedoe
Hi’

⮚ Use case
Since scripts are so powerful, I’m using XYplorer to process files from other apps (eg to reformat parts of md files from Obsidian itself).
For this, I use the command line with /feed to send the script info to my existing instance of XYplorer.
It works very well, but I can’t find a way to keep XYplorer minimized (or at least not being brought to front):
/win=min seems to be honored only if XYplorer is not already running.

It can easily be tested from a dos prompt:

Code: Select all

XYplorer.exe /win=min /feed="::msg 1;"
If this is run when XYplorer is closed, only the message window with 1 is shown, as expected, as XYplorer is launched (and remains) minimized.
But if this is run when XYplorer is already running, even minimized, it is brought to front.

⮚ Wish
Could there be a way to send scripts to a running instance of XYplorer without opening/displaying it?
(whether it’s by enforcing /win=min to honore this all the time, or by adding a new /win or a new /flg…)

Thank you,
   Flux

Re: Command line /win=min to respect "min" even if XY already running

Posted: 28 Jan 2025 22:18
by highend
Just for your reference: If you do it via WM_COPYDATA, XY stays minimized...

Re: Command line /win=min to respect "min" even if XY already running

Posted: 29 Jan 2025 11:51
by FluxTorpedoe
Hello Highend,
I’ve never used nor thought of using this, more work but more possibilities obviously. Here I guess I could pass it via Powershell (used instead of cmd only to launch XYplorer)…
Another alternative was via autohotkey, but I try to reserve it for more system-oriented tasks when I find no other way.
In my current case, everything was working straight between Obsidian and XYplorer, I liked that simplicity. ;)

Anyway, thank you for the tip!

Re: Command line /win=min to respect "min" even if XY already running

Posted: 29 Jan 2025 13:52
by highend
XY_Send script.xys
Rename the attachment to .exe

You can call it via:
0 arguments: It takes the clipboard content to send it to XY
1 argument: This can either be the script itself (single line, it can't include "!) or a full path to a XY script file

Scripts send via wm_copydata require a leading "::". The .exe makes sure it exists and if not, adds it, so all these calls would work:

Code: Select all

// Clipboard contains the script
"XY_Send script.exe"

// Script code to send, no " in the script itself allowed
"XY_Send script.exe" "e 'a';"

// Script to read & send, make sure it really exists
"XY_Send script.exe" "D:\a.xys"

Re: Command line /win=min to respect "min" even if XY already running

Posted: 30 Jan 2025 20:50
by FluxTorpedoe
Thank you for sharing this!
(BTW, unrelated, I like the icon ;) )

Well, I knew a huge amount of things can already be done straight through the command-line with /feed… —hence my wish.

But for more elaborate tasks, it seems indeed that harnessing WM_COPYDATA via AHK makes for a powerful combination!
After your first tip, I also looked into SC copydata, never had a chance or need to try it it until now, I noticed it also needs some external (AHK…) handler for hwnd, etc.
This opens up a whole lot of possibilities… (And maybe I’ll switch my AHK scripts to v2 when I find the time, if there are some benefits.)
But all that is a different topic ;)