LWC Posted November 23, 2010 Share Posted November 23, 2010 (edited) None of GUICtrlSetState's states seem to click menu items. $GUI_DEFBUTTON puts the chosen item in bold but that's it. For example, if I have a menu called "File" (with "Open" and "Save"), I want a method to open the "File" tab. I realize I can use WinMenuSelectItem or use "&File" with Send("!F"). But those are external methods. Is there an internal method for AutoIt's own internal GUIs? Thanks! Edited November 23, 2010 by LWC Link to comment Share on other sites More sharing options...
BrewManNH Posted November 24, 2010 Share Posted November 24, 2010 Why on earth would you want to try to do that with a control you already have full control over? If you want to "click" a menu item on a menu you created, just have your script do whatever that menu item does. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
LWC Posted November 24, 2010 Author Share Posted November 24, 2010 Because I'm updating this menu dynamically based on what you select in the menu itself. Link to comment Share on other sites More sharing options...
BrewManNH Posted November 24, 2010 Share Posted November 24, 2010 Which is completely different from what you asked in your original post. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
LWC Posted November 24, 2010 Author Share Posted November 24, 2010 (edited) You asked me "why on Earth" so I've answered to satisfy you. Can we get back to the original question? I just want the user to see the updated menu after they click the menu item that updates the menu. Edited November 24, 2010 by LWC Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 24, 2010 Moderators Share Posted November 24, 2010 (edited) LWC,As far as I know there is no way to open a menu "internally", but here is one way you might want to use to do what you wantHere is a workaround solution - see below for a programatic method: expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiMenu.au3> $hGUI = GUICreate("Test", 500, 500) $mFilemenu = GUICtrlCreateMenu("File") $mTestitem = GUICtrlCreateMenuItem("Test", $mFilemenu) $mExititem = GUICtrlCreateMenuItem("Exit", $mFilemenu) $mHelpmenu = GUICtrlCreateMenu("?") $mAboutitem = GUICtrlCreateMenuItem("About", $mHelpmenu) GUISetState() $hMenu = _GUICtrlMenu_GetMenu($hGUI) $iCount = _GUICtrlMenu_GetItemCount($hMenu) - 1 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $mExititem Exit Case $mTestitem ReOpenMenu("File") Case $mAboutitem MsgBox(0, "Solved", "That was not too hard!") EndSwitch WEnd Func ReOpenMenu($sText) ; Change the menu item text GUICtrlSetData($mTestitem, "New Title") ; Move through the menu items to match the passed title For $i = 0 To $iCount If $sText = _GUICtrlMenu_GetItemText($hMenu, $i) Then ; Get item location $aItemPos = _GUICtrlMenu_GetItemRect($hGUI, $hMenu, $i) ; Click to open the menu MouseClick("primary", $aItemPos[0] + 10, $aItemPos[1] + 10, 1, 0) EndIf ExitLoop Next EndFuncI hope that helps. M23Edit: Because George insisted - see below. Edited November 26, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
GEOSoft Posted November 24, 2010 Share Posted November 24, 2010 Hey M8 You should change that to MouseClick("primary", $aItemPos[0] + 10, $aItemPos[1] + 10, 1, 0) in case the user is a leftie. M23 - 2 GEO - 15 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 25, 2010 Moderators Share Posted November 25, 2010 George, As usual you are absolutely correct - it must come with advanced age, and of course I am not there quite yet. I have done as you command and amended the post above, O Great (and Aged) One. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jvanegmond Posted November 25, 2010 Share Posted November 25, 2010 (edited) Internally, this uses $WM_MENUSELECT with $MF_MOUSESELECT (0x8000). You need to get the handle with GUICtrlGetHandle and then use GUICtrlSendMessage. No example yet, sorry.Edit: This demonstrates it: Just recreate the message and it send it to your GUI (by handle). Edited November 25, 2010 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 26, 2010 Moderators Share Posted November 26, 2010 LWC, This is how you open a menu programatically (thanks to JamesBrooks for the hint ): expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiMenu.au3> $hGUI = GUICreate("Test", 500, 500) $mFilemenu = GUICtrlCreateMenu("File") $mTestFileitem = GUICtrlCreateMenuItem("Test File", $mFilemenu) $mTestHelpitem = GUICtrlCreateMenuItem("Test Help", $mFilemenu) $mExititem = GUICtrlCreateMenuItem("Exit", $mFilemenu) $mHelpmenu = GUICtrlCreateMenu("Help") $mAboutitem = GUICtrlCreateMenuItem("About", $mHelpmenu) GUISetState() $hMenu = _GUICtrlMenu_GetMenu($hGUI) $iCount = _GUICtrlMenu_GetItemCount($hMenu) - 1 ConsoleWrite("Count: " & $iCount & @CRLF) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $mExititem Exit Case $mTestFileitem _OpenMenu("File") Case $mTestHelpitem _OpenMenu("Help") Case $mAboutitem MsgBox(0, "Solved", "That was a bit harder!") EndSwitch WEnd Func _OpenMenu($sText) ; Sleep to demonstrate the menus close and reopen Sleep(1000) ; Move through the menu items to match the passed title For $i = 0 To $iCount ConsoleWrite("Text: " & _GUICtrlMenu_GetItemText($hMenu, $i) & @CRLF) If $sText = _GUICtrlMenu_GetItemText($hMenu, $i) Then ConsoleWrite($i & @CRLF) ; Get submenu handle $hSubMenu = _GUICtrlMenu_GetItemSubMenu($hMenu, $i) ; Get item location $aItemPos = _GUICtrlMenu_GetItemRect($hGUI, $hMenu, $i) ; Reopen the menu _GUICtrlMenu_TrackPopupMenu($hSubMenu, $hGUI, $aItemPos[0], $aItemPos[3]) ExitLoop EndIf Next EndFunc I hope it does what you want. Manadar, I tried lots of messages but none of them worked even though they matched the ones sent when I clicked on the menu: GUI creation: GUI: 0x0015090A Menu: 0x010308A7 Sending message = _SendMessage($hGUI, $WM_MENUSELECT, 0x80900000, $hMenu): MouseSelect hWnd: 0x0015090A $iMsg: 011F $wParam: 0x80900000 $lParam: 0x010308A7 Popup hWnd: 0x0015090A $iMsg: 011F $wParam: 0x80900000 $lParam: 0x010308A7 Message Sent. Mouse clicked on menu: MouseSelect hWnd: 0x0015090A $iMsg: 011F $wParam: 0x80900000 $lParam: 0x010308A7 Popup hWnd: 0x0015090A $iMsg: 011F $wParam: 0x80900000 $lParam: 0x010308A7 M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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