BrunoStivicevic Posted August 24, 2021 Posted August 24, 2021 Hi all! I've created a GUI menu using $hFile = _GUICtrlMenu_CreateMenu(), $hView = _GUICtrlMenu_CreateMenu() etc and it works fine. But I need a function which would tell me that a specific drop-down menu is actually displayed, and if so, what's its rect. I've searched in help and forum, but to no avail. Apparently there's no function similar to the hypothetic IsDropDownMenuDisplayed($hmenu) that would return true if the menu is expanded, nor I've found how another hypothetic function GetDropDOwnMenuRect that would return x1,y1,x2,y2 or similar. In the attached screen capture, the drop down menu Statistiche is displayed, so IsMenuDisplayed($hStat) would return true, and GetDropDOwnMenuRect would return x1,y1,x2,y2 or similar. Thanks in advance to who knows how to write those functions! Kind regards Bruno
Nine Posted August 24, 2021 Posted August 24, 2021 (edited) You can check if the menu is highlighted. If true then it is displayed, otherwise it will be false. As for the rect, you need to get the first and last item rect... Here an example : #include <GuiMenu.au3> #include <Array.au3> Example() Func Example() If Not WinExists("[CLASS:Notepad]") Then Run("notepad.exe") WinActivate("[CLASS:Notepad]") WinWaitActive("[CLASS:Notepad]") Local $hWnd = WinGetHandle("[CLASS:Notepad]") Local $hMain = _GUICtrlMenu_GetMenu($hWnd) ConsoleWrite("Is it displayed ? " & _GUICtrlMenu_GetItemHighlighted($hMain, 0) & @CRLF) Local $aPos = _GUICtrlMenu_GetItemRect($hWnd, $hMain, 0) MouseClick("left", $aPos[0] + 10, $aPos[1] + 5, 1, 0) Sleep(800) ConsoleWrite("Is it displayed now ? " & _GUICtrlMenu_GetItemHighlighted($hMain, 0) & @CRLF) Local $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0) Local $iCount = _GUICtrlMenu_GetItemCount($hFile) Local $aRect = _GUICtrlMenu_GetItemRect($hWnd, $hFile, 0) Local $aLast = _GUICtrlMenu_GetItemRect($hWnd, $hFile, $iCount - 1) $aRect[2] = $aLast[2] $aRect[3] = $aRect[3] _ArrayDisplay($aRect) EndFunc ;==>Example Edited August 24, 2021 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
BrunoStivicevic Posted August 25, 2021 Author Posted August 25, 2021 Hi Nine, thanks for looking into it! I didn't manage to make work your example, applied on my situation. I've tried the single line first: is it displayed? My menu structure is as shown below. My try was to check whether the drop-down "Statistiche" is displayed. The position of that drop-down is 3 and it is a child of $hMain. But, I'm getting all the time false, when the menu Statistiche is displayed or not. Kind regards Bruno $hMain = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile) _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Trova", 0, $hTrova) _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Visualizza", 0, $hVisualizza) _GUICtrlMenu_InsertMenuItem($hMain, 3, "&Statistiche", 0, $hStatistiche) If $p= 0 Then _GUICtrlMenu_InsertMenuItem($hMain, 4, "&Archivia", 0, $hArchivia) If $p = 0 Then _GUICtrlMenu_InsertMenuItem($hMain, 5, "A&rricchisci", 0, $hArricchisci) If $p = 0 Then _GUICtrlMenu_InsertMenuItem($hMain, 6, "&Strumenti", 0, $hStrumenti) _GUICtrlMenu_InsertMenuItem($hMain, 7, "&Guida", 0, $hGUI_Arch_menuda) ; Set window menu _GUICtrlMenu_SetMenu($hGUI_Arch_menu, $hMain) Local $aAccelKeys[2][2] = [["^1", $e_idArch_Zmin], ["^2", $e_idArch_Zmed]] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND") ; Loop until the user exits. Global $hDLL = DllOpen("user32.dll") While 1 Sleep(100) $msg = GUIGetMsg() ConsoleWrite("Is it displayed ? " & _GUICtrlMenu_GetItemHighlighted($hMain, 3) & @CRLF) ....
Nine Posted August 25, 2021 Posted August 25, 2021 You need to specify $MNS_MODELESS in the creation of the main menu. Please next time provide a runable snippet of code. It is not very hard to produce and it facilitates the ones who are trying to help you. Here : expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiMenu.au3> Example() Func Example() Local $hGUI, $hFile, $hEdit, $hHelp, $hMain Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste ; Create GUI $hGUI = GUICreate("Menu", 400, 300) ; Create File menu $hFile = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew) _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen) _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave) _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit) ; Create Edit menu $hEdit = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut) _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy) _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste) ; Create Help menu $hHelp = _GUICtrlMenu_CreateMenu() ; Create Main menu $hMain = _GUICtrlMenu_CreateMenu($MNS_MODELESS) _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile) _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit) _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp) ; Set window menu _GUICtrlMenu_SetMenu($hGUI, $hMain) GUISetState(@SW_SHOW) ; Loop until the user exits. Do ConsoleWrite("Is it displayed ? " & _GUICtrlMenu_GetItemHighlighted($hMain, 1) & @CRLF) Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
BrunoStivicevic Posted August 25, 2021 Author Posted August 25, 2021 Thank you so much, Nine! I would surely paste the code, but it is over 500 lines and in order to be tested appropriately, it requires Picasa 3.9 to be installed, running and have some content. That's the reason I didn't post it. I will try your example ASAP and will let you know! Kindest regards Bruno
Nine Posted August 25, 2021 Posted August 25, 2021 Understand that a snippet of 500 lines for us is not appropriate. This is why you should always find a representative code that we can run easily. Most of the time, the examples coming from the help file are simple enough to adapt to the issue you are having. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
BrunoStivicevic Posted August 25, 2021 Author Posted August 25, 2021 Thanks a lot Nine, it works also on my menu! Have a nice day! Kindest regards Bruno
Nine Posted August 25, 2021 Posted August 25, 2021 Great, please mark it as solved. Thanks. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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