Expression too long
Posted: 21 Jun 2021, 13:38
Hallo, bei meinem Stöberfund https://www.autohotkey.com/boards/viewtopic.php?f=76&t=62441#p403267 komme ich an Grenzen, ich habe nach Array Manier versucht das oMenu aufzuteilen, aber irgendwie bekomme ich die Klammern nicht hin.
Kann ich das oMenu auch einzeln 'anlegen'?
irgendwie ich hab Ladehemmung, dachte eigentlich das geht so?!
In beiden Versionen bin ich fast an der Expression too long Grenze.
Kann ich das oMenu auch einzeln 'anlegen'?
Code: Select all
oMenu := {Main:[ {name: "Item1", icon: "Shell32,45", L: RunCalc}]}
oMenu .= {Main:[ {name: "Item2", icon: "Shell32,45", L: RunCalc}]}
In beiden Versionen bin ich fast an der Expression too long Grenze.
Code: Select all
;DefaultGuiMenu.ahk
oMenu := {MyMenuBar: [ {text: "&File", label: {FileMenu: [ {text: "sbahn &nippes", icon: "", label: "nippes"}
, {text: "&a2", icon: "", label: "LABEL2"}
, {} ; separator
, {text: "&c3", icon: "", label: "LABEL3"}
, {text: "&d4", icon: "", label: "LABEL4"}
, {text: "&e5", icon: "", label: "LABEL5"}
, {text: "&f6", icon: "", label: "LABEL6"}
, {text: "&g7", icon: "", label: "LABEL7"}
, {text: "&h8", icon: "", label: "LABEL8"}
, {text: "&i9", icon: "", label: "LABEL9"}
, {text: "&j10", icon: "", label: "LABEL10"} ]}}
, {text: "&MenuA", label: {MenuMenuA: [ {text: "&aLABEL1", icon: "", label: "LABEL1"}
, {text: "&bLABEL2", icon: "", label: "LABEL2"}
, {text: "&cLABEL3", icon: "", label: "LABEL3"} ]}}
, {text: "&MenuB", label: {MenuMenuB: [ {text: "&bLABEL1", icon: "", label: "LABEL1"}
, {text: "&cLABEL2", icon: "", label: "LABEL2"}
, {text: "&dLABEL3", icon: "", label: "LABEL3"} ]}}
, {text: "&MenuC", label: {MenuMenuC: [ {text: "&cLABEL1", icon: "", label: "LABEL1"}
, {text: "&dLABEL2", icon: "", label: "LABEL2"}
, {text: "&eLABEL3", icon: "", label: "LABEL3"} ]}}
, {text: "&MenuD", label: {MenuMenuD: [ {text: "&dLABEL1", icon: "", label: "LABEL1"}
, {text: "&eLABEL2", icon: "", label: "LABEL2"}
, {text: "&fLABEL3", icon: "", label: "LABEL3"} ]}}
, {text: "&MenuE", label: {MenuMenuwE: [ {text: "&eLABEL1", icon: "", label: "LABEL1"}
, {text: "&fLABEL2", icon: "", label: "LABEL2"}
, {} ; separator
, {text: "&gLABEL3", icon: "", label: "LABEL3"} ]}} ]}
Gui, +Resize ; Make the window resizable.
Gui, Menu, % CreateMenu(oMenu)
Gui, Add, Text, vTextSpace WantTab W600 R20, %strGlobalWelcomeText%
Gui, Show,, Untitled
Return
GuiClose:
ExitApp
nippes() {
;Nippes := Func("Run").Bind("V:\__ahk projekte aktuell\InternetMovieDatenbank Parts\Array2ListView - Nippes.ahk")
run, V:\__ahk projekte aktuell\InternetMovieDatenbank Parts\Array2ListView - Nippes.ahk
; MsgBox,,, % "This Menu: " . A_ThisMenu . "`nMenu Item: " . A_ThisMenuItem,1
}
LABEL1() {
MsgBox,,, % "This Menu: " . A_ThisMenu . "`nMenu Item: " . A_ThisMenuItem,1
}
LABEL2() {
MsgBox,,, % "This Menu: " . A_ThisMenu . "`nMenu Item: " . A_ThisMenuItem,1
}
LABEL3() {
MsgBox,,, % "This Menu: " . A_ThisMenu . "`nMenu Item: " . A_ThisMenuItem,1
}
LABEL4() {
MsgBox,,, % "This Menu: " . A_ThisMenu . "`nMenu Item: " . A_ThisMenuItem,1
}
LABEL5() {
MsgBox,,, % "This Menu: " . A_ThisMenu . "`nMenu Item: " . A_ThisMenuItem,1
}
LABEL6() {
MsgBox,,, % "This Menu: " . A_ThisMenu . "`nMenu Item: " . A_ThisMenuItem,1
}
LABEL7() {
MsgBox,,, % "This Menu: " . A_ThisMenu . "`nMenu Item: " . A_ThisMenuItem,1
}
LABEL8() {
MsgBox,,, % "This Menu: " . A_ThisMenu . "`nMenu Item: " . A_ThisMenuItem,1
}
LABEL9() {
MsgBox,,, % "This Menu: " . A_ThisMenu . "`nMenu Item: " . A_ThisMenuItem,1
}
LABEL10() {
MsgBox,,, % "This Menu: " . A_ThisMenu . "`nMenu Item: " . A_ThisMenuItem,1
}
Run(Target) {
Run, % Target
return
}
CreateMenu(oMenu) {
for k, v in oMenu {
for i, v in v {
if !IsObject(v.label)
Menu, % k, Add, % v.text, % v.label
else
Menu, % k, Add, % v.text, % ":" CreateMenu(v.label)
if v.icon {
RegExMatch(v.icon, "(?<file>[^,]+)(,(?<num>.+))?", _)
Menu, % k, Icon, % v.text, % _file, % _num
}
}
}
Return k
}
Code: Select all
s11 := "Shell32,11"
s12 := "Shell32,12"
s13 := "Shell32,13"
s14 := "Shell32,14"
s15 := "Shell32,15"
s16 := "Shell32,16"
s17 := "Shell32,17"
s18 := "Shell32,18"
s19 := "Shell32,19"
s20 := "Shell32,20"
s21 := "Shell32,21"
s22 := "Shell32,22"
s23 := "Shell32,23"
s24 := "Shell32,24"
s25 := "Shell32,25"
s26 := "Shell32,26"
s27 := "Shell32,27"
s28 := "Shell32,28"
s29 := "Shell32,29"
s30 := "Shell32,30"
s31 := "Shell32,31"
s32 := "Shell32,32"
s33 := "Shell32,33"
s34 := "Shell32,34"
s35 := "Shell32,35"
s36 := "Shell32,36"
s37 := "Shell32,37"
s38 := "Shell32,38"
s39 := "Shell32,39"
s40 := "Shell32,40"
s41 := "Shell32,41"
s42 := "Shell32,42"
s43 := "Shell32,43"
s44 := "Shell32,44"
s45 := "Shell32,45"
s46 := "Shell32,46"
s47 := "Shell32,47"
s48 := "Shell32,48"
s49 := "Shell32,49"
RunCalc := Func("Run").Bind("calc.exe")
prog1 := Func("Run").Bind("calc.exe")
oMenu := {Main:[ {name: "Item23", icon: s23, L: RunCalc}
, {name: "Item24", icon: s24, L: "MenuHandler1"}
, {name: "Item25", icon: s25, L: prog1}
, {name: "Item26", icon: s26, L: prog1}
, {name: "Item27", icon: s27, L: prog1}
, {name: "Item28", icon: s28, L: prog1}
, {name: "Item29", icon: s29, L: prog1}
, {name: "Item30", icon: s30, L: prog1}
, {name: "Item31", icon: s31, L: prog1}
, {name: "Item32", icon: s32, L: prog1}
, {name: "Item33", icon: s33, L: prog1}
, {name: "Item34", icon: s34, L: prog1}
, {name: "Item35", icon: s35, L: prog1}
, {name: "Item36", icon: s36, L: prog1}
, {name: "Item37", icon: s37, L: prog1}
, {name: "Item38", icon: s36, L: prog1}
, {name: "Item39", icon: s39, L: prog1}
, {name: "Item40", icon: s40, L: prog1}
, {name: "Item41", icon: s41, L: prog1}
, {name: "Item42", icon: s42, L: prog1}
, {name: "Item43", icon: s43, L: prog1}
, {}
, {name: "Item22", icon: "Shell32,47", L: {SubMenu:[ {name: "Item1", icon: s48, L: RunCalc}
, {name: "Item11", icon: s11, L: "MenuHandler2"}
, {name: "Item12", icon: s12, L: "MenuHandler2"}
, {name: "Item13", icon: s13, L: "MenuHandler2"}
, {name: "Item14", icon: s14, L: "MenuHandler2"}
, {name: "Item15", icon: s15, L: "MenuHandler2"}
, {name: "Item16", icon: s16, L: "MenuHandler2"}
, {name: "Item17", icon: s17, L: "MenuHandler2"}
, {name: "Item18", icon: s18, L: "MenuHandler2"}
, {name: "Item19", icon: s19, L: "MenuHandler2"}
, {name: "Item20", icon: s20, L: "MenuHandler2"}
, {name: "Item21", icon: s21, L: "MenuHandler2"}
, {name: "Item22", icon: s22, L: "MenuHandler2"} ]}} ]}
menuName := CreateMenu(oMenu)
Menu,%menuName%, Show
Return
CreateMenu(oMenu) {
for k, v in oMenu {
for i, v in v {
if v.hidden
continue
if !IsObject(v.L)
Menu, % k, Add, % v.name, % v.L
else if (v.L.Count() = "") {
handler := v.L
Menu, % k, Add, % v.name, % handler
}
else
Menu, % k, Add, % v.name, % ":" CreateMenu(v.L)
if v.disabled
Menu, % k, Disable, % v.name
if v.icon {
RegExMatch(v.icon, "(?<file>[^,]+)(,(?<num>.+))?", _)
Menu, % k, Icon, % v.name, % _file, % _num
}
}
}
Return k
}
MenuHandler1() {
MsgBox, % "This Menu: " . A_ThisMenu . "`nMenu Item: " . A_ThisMenuItem
}
MenuHandler2() {
MsgBox, % "This Menu: " . A_ThisMenu . "`nMenu Item: " . A_ThisMenuItem
}
Run(Target) {
Run, % Target
}