Set XYPlorer to the foreground with the command line

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Adequat
Posts: 96
Joined: 20 Jul 2007 12:03

Set XYPlorer to the foreground with the command line

Post by Adequat »

Let's say XYplorer is already running.
I want to show a given file or folder from another application, by executing XYPlorer from the command line.
It works, but XYPlorer remains in the background, while I want to the opposite.
Is there a way to achieve that, without starting a new instance of XYPlorer?
Thanks

armsys
Posts: 557
Joined: 10 Mar 2012 12:40
Location: Hong Kong

Re: Set XYPlorer to the foreground with the command line

Post by armsys »

Are you using any scripting language?

Adequat
Posts: 96
Joined: 20 Jul 2007 12:03

Re: Set XYPlorer to the foreground with the command line

Post by Adequat »

No. XYPlorer is called from another application, with a folder or file name as argument.
What happens is this: a new instance of XYPlorer is executed. It finds there is already a running XY instance. It transmits the arguments to this instance, which display correctly the file or folder. But unfortunatly the XY instance is not put to the front. That's the problem.

klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Set XYPlorer to the foreground with the command line

Post by klownboy »

Hi Adequat,
You said in your second post, a "new instance of XYplorer is executed", but you don't necessarily want that from your first post. So, you want the existing instance of XY to be used and for it to come to the forefront (i.e., be the active window). I'm just curious in XY's Configuration | Startup and Exit, do you have "Allow multiple instances" checked off? If you do, uncheck it and try it again.
Ken

Adequat
Posts: 96
Joined: 20 Jul 2007 12:03

Re: Set XYPlorer to the foreground with the command line

Post by Adequat »

You said in your second post, a "new instance of XYplorer is executed", but you don't necessarily want that from your first post.
Right. And "Allow multiple instances" is off.
But this is the way it works in Windows: a new instance is created, but detects there is already one, hence exits immediatly (after passing the arguments to the already running instance).
I am a programmer, and what I described here is what I can see from the debugger of the application calling XYPlorer.

klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Set XYPlorer to the foreground with the command line

Post by klownboy »

Hi again Adequat, OK now I get it. You probably have looked at the XY parameters in XY's help section on "Command line switches". There's a little section there on "Keeping a single instance". You may also want to try the /flg=2 switch as well, typically used for running scripts, but you may want to try it to see if it affects the XY being activated when run from another app. Try using a one line MSG script as in the help example to see if that forces XY to the top. Also, take a look a the new switch and explanation for <hwnd> in beta v13.10.0135. Again it applies to script running, but you still may want to experiment. I've had great success running XYplorer on it's own as well as XYplorer scripts via AutoHotkey, keeping the existing instance and starting XY if it's not already with no issues of it not becoming active or the topmost window.
Good luck,
Ken

Post Reply