SkyFrontier wrote:I'd like to have the ability to assign a permanent CKS to a temporary script.
- Menu "User"
- "Manage Commands..."
- "Run Script" >> New.. >> Add new command...
>>> Caption: [ Launch temporary script]
>>> Script: [ Load temporary;]
>>> [ Assign Keyboard Shortcut...] e.g. Alt+Q
- OK
Now create an file "temporary.xys" in your XYplorer-/-Data\Scripts folder:
Now if you press Alt+Q every script file called "temporary.xys" in your scripts-folder will be started.
- - -
an more general way would be :
- Menu "User"
- "Manage Commands..."
- "Run Script" >> New.. >> Add new command...
>>> Caption: [ Launch temporary script]
>>> Script: [ <paste the code from below here in> ]
>>> [ Assign Keyboard Shortcut...] e.g. Alt+Q
- OK
Base script is:
Load listfolder("<xyscripts>", "#*.xys", 1);
Script with error handling:
Code: Select all
//Find an XYS script in XY-Scripts folder prefixed by an '#' sign and load that script.
$LoadTemporaryScript = listfolder("<xyscripts>", "#*.xys", 1, "<crlf>");
IF ( strpos($LoadTemporaryScript, "<crlf>") > 0 )
{$LoadTemporaryScript = replace($LoadTemporaryScript, "<xyscripts>\");
msg "Quick Script Loader :error:<crlf><crlf>More then one #*.xys found!
I give up.<crlf>$LoadTemporaryScript";
}else{ Load "$LoadTemporaryScript";}
Now you only have to rename an script file and add an '#' in front of the name and that script will be executed.
Example:
XYplorer-/-Data\Scripts folder: "#AnyNamedScript.xys"
Code: Select all
msg "Hi. i am #AnyNamedScript.xys";
Now if you press Alt+Q every script file having an leading '#'-sign in your scripts-folder will be started.
Note: there must be only ONE script with an leading '#'-sign in the name!
HTH?
- - -
An another idea is this:
I have in my XYS template
"X:\xyplorer\NewItems\Script {yyyy-mm-dd_hh-nn}.xys"
this code for every new script file:
self $File, file; setkey $File, "LastScript", "Script", "<xyscripts>\LastScript.ini"; //store this xys as last xys for reuse
that way i get an LastScript.ini with e.g. this content:
[Script]
LastScript=X:\xyplorer\Scripts\HighlightNEWfiles.xys
Next i have an User Command with an shortcut
which use getkey() to read the item of this LastScript.ini and execute just the last used script.
For example:
Code: Select all
$CRIPT = getkey("LastScript", "Script", "<xyscripts>\LastScript.ini"); //read last script name from ini
end($CRIPT==""), "No Script in ini, or no ini-file found at all.";
end(exist($CRIPT)!=1), "Entry found in ini, but script didn't exist anymore.";
Load $CRIPT; //execute last script
-------
EDIT
SkyFrontier wrote:Second idea (#script) is cool. -but I don't store scripts
Maybe one of this ideas from my scripting IDE is something for you:
Load an default temporary script in your favorite editor,... press OK once you are finished with editing to execute the script:
Code: Select all
"Run Editor Notepad2"
$EDITOR = "X:\Notepad2\Notepad2.exe";
$CRIPT = "C:\Temp\xyscript.xys";
$CRIPT = input(Script to edit, , $CRIPT);
run $EDITOR $CRIPT;
wait 2000;
msg "Click OK once you have<crlf>saved your script to load it...",1;
Load $CRIPT;
(i tried to build an "IDE" with an editor with syntax highlighting and XY related help, but had to do other things in the meantime..., maybe later more.)
As an addition an second entry:
Code: Select all
"Just load default script"
$CRIPT = "C:\Temp\xyscript.xys";
Load $CRIPT;
Or select an script from many:
Code: Select all
"Select an script"
$CRIPT = inputfile("C:\Temp", "xys", "Load script file");
Load $CRIPT;
Code: Select all
"Select an script"
$CRIPT = inputfile("<xyscripts>", "xys", "Load script file");
Load $CRIPT;
Code: Select all
"Open the help"
run "<xypath>\XYplorer.chm";
wait 1000;
SendKeys "{DOWN}";
SendKeys "{DOWN}";
SendKeys "{DOWN}";
SendKeys "{ENTER}";
SendKeys "{DOWN}";
SendKeys "{DOWN}";
SendKeys "{DOWN}";
SendKeys "{DOWN}";
SendKeys "{DOWN}";
SendKeys "{ENTER}";
.