Rawox Posted September 21, 2010 Share Posted September 21, 2010 Hi, So I'm trying to create a contextmenu... Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Switch $iwParam Case $idPlay Run ( $Path & "\System\UT2004.exe" ) Case Else Exit EndSwitch EndFunc ;==>WM_COMMAND Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam) Local $hMenu $hMenu = _GUICtrlMenu_CreatePopup ( 9 ) _GUICtrlMenu_InsertMenuItem ( $hMenu, 0, "Close", $idClose ) _GUICtrlMenu_InsertMenuItem ( $hMenu, 0, "", 0 ) _GUICtrlMenu_InsertMenuItem ( $hMenu, 0, "Join Server", $mJoin ) _GUICtrlMenu_InsertMenuItem ( $mJoin, 0, "WOH RPGInvasion", $idWOH ) _GUICtrlMenu_InsertMenuItem ( $hMenu, 0, "Play Unreal Tournament 2004", $idPlay ) _GUICtrlMenu_TrackPopupMenu ( $hMenu, $iwParam ) _GUICtrlMenu_DestroyMenu ( $hMenu ) Return True EndFunc ;==>WM_CONTEXTMENU but I can't figure out how to create submenu's. The $idWOH should be under (submenu) $mJoin... How to do this? Thanks in advance, Rawox Link to comment Share on other sites More sharing options...
Fire Posted September 21, 2010 Share Posted September 21, 2010 (edited) Hi. If i understand correctly you want to get something like this? Try it: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 564, 282, 382, 239) $Button1 = GUICtrlCreateButton("RIGHT MENU ", 216, 112, 129, 57, $WS_GROUP) $hmenu=GUICtrlCreateContextMenu($Button1) $item=GUICtrlCreateMenu("submenutext",$hmenu) $hexit=GUICtrlCreateMenuItem("Exit",$hmenu) $itemofotem=GUICtrlCreateMenuItem("AAAAAAA",$item) $seconditemofsubmenu=GUICtrlCreateMenuItem("Second Submenu",$itemofotem) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd May be like this? #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 564, 282, 382, 239) $Button1 = GUICtrlCreateButton("RIGHT MENU ", 216, 112, 129, 57, $WS_GROUP) $hmenu=GUICtrlCreateContextMenu($Button1) $item=GUICtrlCreateMenu("submenutext",$hmenu) $hexit=GUICtrlCreateMenuItem("Exit",$hmenu) $itemofotem=GUICtrlCreateMenuItem("AAAAAAA",$item) $seconditemofsubmenu=GUICtrlCreateMenu("Second Submenu",$item) $itemofsubmenu2=GUICtrlCreateMenuItem("BBBBBBB",$seconditemofsubmenu) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited September 21, 2010 by Fire [size="5"] [/size] Link to comment Share on other sites More sharing options...
Rawox Posted September 21, 2010 Author Share Posted September 21, 2010 (edited) You do understand me, but the problem is that I need to use the _GUICtrlMenu functions because I can't show it any other way because the script consists of just this single contextmenu... So I need this to be done using those functions Edited September 21, 2010 by Rawox Link to comment Share on other sites More sharing options...
Fire Posted September 21, 2010 Share Posted September 21, 2010 (edited) Hm. I`m sorry dude.Really i have no experience with _GUICTRLmenu* functions but i think you need _GUICtrlMenu_AppendMenu() function for create submenu for $mJoin. Check it out may be you can solve it using _GUICtrlMenu_AppendMenu(). I'm sorry Really again.I have no experience with _GUICTRLmenu* functions. Edited September 21, 2010 by Fire [size="5"] [/size] Link to comment Share on other sites More sharing options...
Rawox Posted September 22, 2010 Author Share Posted September 22, 2010 No problem. I'll take a look Link to comment Share on other sites More sharing options...
Rawox Posted September 22, 2010 Author Share Posted September 22, 2010 I'm afraid I have to say that the _GUICtrlMenu_AppendMenu has nothing to do with creating submenu's. Any other ideas? Link to comment Share on other sites More sharing options...
Mat Posted September 22, 2010 Share Posted September 22, 2010 I just wrote you a nice reply and then IE crashed (I tried to create two tabs at the same time). Theres a reason I use chrome at home. Anyway. The key is to think backwards. Make the sub menu, then use it as the last parameter in AddMenuItem SubMenu = _GUICtrlMenu_CreateMenu MainMenu = _GUICtrlMenu_CreatePopup _GUICtrlMenu_AddMenuItem(MainMenu, Text, Id, SubMenu) Or look at loading menus from resources. That makes it very easy to edit menus and use them, and it's a pity AutoIt doesn't do more to support resources natively. sample MENU { MENUITEM "&Soup", 100 MENUITEM "S&alad", 101 POPUP "&Entree" { MENUITEM "&Fish", 200 MENUITEM "&Chicken", 201, CHECKED POPUP "&Beef" { MENUITEM "&Steak", 301 MENUITEM "&Prime Rib", 302 } } MENUITEM "&Dessert", 103 } Thats a lot easier to visualize, and the code will be simpler too: $hMenu = LoadMenu(GetModuleHandle(0), "sample") Done Sorry about writing everything in pseudo code, I don't have AutoIt on this machine... Mat SupaNewb 1 AutoIt Project Listing Link to comment Share on other sites More sharing options...
Rawox Posted September 22, 2010 Author Share Posted September 22, 2010 Haha, thank you math I already found another way to manage this. I create a really tiny gui and let autoit rightclick on it while it shows and hide it right away (also the transparancy is @ 1/255) so it won't be visible. Thanks anyway! Rawox Link to comment Share on other sites More sharing options...
Mat Posted September 22, 2010 Share Posted September 22, 2010 You do know that you can call TrackPopupMenu on an internal AutoIt menu?? GUICtrlGetHandle Now you should have explained that you wanted to have sub menu's on a popup menu and then I could have helped you straight away. Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
Rawox Posted September 22, 2010 Author Share Posted September 22, 2010 Mat, thanks to your wonderful idea I've changed it al GUICtrlGetHandle was an excellent idea! Link to comment Share on other sites More sharing options...
Mat Posted September 22, 2010 Share Posted September 22, 2010 Mat, thanks to your wonderful idea I've changed it al GUICtrlGetHandle was an excellent idea!There's always a right way to do it. You've got to learn to not accept what you know is a dodgy workaround, instead you should persevere to find the proper solution. I wish there was a neat philosophical quote explaining that theory. It would definitely go in the sig. AutoIt Project Listing Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now