Interactive Menu and SubMenu

Ask gaming related questions (AHK v1.1 and older)
Shifted_Right
Posts: 1
Joined: 15 Mar 2024, 05:16

Interactive Menu and SubMenu

15 Mar 2024, 05:21

Greetings, i have created this menu and it showcase the submenu within my issue is, when i select the submenu option for example submenu 1.3 it send the A_ThisMenuItemPos =1 result back. I am new to scripting so please do help in making this more efficient or how can i call the correct submenu option

Code: Select all

SetKeyDelay, 500
; Create the popup menu by adding some items to it.

; Create another menu destined to become a submenu of the above menu.
Menu, Submenu1, Add, City Locations, MenuHandler
Menu, Submenu1, Add, Paleto Locations, MenuHandler
Menu, Submenu1.1, Add, City bank, MenuHandler
Menu, Submenu1.1, Add, Diamond Casino, MenuHandler
Menu, Submenu1.1, Add, Pharmacy, MenuHandler
Menu, Submenu1.1, Add, High End, MenuHandler
Menu, Submenu1.1, Add, Low End, MenuHandler
Menu, Submenu1.1, Add, Burger Shot, MenuHandler
Menu, Submenu1.1, Add, Impound, MenuHandler
Menu, Submenu1.1, Add, Mors Insurance, MenuHandler
Menu, Submenu1.1, Add, DMV, MenuHandler
Menu, Submenu1.1, Add, City Police, MenuHandler
Menu, Submenu1.1, Add, City Parking, MenuHandler
Menu, Submenu1.1, Add, Goverment, MenuHandler
Menu, Submenu1.1, Add, LSC, MenuHandler
Menu, Submenu1.1, Add, Credit Store, MenuHandler
Menu, Submenu1.1, Add, DCC, MenuHandler
Menu, Submenu1.2, Add, Bayview Auto center, MenuHandler
Menu, Submenu1.2, Add, Paleto High End, MenuHandler
Menu, Submenu1.2, Add, Sherif Department, MenuHandler
Menu, Submenu1.2, Add, Mors Insurance, MenuHandler
Menu, Submenu1.2, Add, Impound, MenuHandler
Menu, Submenu1.2, Add, DOC, MenuHandler
Menu, Submenu1.3, Add, Eclipse Tower - 5, MenuHandler
Menu, Submenu1.3, Add, Apartment - 6, MenuHandler
Menu, Submenu1.3, Add, Apartment - 7, MenuHandler
Menu, Submenu1.3, Add, Apartment - 8, MenuHandler
Menu, Submenu1.3, Add, Apartment - 4, MenuHandler
Menu, Submenu1.3, Add, Apartment - 3, MenuHandler
Menu, Submenu1.3, Add, Apartment - 2, MenuHandler
Menu, Submenu1.3, Add, Apartment - 1, MenuHandler


; Create a submenu in the first menu (a right-arrow indicator). When the user selects it, the second menu is displayed.
Menu, MyMenu, Add, Locations, :Submenu1
Menu, Submenu1, Add, City Locations, :Submenu1.1
Menu, Submenu1, Add, Paleto Locations, :Submenu1.2
Menu, Submenu1.1, Add, Apartment Complex, :Submenu1.3
Menu, SubMenu1.1, Icon, Apartment Complex, apartment.png,1,50
Menu, MyMenu, Icon, Locations, Filename.png,1,50
Menu, Submenu1, Icon, City Locations, City.png,1,50
Menu, Submenu1, Icon, Paleto Locations, urban.png,1,50
Menu, Submenu1.1, Icon, City bank, bank.png,1,50
Menu, Submenu1.1, Icon, Diamond Casino, casino.png,1,50
Menu, Submenu1.1, Icon, Pharmacy, pills.png,1,50
Menu, Submenu1.1, Icon, High End, sports.png,1,50
Menu, Submenu1.1, Icon, Low End, old.png,1,50
Menu, Submenu1.1, Icon, Burger Shot, burger.png,1,50
Menu, Submenu1.1, Icon, Impound, cimpound.png,1,50
Menu, Submenu1.1, Icon, Mors Insurance, cmors.png,1,50
Menu, Submenu1.1, Icon, DMV, dmv.png,1,50
Menu, Submenu1.1, Icon, City Police, police.png,1,50
Menu, Submenu1.1, Icon, City Parking, parking.png,1,50
Menu, Submenu1.1, Icon, Goverment, gov.png,1,50
Menu, Submenu1.1, Icon, LSC, lsc.png,1,50
Menu, Submenu1.1, Icon, Credit Store, bitcoin.png,1,50
Menu, Submenu1.1, Icon, DCC, office.png,1,50
Menu, Submenu1.3, Icon, Eclipse Tower - 5, eclipse.png,1,50
Menu, Submenu1.3, Icon, Apartment - 1, apt1.png,1,50
Menu, Submenu1.3, Icon, Apartment - 2, apt2.png,1,50
Menu, Submenu1.3, Icon, Apartment - 3, apt3.png,1,50
Menu, Submenu1.3, Icon, Apartment - 4, apt4.png,1,50
Menu, Submenu1.3, Icon, Apartment - 6, apt6.png,1,50
Menu, Submenu1.3, Icon, Apartment - 7, apt7.png,1,50
Menu, Submenu1.3, Icon, Apartment - 8, apt8.png,1,50

return  ; End of script's auto-execute section.

MenuHandler:
if (A_ThisMenuItemPos =1)
{
SendInput t
sleep 50
SendInput /setgps 5 vinewood blvd{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
} else if (A_ThisMenuItemPos =2) {
SendInput t
sleep 50
SendInput /setgps 2 mirror park blvd{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
} else if (A_ThisMenuItemPos =3) {
SendInput t
sleep 50
SendInput /setgps 16 strawberry ave{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
} else if (A_ThisMenuItemPos =4) {
SendInput t
sleep 50
SendInput /setgps 9 red desert ave{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
} else if (A_ThisMenuItemPos =5) {
SendInput t
sleep 50
SendInput /setgps 1 new empire way{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
} else if (A_ThisMenuItemPos =6) {
SendInput t
sleep 50
SendInput /setgps 13 san andreas ave{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
} else if (A_ThisMenuItemPos =7) {
SendInput t
sleep 50
SendInput /setgps 17 power st{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
} else if (A_ThisMenuItemPos =8) {
SendInput t
sleep 50
SendInput /setgps 17 power st{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
} else if (A_ThisMenuItemPos =9) {
SendInput t
sleep 50
SendInput /setgps 17 power st{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
} else if (A_ThisMenuItemPos =10) {
SendInput t
sleep 50
SendInput /setgps 1 atlee st{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
} else if (A_ThisMenuItemPos =11) {
SendInput t
sleep 50
SendInput /setgps 5 elgin ave{enter}
} else if (A_ThisMenuItemPos =12) {
SendInput t
sleep 50
SendInput /setgps 20 eastbourne way{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
} else if (A_ThisMenuItemPos =13) {
SendInput t
sleep 50
SendInput /setgps 1 carcer way{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
} else if (A_ThisMenuItemPos =14) {
SendInput t
sleep 50
SendInput /setgps 1 buccaneer way{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
} else if (A_ThisMenuItemPos =15) {
SendInput t
sleep 50
SendInput /setgps 2 mirror park blvd{enter}
sleep 500
SendInput t
sleep 50
SendInput /me updated the gps location{enter}
}
return

#z::Menu, MyMenu, Show  ; i.e. press the Win-Z hotkey to show the menu.

[Mod edit: Fixed the Codebox tags. They go around the code, not before it.]

[Mod action: Moved topic to the v1 section since this is v1 code. The main section is for v2.]

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 112 guests