Page 1 of 1
external input to show specified tab...AND FILE
Posted: 04 Aug 2016 15:01
by sasumner
So for a long time now I have been able to tell XY to create (or switch to) a tab based on input from another program (let's call the other program a batch file because that works for purposes of this explanation), and I do it like this:
"C:\Program Files (x86)\XYplorer\XYplorer.exe" /flg=8 "C:\a\b\c"
The above runs XY (if not running) or commands XY (if running) to go to tab "c" by creating (if the XY tab doesn't exist) or switching to (if not in existence) it.
ALL IS JUST GREAT WITH THIS!

[I honestly have forgotten what the /flg=8 does for me in this case, but no matter....]
Here's what I
HAVEN'T been successful with doing:
I want to see the file "C:\a\b\c\d.txt" in the XY tab's fileview when I run the command (the file can be selected or not, I don't care, I just want to make sure it is visible (i.e, without having to scroll the window manually). So....XY should create or switch to a tab labelled "c", and then, in the fileview I should be able to see "d.txt" immediately after I run the batch file.
I have tried variations of the /select= switch, for example:
"C:\Program Files (x86)\XYplorer\XYplorer.exe" /flg=8 "C:\a\b\c\" /select="d.txt"
or
"C:\Program Files (x86)\XYplorer\XYplorer.exe" /flg=8 /select="C:\a\b\c\d.txt"
and some other variants of this...
but have met with no success.
Is there an easy way to do what I'm looking to do, if my explanation makes some amount of sense?
Thanks!
Re: external input to show specified tab...AND FILE
Posted: 04 Aug 2016 15:31
by highend
/flg=8: No Custom Column scripts are executed. That way you can start in XYplorer even when you messed up your scripts.
"C:\Program Files (x86)\XYplorer\XYplorer.exe" /flg=8 /select="C:\a\b\c\d.txt"
Works fine here. Although XY doesn't switch to an existing tab, even if it has one open that points to the same path.
What
exactly happens on your system?
Something that should be reliable (and can be used if XYplorer has scripting enabled):
Save this script in your scriptfolder (<xyscripts>):
Code: Select all
global $item;
$parent = gpc($item, "path");
$tabExists = False;
while ($i++ < tab("get", "count")) {
$tabPath = trim(tab("get", "path", $i), "\", "R");
if ($tabPath LikeI $parent) { $tabExists = True; break; }
}
if ($tabExists) { seltab $i; }
else { tab("new", $parent); }
selectitems $item;
sel "+0";
focus;
Call it e.g.: "ScrollIntoView.xys"
Now invoke XYplorer like this:
"C:\Program Files (x86)\XYplorer\XYplorer.exe" /flg=2 /script="::global $item='C:\a\b\c\d.txt';load 'ScrollIntoView'"
This variant get's the parent path of the $item you provided as the argument, checks if a tab with that path exists, switches to it if that's the case or creates a new one and focuses + selects + scrolls the item into view. Works with folders / files alike
Re: external input to show specified tab...AND FILE
Posted: 04 Aug 2016 19:34
by sasumner
It must have been an error or typo on my part as
"C:\Program Files (x86)\XYplorer\XYplorer.exe" /flg=8 /select="C:\a\b\c\d.txt"
now seems to work for me.
I tried the script (this is the first one I've ever run!) and it also works. Thanks. I noticed with the script that if I start each line in column one, XY pops up a menu with each line listed as a separate menu item; if I have the whitespace leading off the lines (a verbatim copy of the script) it works as intended. I will have to look into why this works like this.
Regardless, thanks for your input and I'm sorry for the false alarm about the original /select not seeming to work.
Re: external input to show specified tab...AND FILE
Posted: 04 Aug 2016 19:57
by highend
if I start each line in column one, XY pops up a menu with each line listed as a separate menu item; if I have the whitespace leading off the lines (a verbatim copy of the script) it works as intended. I will have to look into why this works like this.
From the help file:
In a multi-line script all lines apart from the first line have to be indented by at least one space.
Re: external input to show specified tab...AND FILE
Posted: 04 Aug 2016 21:36
by sasumner
I think I figured out why the /select= wasn't working for me. It involves the "Desktop", and I think it is an XY bug.
Invoking:
"C:\Program Files (x86)\XYplorer\XYplorer.exe" /flg=8 /select="C:\Users\myusername\Desktop\a\b\c\d.txt"
doesn't work!
It creates a "? d.txt" tab in XY and shows "? Location currently not available. Desktop\a\b\c\d.txt\" in the file view.
Note especially the trailing backslash, that wasn't passed in...hmmm.
However, the very similar invocation, not involving the Desktop in the path:
"C:\Program Files (x86)\XYplorer\XYplorer.exe" /flg=8 /select="C:\a\b\c\d.txt"
works!
creates or switches to "c" tab in XY and shows and selects d.txt
Also, substituting /flg=2 in causes nothing to happen in XY for either case.
Re: external input to show specified tab...AND FILE
Posted: 04 Aug 2016 21:43
by highend
It doesn't look that bad on my system (it only swallows the rightmost backslash when using "Desktop" in the path) but I file a bug report...
Re: external input to show specified tab...AND FILE
Posted: 12 Feb 2018 15:31
by sasumner
So I've been using the "ScrollIntoView" script (above) successfully ever since the date of the prior postings in this thread...
At version 18.70.0000 of XYplorer, it stopped working. Running it as described above causes XY to either run (if not running) or activate (if running) but it doesn't open (or switch to) the tab desired. I also tried 18.70.0100 and not working there either (same result as .0000).
So for the moment I have downgraded to 18.60.0000, but I'm wondering what broke it in 18.70.* and if it can be fixed? Or maybe the script needs adjusting to cope with something new in the new version of XY?
Thanks for any assist, here...
Re: external input to show specified tab...AND FILE
Posted: 12 Feb 2018 15:45
by highend
Show the exact command line that you've used to invoke XY. Additionally a screenshot of your open tabs (with complete paths)
and the element from the command line that you wanted to navigate to
The scripts still works fine here with 18.70.0100...
Btw, I modified it a bit (using an item directly in the root of a drive didn't detect a belonging tab):
Code: Select all
global $item;
$parent = gpc($item, "path");
$tabExists = False;
while ($i++ < tab("get", "count")) {
$tabPath = trim(tab("get", "path", $i), "\", "R");
if ($tabPath LikeI $parent) { $tabExists = True; break; }
}
if ($tabExists) { seltab $i; }
else { tab("new", $parent); }
selectitems $item;
sel "+0";
focus;
Re: external input to show specified tab...AND FILE
Posted: 03 Sep 2023 13:19
by sasumner
Rereading the history here... aside from the minor burble I seemed to have in 2018 (which must have been a non-issue since I didn't pursue it), this has been working great for me for a long time.
(Also from a reread of the history: The two versions of the script seem to be the same, not sure why this is...)
-----------
OK, present day question:
I notice that sometimes when this runs, the XYplorer title bar flashes several times (along with the desired script action being completed). It doesn't happen all the time, and in fact right now I can't force it to happen, so I can't be more specific about what I might be doing at time of occurrence. It's more of a curiosity than an annoyance, but I was just wondering if anyone knows under what circumstances this flashing can occur...
Re: external input to show specified tab...AND FILE
Posted: 12 Sep 2023 14:53
by sasumner
I'm rather surprised that no one answered my recent question, but I'll go ahead an answer it myself:
So it turns out that when the XYplorer title bar flashing was occurring, I had the Alt key held down when invoking the XYplorer command line (and script). You'd think that it is a bit hard to do those two things at once, but what I have is some text in a text file that looks like this: xy:c:\testdir\test.txt and in the editor it looks like a hypertext link, and part of invoking it via the link is holding Alt while clicking the link (double-click doesn't do it in this application). Script logic recognizes the Alt+click of the hyperlink, and runs XY; this happens while the Alt key is still down, and XY sees the Alt as well (and apparently this causes the XY titlebar flashing). The solution is, in the script code, wait for all keyboard modifiers to be released BEFORE running the XY command.