Open script file externally from ctb Edit dialog

Features wanted...
Post Reply
kiwichick
Posts: 557
Joined: 08 Aug 2012 04:14
Location: Pahiatua, New Zealand

Open script file externally from ctb Edit dialog

Post by kiwichick »

When using a custom toolbar button, more often than not, I'm loading a script file from one of the 'on click' fields as opposed to using multi-line script. But if I want to edit the script file, I have to open the button Edit dialog to see what the name of the script file is, close the Edit dialog, navigate to the script file and open it in a my text editor. What would be great is if there was the ability to open it in the text editor directly from the button Edit dialog (eg: a separate button, or maybe Ctrl-click on the Edit button). Would that be possible?
Windows 10 Pro 22H2

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

Re: Open script file externally from ctb Edit dialog

Post by admin »

Difficult.

LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: Open script file externally from ctb Edit dialog

Post by LittleBiG »

kiwichick wrote: 07 Aug 2022 07:17 When using a custom toolbar button, more often than not, I'm loading a script file from one of the 'on click' fields as opposed to using multi-line script. But if I want to edit the script file, I have to open the button Edit dialog to see what the name of the script file is, close the Edit dialog, navigate to the script file and open it in a my text editor. What would be great is if there was the ability to open it in the text editor directly from the button Edit dialog (eg: a separate button, or maybe Ctrl-click on the Edit button). Would that be possible?
There could be a workaround.
Put the script file into the CTB name, and you will be able to refer it as ctbname() in the button scripts.
Then you can load it in the left click and open it by the run command in the middle click event.
Like this:
2022-08-08_15h52_04.png
2022-08-08_15h52_04.png (12.72 KiB) Viewed 485 times

kiwichick
Posts: 557
Joined: 08 Aug 2012 04:14
Location: Pahiatua, New Zealand

Re: Open script file externally from ctb Edit dialog

Post by kiwichick »

admin wrote: 08 Aug 2022 12:38Difficult.
Thanks Don, :tup:
Windows 10 Pro 22H2

kiwichick
Posts: 557
Joined: 08 Aug 2012 04:14
Location: Pahiatua, New Zealand

Re: Open script file externally from ctb Edit dialog

Post by kiwichick »

LittleBiG wrote: 08 Aug 2022 15:38 There could be a workaround.
Thanks! What a neat idea. I'll definitely look into it.

UPDATE: I have my .xys files set to open in Notepad++ so all I needed to do was enter the open command for the script file into the click field. Easy peasy!

Code: Select all

open "<xyscripts>\MyScript.xys";
Of course, it does mean I sacrifice one of the click fields using this as a workaround but it's better than nothing, so thanks again.
Windows 10 Pro 22H2

LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: Open script file externally from ctb Edit dialog

Post by LittleBiG »

If you don't want to sacrifice anything, use this kind of structure. Click runs the script, Ctrl+Click opens it.

Code: Select all

//leftscript
 $ctrl_pressed = get("shift") == 2;
   if ($ctrl_pressed) {
     open "<xyscripts>\MyScript.xys";
   }
   else {
     load "MyScript.xys";
   }

kiwichick
Posts: 557
Joined: 08 Aug 2012 04:14
Location: Pahiatua, New Zealand

Re: Open script file externally from ctb Edit dialog

Post by kiwichick »

LittleBiG wrote: 09 Aug 2022 07:58 If you don't want to sacrifice anything, use this kind of structure. Click runs the script, Ctrl+Click opens it.

Code: Select all

//leftscript
 $ctrl_pressed = get("shift") == 2;
   if ($ctrl_pressed) {
     open "<xyscripts>\MyScript.xys";
   }
   else {
     load "MyScript.xys";
   }
Oh my god, that is absolutely brilliant!!!!! I would never ever have thought of that. Thank you so much :appl: :appl: :appl: :appl: :appl: :appl: :appl: :appl:
Windows 10 Pro 22H2

Post Reply