TheAutomator Posted October 7, 2014 Share Posted October 7, 2014 (edited) Hello How does Autoit detect when you click on a menu button? (not a sub-menu item, but the actual menu button itself) $Form = GUICreate("", 410, 270) $Menu_Help = GUICtrlCreateMenu("Help") GUISetState(@SW_SHOW) while true Switch GUIGetMsg() Case $Menu_Help msgbox(0,1,2) EndSwitch wend Thanks in advance TheAutomator [EDIT:] Should this be in the gui section? Edited October 7, 2014 by TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
LarsJ Posted October 8, 2014 Share Posted October 8, 2014 WM_ENTERMENULOOP: #include <WindowsConstants.au3> $Form = GUICreate("", 410, 270) $Menu_Help = GUICtrlCreateMenu("Help") GUISetState(@SW_SHOW) GUIRegisterMsg( $WM_ENTERMENULOOP, "WM_ENTERMENULOOP" ) while true Switch GUIGetMsg() Case $Menu_Help msgbox(0,1,2) Case -3 Exit EndSwitch wend Func WM_ENTERMENULOOP( $hWnd, $iMsg, $iwParam, $ilParam ) msgbox(0,1,"WM_ENTERMENULOOP") EndFunc Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
TheAutomator Posted October 8, 2014 Author Share Posted October 8, 2014 (edited) WM_ENTERMENULOOP: #include <WindowsConstants.au3> $Form = GUICreate("", 410, 270) $Menu_Help = GUICtrlCreateMenu("Help") GUISetState(@SW_SHOW) GUIRegisterMsg( $WM_ENTERMENULOOP, "WM_ENTERMENULOOP" ) while true Switch GUIGetMsg() Case $Menu_Help msgbox(0,1,2) Case -3 Exit EndSwitch wend Func WM_ENTERMENULOOP( $hWnd, $iMsg, $iwParam, $ilParam ) msgbox(0,1,"WM_ENTERMENULOOP") EndFunc how do i know which item is clicked on if i have 2 menu heather's? also just clicking on the menu bar gives the message... TheAutomator Edited October 8, 2014 by TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
MikahS Posted October 8, 2014 Share Posted October 8, 2014 (edited) how do i know which item is clicked on if i have 2 menu heather's? also just clicking on the menu bar gives the message... TheAutomator Func WM_ENTERMENULOOP( $hWnd, $iMsg, $iwParam, $ilParam ) Local $gFocus = ControlGetFocus('[ACTIVE]') ; get the focus of the menu you are selecting MsgBox(0, "", $gFocus) ; tell us EndFunc Edited October 8, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
TheAutomator Posted October 8, 2014 Author Share Posted October 8, 2014 Func WM_ENTERMENULOOP( $hWnd, $iMsg, $iwParam, $ilParam ) Local $gFocus = ControlGetFocus('[ACTIVE]') ; get the focus of the menu you are selecting MsgBox(0, "", $gFocus) ; tell us EndFunc did you test the script? because the msgbox is just empty and also it still gives a pop-up when you click on the menu bar.. TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
MikahS Posted October 8, 2014 Share Posted October 8, 2014 (edited) did you test the script? because the msgbox is just empty and also it still gives a pop-up when you click on the menu bar.. TheAutomator Nope, just thought I would throw something out there. Yes, what it is doing is their is not control focused when you click on a menu item because it will instantly take away focus, should have thought of that.. But, maybe.. Local $hts = _HexToString($lparam) MsgBox(0, "", $hts) ;untested Edited October 8, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
TheAutomator Posted October 8, 2014 Author Share Posted October 8, 2014 Nope, just thought I would throw something out there. Yes, what it is doing is their is not control focused when you click on a menu item because it will instantly take away focus, should have thought of that.. But, maybe.. Local $hts = _HexToString($lparam) Local $stascii = StringToASCIIArray($hts) Local $t = _ArrayToString($stascii) MsgBox(0, "", $t) ;untested nope Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
MikahS Posted October 8, 2014 Share Posted October 8, 2014 (edited) I edited my post, give that one a try as well. You don't need to make it ASCII. Edited October 8, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
TheAutomator Posted October 8, 2014 Author Share Posted October 8, 2014 I edited my post, give that one a try as well. You don't need to make it ASCII. Still not working... Thanks for the effort but I think its not the right way to do this, I swear I saw an answer on this forum for that exact problem a LONG time ago but I can't find it anymore think it was answered by Melba23 ... Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
MikahS Posted October 8, 2014 Share Posted October 8, 2014 Still not working... Thanks for the effort but I think its not the right way to do this, I swear I saw an answer on this forum for that exact problem a LONG time ago but I can't find it anymore think it was answered by Melba23 ... Seems to me like it is time for a wild goose chase Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
TheAutomator Posted October 8, 2014 Author Share Posted October 8, 2014 Seems to me like it is time for a wild goose chase Haha, I guess so Thanks for the help already btw Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
MikahS Posted October 8, 2014 Share Posted October 8, 2014 Haha, I guess so Thanks for the help already btw My pleasure I will help on the goose chase but I must get going, Later tonight I will search more Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted October 8, 2014 Moderators Solution Share Posted October 8, 2014 TheAutomator, think it was answered by Melba23Someone called? Perhaps you mean >this post? But beware you need at least 1 valid menu entry first. I posted >this other solution a long time ago, but I would recommend the above. 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...
MikahS Posted October 8, 2014 Share Posted October 8, 2014 TheAutomator, Someone called? Perhaps you mean >this post? But beware you need at least 1 valid menu entry first. I posted >this other solution a long time ago, but I would recommend the above. M23 Dang, you're fast Could it be a blank menu item such as a line made with ""? Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 8, 2014 Moderators Share Posted October 8, 2014 MikahS,Dang, you're fast I aim to please! M23 MikahS 1 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...
TheAutomator Posted October 8, 2014 Author Share Posted October 8, 2014 (edited) MikahS, I aim to please! M23 Sometimes I doubt if you are human Melba23, You never sleep and your everywhere on this forum Thanks for solving my problem Edited October 8, 2014 by TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 8, 2014 Moderators Share Posted October 8, 2014 TheAutomator,Only too human, alas. M23 TheAutomator 1 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...
LarsJ Posted October 8, 2014 Share Posted October 8, 2014 WM_ENTERMENULOOPYou can do something like this. But menus without menu items are not proper menus. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> $Form = GUICreate("", 410, 270) $Menu_File1 = GUICtrlCreateMenu("File1") $Menu_File2 = GUICtrlCreateMenu("File2",-1) $Menu_File3 = GUICtrlCreateMenu("File3",-1) GUISetState(@SW_SHOW) GUIRegisterMsg( $WM_ENTERMENULOOP, "WM_ENTERMENULOOP" ) while true Switch GUIGetMsg() Case -3 ExitLoop EndSwitch wend Func WM_ENTERMENULOOP( $hWnd, $iMsg, $iwParam, $ilParam ) Local $x = GUIGetCursorInfo()[0] Local $i = Int( $x / ( 112 / 3 ) ) Switch $i Case 0 MsgBox( 0, "", "File1" ) Case 1 MsgBox( 0, "", "File2" ) Case 2 MsgBox( 0, "", "File3" ) Case Else MsgBox( 0, "", "No menu" ) EndSwitch Return $GUI_RUNDEFMSG EndFunc Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
TheAutomator Posted October 8, 2014 Author Share Posted October 8, 2014 (edited) WM_ENTERMENULOOP You can do something like this. But menus without menu items are not proper menus. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> $Form = GUICreate("", 410, 270) $Menu_File1 = GUICtrlCreateMenu("File1") $Menu_File2 = GUICtrlCreateMenu("File2",-1) $Menu_File3 = GUICtrlCreateMenu("File3",-1) GUISetState(@SW_SHOW) GUIRegisterMsg( $WM_ENTERMENULOOP, "WM_ENTERMENULOOP" ) while true Switch GUIGetMsg() Case -3 ExitLoop EndSwitch wend Func WM_ENTERMENULOOP( $hWnd, $iMsg, $iwParam, $ilParam ) Local $x = GUIGetCursorInfo()[0] Local $i = Int( $x / ( 112 / 3 ) ) Switch $i Case 0 MsgBox( 0, "", "File1" ) Case 1 MsgBox( 0, "", "File2" ) Case 2 MsgBox( 0, "", "File3" ) Case Else MsgBox( 0, "", "No menu" ) EndSwitch Return $GUI_RUNDEFMSG EndFunc Yes that's also an option, thanks TheAutomator Edited October 8, 2014 by TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone 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