Can't Open New Instance Of XY With Script

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
Jeff Bellune
Posts: 284
Joined: 13 Dec 2007 12:55

Can't Open New Instance Of XY With Script

Post by Jeff Bellune »

Allow Multiple Instances is unchecked in Configuration Settings.

The script:

Code: Select all

run ""<xy>" /new";
does not open a new instance of XY. Instead, it opens Windows Explorer. Same result whether XY is set as the default file manager or not.

Bug or Operator Error?

Thanks,
Jeff

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

Re: Can't Open New Instance Of XY With Script

Post by klownboy »

Instead use...it works.

Code: Select all

run """<xy>"" /new";

Jeff Bellune
Posts: 284
Joined: 13 Dec 2007 12:55

Re: Can't Open New Instance Of XY With Script

Post by Jeff Bellune »

Thanks.

From the Help file:
Names with blanks must be quoted. Note that the quotes have to be wrapped in single-quotes double-quotes because an argument's outer quotes are auto-stripped by XY's script parser!
I guess this applies to each argument in the expression, not just the whole expression. Hopefully I'll remember this for next time. :)

Cheers,
Jeff

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

Re: Can't Open New Instance Of XY With Script

Post by klownboy »

Hi Jeff, many here get around the quoting "fun" by setting up the command in a variable and by doing something like this...which will work in the Address Bar.

Code: Select all

::$xy = "<xy> /new"; run $xy;

Jeff Bellune
Posts: 284
Joined: 13 Dec 2007 12:55

Re: Can't Open New Instance Of XY With Script

Post by Jeff Bellune »

Nice tip, thanks! I ended up putting it in an "Open" UDC:

Code: Select all

"<xy>" /new
If I use it enough, I'll probably make a toolbar button out of it. Then I can use your code.

Cheers,
Jeff

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Can't Open New Instance Of XY With Script

Post by PeterH »

klownboy wrote:Hi Jeff, many here get around the quoting "fun" by setting up the command in a variable and by doing something like this...which will work in the Address Bar.

Code: Select all

::$xy = "<xy> /new"; run $xy;
Sorry: this isn't the same :roll:

<xy> is path and name of XY executable. It *may* contain blank characters.
Assume: path is c:\p f\xy\xyplorer.exe
the run cmd will give as argument: c:\p f\xy\xyplorer.exe /new
The first token is the executrable, it is: c:\p :?
The rest are 2 arguments :veryconfused:
So that the 1st argument is the correct path it must be wrapped in double quotes: "<xy>"
This must be expressed as a string, i.e. wrapped in quotes - *double* quotes, as a variable <xy> must be resolved. But: double quotes inside double quotes must be doubled :shock: so:
"""<xy>"" /fresh"
This may be assigned to a variable, or be directly given with run.

As long as you are 100% sure that <xy> doesn't contain blanks, and never will, you can drop the inner, doubled double quotes as you did. But if you show it to someone else this may be incorrect for him!

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

Re: Can't Open New Instance Of XY With Script

Post by klownboy »

I see what you're saying, but I though Don just made a change (within the past couple of weeks) in XY's built in variables not requiring them to be quoted at all (see v14.30.0301 notes).

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Can't Open New Instance Of XY With Script

Post by PeterH »

klownboy wrote:I see what you're saying, but I though Don just made a change (within the past couple of weeks) in XY's built in variables not requiring them to be quoted at all (see v14.30.0301 notes).
I think it's right: <xy> must not be quoted.
But what about /fresh?
(You see: I didn't specify it as a string, and so you don't know what I mean! I mean " /fresh" - note the blank inside the quote, but no trailing "?"!!)
So you could write
$xy = <xy> . "/new"; run $xy;
BUT: <xy> may not contain blank(s) here! Solution:
$xy = """" . <xy> . """ /new"; run $xy;

OK, to be serious: we talk about different things. Exact: <xy> may be unquoted, but Run cmd needs the path (i.e. <xy>) quoted.
<xy> or "<xy>" is the path, and now quote it: """".<xy>."""" or """<xy>"""
(Result of both is like "c:\path\path\xyplorer.exe")

I hope this explains it a bit more...

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

Re: Can't Open New Instance Of XY With Script

Post by klownboy »

Thanks PeterH, I saved this post in my "Fun with XY Quoting" Favorites folder. :) I do typically double quote in scripts even when it's an assigned variable as an example,

Code: Select all

  $g_IrfanPath="d:\graphics\irfanView\i_view32.exe";
  run """$g_IrfanPath"" $file /aspectratio /jpgq=100 /crop=($x_crop, $y_crop, $width, $height) /convert=$path\". $base ."_$xy.$ext", , 2,0;
but I had tested what I had posted earlier, it worked and never thought about spaces (obviously I don't have spaces in my XY command line). Now maybe the above isn't totally correct either but it has worked for me for last couple of years.
Thanks again,
Ken

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Can't Open New Instance Of XY With Script

Post by PeterH »

klownboy wrote:Thanks PeterH, I saved this post in my "Fun with XY Quoting" Favorites folder. :) I do typically double quote in scripts even when it's an assigned variable as an example,

Code: Select all

  $g_IrfanPath="d:\graphics\irfanView\i_view32.exe";
  run """$g_IrfanPath"" $file /aspectratio /jpgq=100 /crop=($x_crop, $y_crop, $width, $height) /convert=$path\". $base ."_$xy.$ext", , 2,0;
but I had tested what I had posted earlier, it worked and never thought about spaces (obviously I don't have spaces in my XY command line). Now maybe the above isn't totally correct either but it has worked for me for last couple of years.
Thanks again,
Ken
I think your wording doesn't exactly fit the statements :mrgreen:
In both lines you use text-strings, containing characters as c: or /aspectratio - and these must be quoted. That is: quotes are needed!
Next you use the ability of XY, that variables inside double quotes are resolved. So it generally isn't necessary to take the variables outside the quotes and use concatenation. So I'd say: the variables are not explicitely quoted - they are just inside quotes.
And there is one (solved) problem: a variable inside double quotes must be recognized. That's easy if it's name is followed by a blank or another character that is not allowed in variable names. But the variable $base is followed by an underscore - if it would be inside the double quotes it would be trated as $base_ :arrow: you correctly have pulled these apart by concatenation.

And the very last to say (I think) is to the doubled quotes in run """$g_IrfanPath"" ... These are not for XY, but for the run command, to possibly recognize the file, though it's name might contain blanks. You could have changed that as

Code: Select all

  $g_IrfanPath="""d:\graphics\irfanView\i_view32.exe""";
  run "$g_IrfanPath $file /aspectratio /jpgq=100 /crop=($x_crop, $y_crop, $width, $height) /convert=$path\". $base ."_$xy.$ext", , 2,0;
the result would exactly be the same. This shows: the doubled double quote leads to a double quote in the resultant string. And as the 1st statement contains no variable:

Code: Select all

  $g_IrfanPath='"d:\graphics\irfanView\i_view32.exe"';
  run "$g_IrfanPath $file /aspectratio /jpgq=100 /crop=($x_crop, $y_crop, $width, $height) /convert=$path\". $base ."_$xy.$ext", , 2,0;
the same again, i.e. double quotes inside single quotes are not doubled :D

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

Re: Can't Open New Instance Of XY With Script

Post by klownboy »

Hi again PeterH, it was nearly 2 years ago that I posted an "early" version of my script PhotoCropper You probably don't remember but if you scan down to the bottom of the post I noted you helped me through some issues probably in other threads. Note that the run command line is identical to what I posted above. You probably wouldn't believe how many iterations of that run line, and another I used with ImageMagick instead of Irfanview, I tried before I got them working. I did substitute your line above and it did work as you said it would.
Once again thanks for your help,
Ken

Jeff Bellune
Posts: 284
Joined: 13 Dec 2007 12:55

Re: Can't Open New Instance Of XY With Script

Post by Jeff Bellune »

klownboy wrote:You probably wouldn't believe how many iterations of that run line, and another I used
I'd sure believe it. I went through dozens of iterations recently trying to get a script-generated.m3u playlist to open in Mp3tag. I just kept adding quotes around everything until I got it right. 8)

Cheers,
Jeff

Post Reply