Add sub-menu support for scripts

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

Re: Add sub-menu support for scripts

Post 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...)

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

Re: Add sub-menu support for scripts

Post 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.

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Add sub-menu support for scripts

Post by yusef88 »

speaking of sub-menu, could it be in native buttons?
Attachments
Shot 1.png
Shot 1.png (9.89 KiB) Viewed 3156 times

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

Re: Add sub-menu support for scripts

Post by admin »

Not really.

... sleep :ghost: sleep ...

Hmm, maybe yes...

... try :maf: try ...

No, not possible.

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

Re: Add sub-menu support for scripts

Post 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>

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Add sub-menu support for scripts

Post 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...
One of my scripts helped you out? Please donate via Paypal

zhaowu
Posts: 30
Joined: 24 Oct 2016 16:03

Re: Add sub-menu support for scripts

Post by zhaowu »

v17.30.0001 - 2016-11-02 11:29
+++ Scripting: Now Multi-Scripts support nesting.
Thanks for the update! :tup:

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"

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

Re: Add sub-menu support for scripts

Post by admin »

Variations, Additions, Complications later... :)

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: Add sub-menu support for scripts

Post 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. :tup: :appl:
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.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

FluxTorpedoe
Posts: 855
Joined: 05 Oct 2011 13:15

Re: Add sub-menu support for scripts

Post 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. :appl:

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);

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: Add sub-menu support for scripts

Post by klownboy »

That's interesting Flux. :appl: 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.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

zhaowu
Posts: 30
Joined: 24 Oct 2016 16:03

Re: Add sub-menu support for scripts

Post 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.

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

Re: Add sub-menu support for scripts

Post 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.

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Add sub-menu support for scripts

Post 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);
Attachments
Shot 1.png
Shot 1.png (2.8 KiB) Viewed 3026 times

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Add sub-menu support for scripts

Post 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
One of my scripts helped you out? Please donate via Paypal

Post Reply