Page 1 of 1

Pass search value to XY via cmd

Posted: 23 Oct 2016 20:21
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

Re: Pass search value to XY via cmd

Posted: 23 Oct 2016 21:09
by highend
Put it in a permanent variable?

Re: Pass search value to XY via cmd

Posted: 23 Oct 2016 22:10
by yusef88
would it help if the value is set in permanent variable? please provide more details

Re: Pass search value to XY via cmd

Posted: 23 Oct 2016 22:50
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...

Re: Pass search value to XY via cmd

Posted: 23 Oct 2016 23:29
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

Re: Pass search value to XY via cmd

Posted: 23 Oct 2016 23:33
by highend

Code: Select all

$cmd = substr($cmd, 3);
?

Re: Pass search value to XY via cmd

Posted: 23 Oct 2016 23:45
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"


Re: Pass search value to XY via cmd

Posted: 24 Oct 2016 00:32
by yusef88
could ampersands be escaped?
blue%20sky ===> blue sky

Re: Pass search value to XY via cmd

Posted: 24 Oct 2016 00:44
by highend
urldecode()