Page 4 of 6
Re: Add sub-menu support for scripts
Posted: 01 Nov 2016 16:43
by admin
...especially when there are long complicated run or open statements.
It might be personal coding preferences but I would not pack any long code into the menu generating command. Just return values. Then process acc. to returned values.
(Note to myself: Need to add switch() statement to scripting...)
Re: Add sub-menu support for scripts
Posted: 01 Nov 2016 17:15
by admin
highend wrote:@Don
Should a menu item that is the opener for a submenu not be greyed out like normal items
when it's state is 4? (ocf I'm using "<:>" as the separator for popupnested() here)
Code: Select all
Mp3 Special<:><:><:>4
Filename (Artist - Title.mp3) to ID3 Tag<:>#141;<:><:>4
Filename (Track - Artist - Title.mp3) to ID3 Tag<:>#142;<:><:>4
Filename (Artist - Album - Track - Title.mp3) to ID3 Tag<:>#143;<:><:>4
Filename (Artist - Year - Album - Track - Title.mp3) to ID3 Tag<:>#158;<:><:>4
"MP3 Special" has a black color in this case, not a grey one like it's subitems
Yes, bug. Fix comes.
Re: Add sub-menu support for scripts
Posted: 01 Nov 2016 18:29
by yusef88
speaking of sub-menu, could it be in native buttons?
Re: Add sub-menu support for scripts
Posted: 01 Nov 2016 18:34
by admin
Not really.
... sleep

sleep ...
Hmm, maybe yes...
... try

try ...
No, not possible.
Re: Add sub-menu support for scripts
Posted: 02 Nov 2016 07:14
by admin
klownboy wrote:LittleBiG wrote:Won't something similar be possible later in CTB script?
Code: Select all
"Top"
"Sub1"
"Sub11"
text "11";
"Sub12"
text "12";
"Sub2"
text "2";
"Top2"
text "T2";
The new SC popupnested is great Don, but revamping previously written large menus that use normal XY menu scripting can be quite a task. No problems when coming up with new menus. I have a few menus that I'd be better off starting from scratch (and I don't want to do that) than trying to update to use SC popupnested especially when there are long complicated run or open statements. So I'll second the motion for nested fly-out submenus in the typical XY menus that don't use SC popupmenu/popupnested.
Thanks,
Ken
Actually I got an idea now. Let's see... <rolling up sleeves>
Re: Add sub-menu support for scripts
Posted: 02 Nov 2016 11:53
by highend
! SC popupnested: Parent items were not drawn disabled (grey) when set to
state 4. Fixed. And now, of course, the submenu does not even popup when
hovering such a disabled parent.
Fix confirmed...
Re: Add sub-menu support for scripts
Posted: 02 Nov 2016 12:38
by zhaowu
v17.30.0001 - 2016-11-02 11:29
+++ Scripting: Now Multi-Scripts support nesting.
Thanks for the update!
Wish: load submenu from other script. For example:
Code: Select all
"<load otherscript.xys>|icon|state|LEVEL : label"
This will load "otherscript.xys" and put menus as "LEVEL + 1"
Re: Add sub-menu support for scripts
Posted: 02 Nov 2016 12:45
by admin
Variations, Additions, Complications later...

Re: Add sub-menu support for scripts
Posted: 02 Nov 2016 13:58
by klownboy
admin wrote:Actually I got an idea now. Let's see... <rolling up sleeves>
Your sleeves must have been rolled up pretty far.
I was going nuts initially trying to figure out why nesting in a multiscript menu wasn't working for me. I had, I guess you'd call them nested, heredocs originally to run the submenus with a load statement. As an example...
Code: Select all
perm $mn =<<<FOO
"Ccleaner|<xyicons>\ccleaner02.ico" open "D:\Tools\Ccleaner\Ccleaner.exe";
"Control Panel All Tasks|D:\Graphics\Icons\Starcraft.ico" run "%windir%\explorer.exe shell:::{ED7BA470-8E54-465E-825C-99712043E01C}";
"Device Manager|D:\Graphics\Icons\dock settings.ico" open "C:\Windows\System32\devmgmt.msc";
"-"
"Tools && Utilities|:conf"
$tools = <<<hdc
"Device Manager|<xyicons>\preferences.ico||1" run "explorer shell:::{74246bfc-4c96-11d0-abef-0020af6b0b7a}";
"Disk Management|D:\Graphics\Icons\Settings2.ico||1" open "C:\Windows\System32\diskmgmt.msc";
hdc;
load ("$tools", , s);
FOO;
load "$mn", *, 's';
unset $mn;
Then it dawned on me, what the hell am I doing I don't have to do that anymore. With your new nested multi-level scripts, it's not necessary.
Thanks Don, this is great.
Re: Add sub-menu support for scripts
Posted: 02 Nov 2016 15:02
by FluxTorpedoe
1. +++ Scripting: Now Multi-Scripts support nesting. The level is simply stated by the number denoting its depth, first level is 0 (zero)
Working great! And very fast to implement.
2. One note though, about a slight glitch: looks like an extra separator is added at the end of menus for each "_hidden" entry, e.g.
Code: Select all
"Top"
"Sub|||1"
sub "_routine";
"_routine"
msg 1;
3.
admin wrote:I would not pack any long code into the menu generating command. Just return values. Then process acc. to returned values.(Note to myself: Need to add switch() statement to scripting...)
Interesting and much more readable approach indeed (provided one doesn’t need dynamic menus, but that’s where the new "|||#" comes into play).
To whom it might interest, here’s a streamlined quick proof-of-concept, even without case/switch:
Code: Select all
// ---------------------------------------------> Menu structure
"_Initialize"
$menu = <<<MENU
Top1;;:paper;1
Sub1
Sub2
SubSub1;;*.ini
SubSub2
SubSub3;;;2
Top2;;<xy>
MENU;
sub popupnested($menu);
end 1;
// ---------------------------------------------<
// ---------------------------------------------> Menu content
"Sub1"
msg self("label");
"SubSub1"
msg self("label");
// SubSub2, SubSub3…
"Top2"
msg self("label");
// ---------------------------------------------<
Note: If necessary, it also works well with hidden entries ("_Sub1", "_SubSub1"…), loaded with:
sub "_".popupnested($menu);
Re: Add sub-menu support for scripts
Posted: 02 Nov 2016 15:56
by klownboy
That's interesting Flux.

How did you come up with
"sub popupnested($menu);"? It's funny that without the sub lead-in to popupnested, the menu displays, but of course the actions are not executed. Looks much cleaner that way breaking up the structure from the menu items when using popupnested. Like you said, an alternative to the slightly newer multi-script level nesting.
Re: Add sub-menu support for scripts
Posted: 02 Nov 2016 16:17
by zhaowu
Suggestion: relative level
Code: Select all
"Caption|Icon|State|[+|-]Level : Label" Script
Example:
Code: Select all
/* global menu level for this script */
"C:"
"Go to C:\|||+1"
goto "C:\";
"%winsysdir%|||+1" goto "%winsysdir%";selectitems "calc.exe";
"D:"
"Go to D:\|||+1"
goto "D:\";
With this relative level, it is easy to load submenu from other script.
Re: Add sub-menu support for scripts
Posted: 03 Nov 2016 09:23
by admin
zhaowu wrote:Suggestion: relative level
Code: Select all
"Caption|Icon|State|[+|-]Level : Label" Script
It's a cool idea but I don't think it would work. The popup menu is already completely created in the moment you call the LOAD command. It cannot be dynamically extended on the fly.
Re: Add sub-menu support for scripts
Posted: 03 Nov 2016 18:28
by yusef88
please help me to make this script work
Code: Select all
$menu = <<<MENU
Top1;;<xy>
Go;;:go; goto "%winsysdir%"
Share;;:browsenetwork; perm $user;
if !($user) { $user = input("Win User Name","", "geek"); };
run "nircmd elevate cmd /k pause &net share ""<curfolder>""=""<curpath>"" /GRANT:%username%,FULL /GRANT:$user,Read /REMARK:""By %username%"" &pause &exit"
Top2;;<xy>
MENU;
popupnested($menu);
Re: Add sub-menu support for scripts
Posted: 03 Nov 2016 19:04
by highend
Use a different sep_item like "<:>" instead of ";". Something that isn't used inside your command lines
Your commands are in the wrong place on each line! They belong between the first and the second sep_item!
Execute those commands with load $commands, , 's';
afterwards where $commands is the variable you assigned popupnested() to