Easier Way to CKS a Temporary Script.

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Easier Way to CKS a Temporary Script.

Post by SkyFrontier »

I'd like to have the ability to assign a permanent CKS to a temporary script.
Say I'm batch renaming several files on a session, but soon I'm creating a series of folders or anything else via script. So I'd like to have a CKS to run such temporary scripts, and have a way to easily edit them so I can have another script assigned to that very CKS. All of this must be retained across sessions.
-Run Script... requires at least CKS plus CTRL+Enter, and it does not retain scripts after XY reloading.
-Anything goes, alias, catalog (which I don't use at all), anything - fast and easy.
Thanks!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Easier Way to CKS a Temporary Script.

Post by Stefan »

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:

Code: Select all

msg "Hi. i am temporary.xys";
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? :D


- - -

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}";
.
Last edited by Stefan on 01 Oct 2010 18:51, edited 2 times in total.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Easier Way to CKS a Temporary Script.

Post by SkyFrontier »

Second idea (#script) is cool. -but I don't store scripts (except for the ones that NEED to be there when executed). Doesn't fit my workflow. :!: I could keep such #script.xys and edit it to store... HEY, I could write a little sequence to quickly get such file ready (air code: writefile #script.xys, <clipboard>), THEN execute your method. Minimum impact, maximum results.
-thanks for the error handling! Always better to have it than not.

Same goes for the first idea - I thought about that, but found it to be a hassle looking after and editing such tempscript.xys. The idea above may solve partially the problem, as I intend to create a CTB (Custom Toolbar Button) for it.

The third one seems to be great, except that (as stated above) I don't use such structure for now. BUT soon I'll get some spare time and select few scripts (currently stored under User > Run Script) and save them as .xys at the <xyscripts> folder.
-is it possible for XY to append your LastScript/Script key to all of those scripts at once, and to selected when required (=future scripts added to such collection)? If so, can you please build a code for that?
-would you mind in sharing that User Command "which use getkey() to read the item of this LastScript.ini and execute just the last used script"?
Thank you!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Easier Way to CKS a Temporary Script.

Post by SkyFrontier »

Codes for CTB:

Code: Select all

"TempScript|:steps" writefile("<xyscripts>\temporary.xys", <clipboard>, o, ta)
"CheckTempScript|:steps" open "<xyscripts>\temporary.xys"
-can the cool xyScripts icons be added as valid :xyscript icons, Don?
Thanks!

EDIT: Added suggestion to use :steps icon to distinguish them from other scripts within a list of a CTB.
Last edited by SkyFrontier on 01 Oct 2010 18:05, edited 1 time in total.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 65255
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Easier Way to CKS a Temporary Script.

Post by admin »

SkyFrontier wrote:Codes for CTB:

Code: Select all

"TempScript" writefile("<xyscripts>\temporary.xys", <clipboard>, o, ta)
"CheckTempScript" open "<xyscripts>\temporary.xys"
-can the cool xyScripts icons be added as valid :xyscript icons, Don?
Thanks!
It's outdated, isn't it?

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Easier Way to CKS a Temporary Script.

Post by SkyFrontier »

I like them (despite thinking that they may not be that cool when resized that down...).
-there are few of us who seem to still use the old XY icon, too.
-and if you're/other user able to provide new fashioned XY script icons thinking on them as CTB icons too, why not?!
Thanks!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 65255
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Easier Way to CKS a Temporary Script.

Post by admin »

SkyFrontier wrote:I like them (despite thinking that they may not be that cool when resized that down...).
-there are few of us who seem to still use the old XY icon, too.
-and if you're/other user able to provide new fashioned XY script icons thinking on them as CTB icons too, why not?!
Thanks!
OK, I'll wait a couple of days, if nothing turns up, I make some myself.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Easier Way to CKS a Temporary Script.

Post by SkyFrontier »

Thanks! :mrgreen:
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Easier Way to CKS a Temporary Script.

Post by Stefan »

SkyFrontier>Second idea (#script) is cool. -but I don't store scripts
I have added something to my post above. (Load an default temporary script in your favorite editor)

SkyFrontier>would you mind in sharing that User Command "which use getkey()
SkyFrontier>to read the item of this LastScript.ini and execute just the last used script"?

Sure, i just had it not at hand and had no time and don't want to post untested things.
I have modified my post above.

SkyFrontier>is it possible for XY to append your LastScript/Script key to all of those scripts at once,
I guess: NO.
Because I can add an new line at top of all files, even by an dos command,
but this new line have to be added with an correct indention and i would have
to check if the current script have labels or not,... so i can't imagine to manage this,
at least not at spending an time amount i would like to spend.

.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Easier Way to CKS a Temporary Script.

Post by SkyFrontier »

@Stefan:
...now we have plenty of ways to achieve such task. Thanks much!
And having tested what you offered, I'm satisfied with the current workflow (ah, if only I had this yesterday...).

I recall something about "use last loaded script", which also may be useful - will read and try it too, later. (I'm not sure this is what I was looking for, when remembered such stuff...)

Regarding Help:
1) :mrgreen: LOVED it! (the joke, the message, everything!)
2) Just yesterday I was wondering if some XY commands could be extended to external apps (not talking about parsing parameters...). THEY CAN, as it seems (will do some tests, later).
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Easier Way to CKS a Temporary Script.

Post by SkyFrontier »

SHIFT+S all the way... (SHIFT+H, in case one wants a harder to press shortcut so he can probably do less mistakes when testing scripts).
In case one miss this at the Beta section, here it goes:

Code: Select all

v9.60.0112 - 2010-10-28 13:10
    + Menu Scripting: Added command "Run Script Again". Runs the script
      previously entered in Run Script again.
Thanks much, Don! AGAIN! :D
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Easier Way to CKS a Temporary Script.

Post by SkyFrontier »

Hmmmmm...
What about Run Script being able to remember script across sessions, Don?
Power failures may interrupt an ongoing test project (I'm nobreak-covered on 2 machines, any way) leaving one (incautious or simply coding-focused enough to forget to backup) perhaps with hours of work in prejudice.
Thanks.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 65255
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Easier Way to CKS a Temporary Script.

Post by admin »

SkyFrontier wrote:Hmmmmm...
What about Run Script being able to remember script across sessions, Don?
Power failures may interrupt an ongoing test project (I'm nobreak-covered on 2 machines, any way) leaving one (incautious or simply coding-focused enough to forget to backup) perhaps with hours of work in prejudice.
Thanks.
I planned to do that anyway, why not now. :wink:

zer0
Posts: 2676
Joined: 19 Jan 2009 20:11

Re: Easier Way to CKS a Temporary Script.

Post by zer0 »

Considering how many potential solutions have been described and explained in this thread, it amazes me how yet another has been created. It's quantity that doesn't add quality :?
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Easier Way to CKS a Temporary Script.

Post by SkyFrontier »

zer0 wrote:Considering how many potential solutions have been described and explained in this thread, it amazes me how yet another has been created. It's quantity that doesn't add quality :?
Considering the product itself for a newcomer/user that will never come into forums (which almost was my particular case), this is the first and unique* solution, zer0.
Despite being able to frankenscript a solution, I still would like to see the official, supported and stable way to do the same achievement - sometimes with a prejudice to flexibility, but certainly with a less error-prone, future-proof behavior.

EDIT: *Not to mention easier...
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Post Reply