Pass search value to XY via cmd

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Pass search value to XY via cmd

Post by yusef88 »

I tried to pass the search value by /user switch and it works but for one-time unless you restart xy
is there another way to make it run again with existing instance of XY?

form command line:

Code: Select all

"C:\Program Files\XYplorer\XYplorer.exe" /script=cmd /user=%1 /flg=2
the script:

Code: Select all

    echo get("CmdLineUser");
    $a=get("CmdLineUser"); 
    setkey "$a", "Named", "Named", "<xydata>\FindTemplates\cmd.ini";
    #260;loadsearch "cmd", rlec
the benefit is: search in XYPlorer from Firefox

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Pass search value to XY via cmd

Post by highend »

Put it in a permanent variable?
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Pass search value to XY via cmd

Post by yusef88 »

would it help if the value is set in permanent variable? please provide more details

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Pass search value to XY via cmd

Post by highend »

Your %1 is resolved during the XY call through your 3rd party application, right?

Then you can either use a perm variable (if you need it even if you quit xy in the meantime) or a global one
if it's only in the current session by:

Code: Select all

"C:\Program Files\XYplorer\XYplorer.exe" /script="::global $cmd;$cmd=%1;load 'cmd';" /flg=2
While the cmd.xys accesses this (in this case global) variable via:

Code: Select all

    global $cmd;
    echo $cmd;
    <your other commands>...
And you could exchange "global" with "perm" in the xy call and cmd.xys + a "writepv;" command to save it...
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Pass search value to XY via cmd

Post by yusef88 »

Thanks a million highend
one more question, could XY remove first 3 letters like this batch file does?

@echo off
setlocal EnableDelayedExpansion
set w=%1
set W=%W:~3%
echo.%W%
"C:\Program Files\XYplorer\XYplorer.exe" /script="::global $cmd;$cmd=%W%;load 'cmd';" /flg=2

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Pass search value to XY via cmd

Post by highend »

Code: Select all

$cmd = substr($cmd, 3);
?
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Pass search value to XY via cmd

Post by yusef88 »

Thanks again
if interested here is a bookmarklet to search in xyplorer from firefox

Code: Select all

javascript:Qr=document.getSelection();if(!Qr){void(Qr=prompt('Registry%20entry%20to%20find:',''))}if(Qr)location.href='xy:'+(Qr);void(0)
and this reg file to register the Protocol, of course in addition to your script

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\XY]
@="URL:XYplorer Protocol"
"URL Protocol"=""
"CustomUrlArguments"=""

[HKEY_CLASSES_ROOT\XY\shell]

[HKEY_CLASSES_ROOT\XY\shell\open]

[HKEY_CLASSES_ROOT\XY\shell\open\command]
@="\"C:\\Program Files\\XYplorer\\XYplorer.exe\" /script=\"::global $cmd;$cmd=%1;load 'cmd';\" /flg=2"


yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Pass search value to XY via cmd

Post by yusef88 »

could ampersands be escaped?
blue%20sky ===> blue sky

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Pass search value to XY via cmd

Post by highend »

urldecode()
One of my scripts helped you out? Please donate via Paypal

Post Reply