Run scripts from an external program?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Channing
Posts: 12
Joined: 25 Oct 2012 14:13

Run scripts from an external program?

Post by Channing »

Hello everyone,

I'm the developer of Listary, a utility that can provide great help for XYplorer users. For example, with Listary, you can:
  • After any open/save file dialog pops up, you can press Ctrl + G to jump to the folder you're viewing in XYplorer directly.
  • If you switch from any file dialog to XYplorer, do some file management work, and then switch back to the file dialog, Listary will let the dialog jump to your working folder in XYplorer automatically.
  • Press your mouse middle button or the hot key Win + W in XYplorer, Listary will show up with all your important and recent opened folders.
  • And many more...
Lots of my users hope that Listary can integrate more with XYploer, and the amazing scripting support in XYplorer seems to be a very good starting point. Unfortunately I've only found the hard AHK way to run a piece of script from an external program:
1. Fill XYplorer address bar with the script like "::msg".
2. Simulate an Enter key press in the address bar.

Two reasons I don't like it:
1. It will mess up the user's address bar history. I'd like to run tens of scripts, but they will definitely overwrite all the user's address bar history.
2. It's not stable. You know, simulating keyboard input, it just doesn't work sometimes.

I'm looking for a more easy way to run scripts in XYplorer from an external program, something like sending a WM_COPYDATA command with the full script to a specific hwnd.

Please help me. Thank you!

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Run scripts from an external program?

Post by SkyFrontier »

http://www.xyplorer.com/release_9.50.htm
Now you can run a script directly from the command line. (Pro Edition Only)

The switch is /script=[script resource], where [script resource] can be:

1) The path to a script file (commonly called *.xys). The file spec is resolved as in the script command load, so you can skip the XYS extension. You can also skip the path if the XYS file is located in the default scripts folder. For example
XYplorer.exe /script=test

would run the file <xyscripts>\test.xys on startup. If the path contains spaces it must be quoted:
XYplorer.exe /script="C:\Zen\test one.xys"

2) A script. It must be preceded by ::, and it must not contain double quotes or other characters that might lead to problems when parsing the command line. For example
XYplorer.exe /script="::msg 'Welcome to XY!';"

Note the double quotes surrounding the whole argument which are needed because of the spaces in the script line.
Hope this helps...
...and welcome to the board!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Run scripts from an external program?

Post by SkyFrontier »

To XYplorer users it's worth mention this, taken from Listary's version history:

http://www.listary.com/download
Version History

3.51.858 (8 May 2012)

——————————————–

- New: XYplorer 11.00 support
I'm not a Listary user myself but will check out its integration with XY. Probably to suggest a better approach from what I suggested in my previous post - or just correct it, in case it's the wrong answer.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Channing
Posts: 12
Joined: 25 Oct 2012 14:13

Re: Run scripts from an external program?

Post by Channing »

SkyFrontier wrote:http://www.xyplorer.com/release_9.50.htm
Hope this helps...
...and welcome to the board!
Thank you very much for the information!

Sorry that I didn't make it clear in my first post: I'd like to run many (tens of) scripts in the current instance of XYplorer, and these scripts may need to retrieve information from the file list which the user is viewing. For example, one script is to write the path of the selected file to a .txt file, so Listary can help the user open it in a file open dialog. Passing the script in command line doesn't seem to work in this situation?

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

Re: Run scripts from an external program?

Post by Marco »

Code: Select all

XYplorer.exe /script=":: #101;" /flg=2
The first switch contains the script. For copying the path+filename to clipboard that's all you need, a #101.
The second switch is the big deal, and instructs XY to reuse the current instance.

If I understand correctly, /flg=2 is what you'll always have to use.
Last edited by Marco on 25 Oct 2012 16:00, edited 1 time in total.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Run scripts from an external program?

Post by SkyFrontier »

IF command line is the way to go, then I'd recommend you/your users to pass each script into a separate XY instance. I recall seeing an observation here in the forums regarding a SECOND script execution being NOT recommended to run on a same instance of the program (can't confirm, sorry), imagine TENS of them...
It seems to be there are very specific cases which may or may not be handled well by XY/background operations/queued copying, so I suggest you/your users to post the detailed cases and wait a bit for the answers to show up.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Channing
Posts: 12
Joined: 25 Oct 2012 14:13

Re: Run scripts from an external program?

Post by Channing »

@Marco
Thank you, it works!

I'm thinking of instead of passing the script in command line, let my program passing it directly to the existing XYplorer instance in the same way the second XYplorer.exe does. XYplorer.exe does seem to use WM_COPYDATA to pass the command line parameters.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Run scripts from an external program?

Post by highend »

So we'll see a working Listary integration (in XYplorer) soon?
One of my scripts helped you out? Please donate via Paypal

Channing
Posts: 12
Joined: 25 Oct 2012 14:13

Re: Run scripts from an external program?

Post by Channing »

highend wrote:So we'll see a working Listary integration (in XYplorer) soon?
Yes, very soon :D

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

Re: Run scripts from an external program?

Post by admin »

Channing wrote:@Marco
Thank you, it works!

I'm thinking of instead of passing the script in command line, let my program passing it directly to the existing XYplorer instance in the same way the second XYplorer.exe does. XYplorer.exe does seem to use WM_COPYDATA to pass the command line parameters.
Hi,

I agree that WM_COPYDATA is the way to do inter-app communication, and passing a script (even a long one) this way should be no problem. However, I'm currently in the midst of what must be the biggest re-write in history (opening a 200,000 lines source code for Multilingual Support, with thousands of partly complex messages that had been hard-coded to English over 15 years ... groan). If I survive this, I will add WM_COPYDATA support for remote scripting. Can take some weeks.

Don

Channing
Posts: 12
Joined: 25 Oct 2012 14:13

Re: Run scripts from an external program?

Post by Channing »

admin wrote: I agree that WM_COPYDATA is the way to do inter-app communication, and passing a script (even a long one) this way should be no problem. However, I'm currently in the midst of what must be the biggest re-write in history (opening a 200,000 lines source code for Multilingual Support, with thousands of partly complex messages that had been hard-coded to English over 15 years ... groan). If I survive this, I will add WM_COPYDATA support for remote scripting. Can take some weeks.

Don
Hello Donald,

Thank you very much for your reply. Just take your time. I found that I can send a WM_COPYDATA with 0x008BF6D6 and /script="::[my script];", it does pretty much the same thing :wink:

Good luck with the big refactoring!

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

Re: Run scripts from an external program?

Post by admin »

Wow, good hacking! :)

But note some things:
- users can turn off scripting.
- the Home edition comes without scripting.

If you tell me what exactly you want to achieve by remote scripting, I might find an easier and safer way for you to do it.

Channing
Posts: 12
Joined: 25 Oct 2012 14:13

Re: Run scripts from an external program?

Post by Channing »

admin wrote:If you tell me what exactly you want to achieve by remote scripting, I might find an easier and safer way for you to do it.
Here are a few things I need currently:
  • Get the selected/highlighted file path in the current XYplorer instance. Then with one simple hot key press, Listary can help the user open it in a file dialog.
  • Let the current XYplorer window jump to a folder and select one specific file. The new beta version of Listary adds Everything integration, and I'd like to bring the ultra fast full disk search experience to XYplorer.
  • Export the file list content. This will make it easier for Listary to do some search and add favorites.
  • Open a new tab with specific path and file type filters. With Listary you can use Total Commander to totally replace file dialogs, and I'd love this feature to also support XYplorer.
Also, I'd like to confirm the WM_COPYDATA runs synchronously, i.e. at the moment WM_COPYDATA returns, the script is guaranteed to be finished?

Thank you very much for your time :)

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

Re: Run scripts from an external program?

Post by admin »

Channing wrote:
admin wrote:If you tell me what exactly you want to achieve by remote scripting, I might find an easier and safer way for you to do it.
Here are a few things I need currently:
  • Get the selected/highlighted file path in the current XYplorer instance. Then with one simple hot key press, Listary can help the user open it in a file dialog.
  • Let the current XYplorer window jump to a folder and select one specific file. The new beta version of Listary adds Everything integration, and I'd like to bring the ultra fast full disk search experience to XYplorer.
  • Export the file list content. This will make it easier for Listary to do some search and add favorites.
  • Open a new tab with specific path and file type filters. With Listary you can use Total Commander to totally replace file dialogs, and I'd love this feature to also support XYplorer.
Also, I'd like to confirm the WM_COPYDATA runs synchronously, i.e. at the moment WM_COPYDATA returns, the script is guaranteed to be finished?

Thank you very much for your time :)
OK, I think remote scripting is indeed the way for you. Until I'm ready to add something a little more civilized, you can do your testing with your WM_COPYDATA hack. Yes, most scripts run synchronously, and your scripts are among them as it looks from your post above.

Cool project, BTW!

kodyman
Posts: 222
Joined: 09 Apr 2011 04:05

Re: Run scripts from an external program?

Post by kodyman »

Channing wrote:
highend wrote:So we'll see a working Listary integration (in XYplorer) soon?
Yes, very soon :D
YEA!!! :biggrin: :appl:

Post Reply