working Code
Code: Select all
m := Menu()
mainmenu := Menu()
submenu1 := Menu()
submenu2 := Menu()
submenu3 := Menu()
m.Add("mainmenu", mainmenu)
mainmenu.Add("What is the Queston 1", submenu1)
submenu1.Add("The answer can be anything -it --rm -ssh --especially blah <> --image", MenuHandler)
mainmenu.Add("can you type this", submenu2)
submenu2.Add("yes i can type 'anything' you want me to", MenuHandler)
submenu2.Add("i can also write anything that is gibberish", MenuHandler)
mainmenu.Add("Good Morning", submenu3)
submenu3.Add("morning is ok -- with so many ideans like , :' and also anything ", MenuHandler)
submenu3.Add("very good morining", MenuHandler)
submenu3.Add("Thank you", MenuHandler)
MenuHandler(Item, *){
A_Clipboard := Item
Send('^v')
}
#n::m.Show() ; i.e. press the Win-Z hotkey to show the menu.
here is the json structure
{
"Mainmenu1": {
"What is the Queston 1": [
"The answer can be anything -it --rm aks-ssh --especially blah <> --image"
],
"can you type this": [
"yes i can type \"anything\" you want me to",
"i can also write anything that is gibberish"
],
"Good Morning": [
"very good morning",
"morning is ok -- with so many ideas like , :' and also anything ",
"Thank you"
]
},
"Mainmenu2": {
"Random Query": [
"Some random command -it --rm --image=randomimage:latest"
],
"Lorem Ipsum": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit",
"Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"
],
"Gibberish Text": [
"Flibber flabber blibber blabber",
"Blah blah blah -- with symbols like @#$%&*()!",
"Thank you for using gibberish"
]
}
}
Non working code, Some thing like below
Code: Select all
; Read the JSON file
jsonContent := FileRead("C:\key\myjson.txt")
; Parse the JSON content
json := JSON.Load(jsonContent)
; Create the main menu
m := Menu()
; Loop through each main menu item in the JSON
for mainMenuKey, mainMenuValue in json
{
; Create a new submenu
subMenu := Menu()
; Loop through each submenu item
for subMenuKey, subMenuValue in mainMenuValue
{
; Add the submenu items
for index, item in subMenuValue
{
subMenu.Add(item, "MenuHandler")
}
}
; Add the main menu items
m.Add(mainMenuKey, subMenu)
}
; Define the menu handler
MenuHandler(Item, *)
{
A_Clipboard := Item
Send('^v')
}
; Hotkey to show the menu
#n::m.Show() ; i.e. press the Win-N hotkey to show the menu.