remote control of xyplorer via tcp

Features wanted...
leinad
Posts: 47
Joined: 17 Jun 2010 09:08

remote control of xyplorer via tcp

Post by leinad »

Hi,

XYplorer is so fully loaded with features, that it is a bit troublesome to get at them.

I'm using "HID macros" to use a second keyboard to execute some python scripts via a single keypress (that is, one keyboard as a control board, instead of a typing board). I would like some of those python scripts to make a TCP connection (telnet, http, whatever) to XYplorer, to issue commands like "load catalog test.dat", "toggle hide catalog and show tree" "minimize/unminimize tree", "hide pane 1" "open desktop in pane 2" "show files with tag xy in folder abc" "minimize window" "restore window" and so on.

I think this feature is kind of important. I'm using xyplorer less and less because I've got it set up for a special working scenario, so that I don't want to just open a folder in it, as if it were a replacement for a windows explorer window, since xyplorer, unlike a windows explorer window is a open once and keep open forever application, while windows explorer is a open use and discard thing. This is because it is kind of tedious to get it set up the way you need it to be.

If I could use remote commands not only to load different stored layouts, but also to invoke certain actions, like the examples I used above, I would be
in explorer heaven.

Kind regards,
Daniel

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

Re: remote control of xyplorer via tcp

Post by admin »

Did you know that you can run a script at startup using the /script=... command line switch?

leinad
Posts: 47
Joined: 17 Jun 2010 09:08

Re: remote control of xyplorer via tcp

Post by leinad »

Actually I didn't notice that until after I posted this thread.

But I'm facing some problems. The most important one is that it doesn't retain the current directory. If no directory is given, it loads XYplorer's root, else I have to tell it to load something.

But apart from this, there is a lot which can be archived with the command line. I'll be testing this over the next few days and will then give my feedback, but the issue with the folders is really a bit problematic.

I'm also in the need of saving the current layout and loading a saved one. How can I archive this? With different ini files? Does this require a restart of XYplorer?

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

Re: remote control of xyplorer via tcp

Post by admin »

leinad wrote:I'm also in the need of saving the current layout and loading a saved one. How can I archive this? With different ini files? Does this require a restart of XYplorer?
Yes, with different ini files, and yes it requires a restart. And note that since Dual Pane was added, a level of complexity had to be added as well, and parts of the layout (the tabs) are now stored in extra files in the "panes" subdirectory.

leinad
Posts: 47
Joined: 17 Jun 2010 09:08

Re: remote control of xyplorer via tcp

Post by leinad »

But the problem is that when I run the script from the command line, first the pane contents get changed to either the default directory, or the directory passed with the command. When I first want to save the current layout (including the open tabs/paths), I'm unable to do so, because it will be modified first.

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

Re: remote control of xyplorer via tcp

Post by admin »

leinad wrote:But the problem is that when I run the script from the command line, first the pane contents get changed to either the default directory, or the directory passed with the command. When I first want to save the current layout (including the open tabs/paths), I'm unable to do so, because it will be modified first.
Yes. XY is not really built for what you want to achieve. It's a "local control" file manager. :)

leinad
Posts: 47
Joined: 17 Jun 2010 09:08

Re: remote control of xyplorer via tcp

Post by leinad »

well yeah, I get what you mean, but you know that I'm actually referring to localhost, so it's not really a valid argument. The point is that I want to inject commands, and while the command line thing comes pretty close to what I need, it does have a really bad problem.

I believe that you would help me a lot if you could change the command line behaviour, possibly by adding a /control flag which then indicates that if an instance is reused, absolutely no changes are made to the ui. This means, that no pane content will change, no focusing will change, the only thing that will happen is that the script passed as a parameter will get executed in this instance.

Is this possible? I'd appreciate it, since this would suit 99% of my needs and build upon a preexisting technology (command line) instead of requiring the addition of a new ipc system (sockets).

As a workaround I could read out the \Data\Panes\x\pane.ini before issuing the command in order to pass the current directory via the command line, but how would I know which is the active pane+ active tab without issuing a script? Could something like this work?

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

Re: remote control of xyplorer via tcp

Post by admin »

Maybe I did not understand correctly but this should work already since v9.90.0104:

Code: Select all

v9.90.0104 - 2011-01-26 15:28
    + Command Line: Now the /script switch to run a script directly from 
      the command line also works in a re-used previous instance. So if 
      you really want you now can feed scripts into the running instance 
      via command line.
EDIT: OK, I think I got it. Feeding the script works BUT you don't want to do any path changing. Correct?

zer0
Posts: 2676
Joined: 19 Jan 2009 20:11

Re: remote control of xyplorer via tcp

Post by zer0 »

Just to throw my hat in the ring -- considering my data protection and security background -- it is a potentially risky area to allow software to be launched with specified parameters remotely without doing any kind of authentication. It is bordering on remote code execution. Just sayin' :)
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

leinad
Posts: 47
Joined: 17 Jun 2010 09:08

Re: remote control of xyplorer via tcp

Post by leinad »

EDIT: OK, I think I got it. Feeding the script works BUT you don't want to do any path changing. Correct
Yup.
Just to throw my hat in the ring -- considering my data protection and security background -- it is a potentially risky area to allow software to be launched with specified parameters remotely without doing any kind of authentication. It is bordering on remote code execution. Just sayin'
That may be true in the tcp case, but at the command line? I mean, you already got there. In case of tcp this could be enabled in the properties, with disabled default. If you enable it you certainly will want to check your firewall settings, so this is not really a problem.

Anyway, I'm awaiting that non-path-changing command line stuff eagerly; I love this app :)

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

Re: remote control of xyplorer via tcp

Post by admin »

leinad wrote:Anyway, I'm awaiting that non-path-changing command line stuff eagerly; I love this app :)
It's already there since v10.40.0115! (Not yet mentioned in the Help file but it works.)

Code: Select all

    + Command Line Switches: Now you can feed a script into an existing
      instance of XYplorer without changing the location or tabs of that
      instance. Simply pass the new switch /flg=2 in the command line,
      for example:
        E:\XY\XYplorer\XYplorer.exe /script="::msg 'Hi!';" /flg=2

leinad
Posts: 47
Joined: 17 Jun 2010 09:08

Re: remote control of xyplorer via tcp

Post by leinad »

That's great to hear!

But for some reason this is not working for me.

subprocess.Popen('C:\\App\\XYplorer\\XYplorer.exe /script="::load \'show.xys\', showCatalog; catalogload \'locations.dat\', \'sp\';" /flg=2')

is executing the script successfully, but also replacing the path. That's on version 10.50.0000

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

Re: remote control of xyplorer via tcp

Post by admin »

leinad wrote:That's great to hear!

But for some reason this is not working for me.

subprocess.Popen('C:\\App\\XYplorer\\XYplorer.exe /script="::load \'show.xys\', showCatalog; catalogload \'locations.dat\', \'sp\';" /flg=2')

is executing the script successfully, but also replacing the path. That's on version 10.50.0000
Strange. Are you sure you are calling an already running instance?

Here's a little debug trick. Run this script through the address bar:

Code: Select all

::showcommandfromotherinst 1;
Then call your remote control line command. Now a message should show the command that is passed to XYplorer. Does it look okay?

leinad
Posts: 47
Joined: 17 Jun 2010 09:08

Re: remote control of xyplorer via tcp

Post by leinad »

Does it look okay?
I'm not sure what to expect. I get a popup with

Command: /script="::load 'show.xys", showCatalog; catalogload 'locations.dat', 'sp';" (Unicode: False)

If I remove the /flg=2 flag, then the popup contains the same content. If I change/flg=2 to /flag=2, the popup changes to

Command: /script="::load 'show.xys", showCatalog; catalogload 'locations.dat', 'sp';" "C:\App\XYplorer" (Unicode: False)

The difference is that when the text "C:\App\XYplorer" does not appear in that popup, then the active tab changes to "Computer" showing the list of drives, instead of the content of XYplorer's root folder.

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

Re: remote control of xyplorer via tcp

Post by admin »

leinad wrote:
Does it look okay?
I'm not sure what to expect. I get a popup with

Command: /script="::load 'show.xys", showCatalog; catalogload 'locations.dat', 'sp';" (Unicode: False)

If I remove the /flg=2 flag, then the popup contains the same content. If I change/flg=2 to /flag=2, the popup changes to

Command: /script="::load 'show.xys", showCatalog; catalogload 'locations.dat', 'sp';" "C:\App\XYplorer" (Unicode: False)

The difference is that when the text "C:\App\XYplorer" does not appear in that popup, then the active tab changes to "Computer" showing the list of drives, instead of the content of XYplorer's root folder.
Looks like /flg=2 is missing. Strange, the syntax of your command looks okay at first sight.

Aaah, wait, I could reproduce it.... :twisted:

Post Reply