kftang Posted August 20, 2022 Share Posted August 20, 2022 (edited) expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> Example() Func Example() local $hGui = GUICreate("My GUI menu", 300, 200) Local $idFilemenu = GUICtrlCreateMenu("&File") Local $idFileitem = GUICtrlCreateMenuItem("Open", $idFilemenu) Local $idHelpmenu = GUICtrlCreateMenu("?") GUICtrlCreateMenuItem("Save", $idFilemenu) GUICtrlSetState(-1, $GUI_DISABLE) Local $idInfoitem = GUICtrlCreateMenuItem("Info", $idHelpmenu) Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu) Local $idRecentfilesmenu = GUICtrlCreateMenu("Recent Files", $idFilemenu, 1) Local $idViewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu Local $idViewstatusitem = GUICtrlCreateMenuItem("Statusbar", $idViewmenu) GUICtrlSetState(-1, $GUI_CHECKED) Local $idButton_1 = GUICtrlCreateButton("Button 1", 50, 130, 70, 20) Local $idButton_2 = GUICtrlCreateButton("Button 2", 180, 130, 70, 20) GUISetState(@SW_SHOW) Local $sFile Local $tPoint = GUIGetCursorInfo() Local $hWnd1 = ControlGetHandle(WinGetHandle($hGui), "", $idButton_1) Local $hWnd2 = ControlGetHandle(WinGetHandle($hGui), "", $idFilemenu) While 1 $tPoint = _WinAPI_GetMousePos() If _WinAPI_WindowFromPoint($tPoint) = $hWnd1 Then GUICtrlSetState($idButton_2, $GUI_HIDE) ElseIf _WinAPI_WindowFromPoint($tPoint) = $hWnd2 Then ; Got PROBLEM at here GUICtrlSetState($idButton_2, $GUI_HIDE) Else GUICtrlSetState($idButton_2, $GUI_SHOW) EndIf Switch GUIGetMsg() Case $idFileitem $sFile = FileOpenDialog("Choose file...", @TempDir, "All (*.*)") If @error <> 1 Then GUICtrlCreateMenuItem($sFile, $idRecentfilesmenu) Case $idViewstatusitem If BitAND(GUICtrlRead($idViewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($idViewstatusitem, $GUI_UNCHECKED) Else GUICtrlSetState($idViewstatusitem, $GUI_CHECKED) EndIf Case $GUI_EVENT_CLOSE, $idExititem ExitLoop Case $idInfoitem MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...") EndSwitch WEnd GUIDelete() EndFunc Hi, I got stuck at mouse hover problem. This is my code. From the code, you can see when mouse hover on Button 1, Button 2 will be hided. But when mouse hover on the File Menu, Button 2 doesn't work. I think the main reason is due to the File Menu's control ID cannot be detected. I used the AutoIT Info Tool also can't detected the Menu bar. Appreciate if anybody can help. Thank you.New AutoIt v3 Script.au3 Edited August 20, 2022 by kftang To attached with the code Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 20, 2022 Moderators Share Posted August 20, 2022 Moved to the appropriate forum. Moderation Team 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...
Nine Posted August 20, 2022 Share Posted August 20, 2022 (edited) Maybe this way (it doesn't solve the flickers, but I will let you handle it) : expandcollapse popup#include <GUIConstants.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <GuiMenu.au3> #include <Array.au3> Example() Func Example() Local $hGui = GUICreate("My GUI menu", 300, 200) Local $idFilemenu = GUICtrlCreateMenu("&File") Local $idFileitem = GUICtrlCreateMenuItem("Open", $idFilemenu) Local $idHelpmenu = GUICtrlCreateMenu("?") GUICtrlCreateMenuItem("Save", $idFilemenu) GUICtrlSetState(-1, $GUI_DISABLE) Local $idInfoitem = GUICtrlCreateMenuItem("Info", $idHelpmenu) Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu) Local $idRecentfilesmenu = GUICtrlCreateMenu("Recent Files", $idFilemenu, 1) Local $idViewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu Local $idViewstatusitem = GUICtrlCreateMenuItem("Statusbar", $idViewmenu) GUICtrlSetState(-1, $GUI_CHECKED) Local $idButton_1 = GUICtrlCreateButton("Button 1", 50, 130, 70, 20) Local $idButton_2 = GUICtrlCreateButton("Button 2", 180, 130, 70, 20) GUISetState(@SW_SHOW) Local $tPoint = DllStructCreate($tagPOINT) Local $hMain = _GUICtrlMenu_GetMenu($hGui) ConsoleWrite($hMain & @CRLF) Local $aFile = _GUICtrlMenu_GetItemRect($hGui, $hMain, 0) $tPoint.X = $aFile[0] $tPoint.Y = $aFile[1] _WinAPI_ScreenToClient($hGui, $tPoint) ConsoleWrite($tPoint.X & "/" & $tPoint.Y & @CRLF) $aFile[0] = $tPoint.X $aFile[1] = $tPoint.Y $tPoint.X = $aFile[2] $tPoint.Y = $aFile[3] _WinAPI_ScreenToClient($hGui, $tPoint) ConsoleWrite($tPoint.X & "/" & $tPoint.Y & @CRLF) $aFile[2] = $tPoint.X $aFile[3] = $tPoint.Y While 1 $aPos = GUIGetCursorInfo() If $aPos[0] >= $aFile[0] And $aPos[1] >= $aFile[1] And $aPos[0] <= $aFile[2] And $aPos[1] <= $aFile[3] Then GUICtrlSetState($idButton_2, $GUI_HIDE) ElseIf $aPos[4] = $idButton_1 Then GUICtrlSetState($idButton_2, $GUI_HIDE) Else GUICtrlSetState($idButton_2, $GUI_SHOW) EndIf Switch GUIGetMsg() Case $idFileitem $sFile = FileOpenDialog("Choose file...", @TempDir, "All (*.*)") If @error <> 1 Then GUICtrlCreateMenuItem($sFile, $idRecentfilesmenu) Case $idViewstatusitem If BitAND(GUICtrlRead($idViewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($idViewstatusitem, $GUI_UNCHECKED) Else GUICtrlSetState($idViewstatusitem, $GUI_CHECKED) EndIf Case $GUI_EVENT_CLOSE, $idExititem ExitLoop Case $idInfoitem MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...") EndSwitch WEnd EndFunc ;==>Example Edited August 20, 2022 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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
kftang Posted August 20, 2022 Author Share Posted August 20, 2022 Nine, thanks your reply. It works. However, this method create another problem. Whenever I minimize the GUI window, or mouse click outside the range from Window, it will prompt an error: Subscript used on non-accessible variable. Any further advise? Thank you. expandcollapse popup#include <GUIConstants.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <GuiMenu.au3> #include <Array.au3> Example() Func Example() Local $hGui = GUICreate("My GUI menu", 300, 200) Local $idFilemenu = GUICtrlCreateMenu("&File") Local $idFileitem = GUICtrlCreateMenuItem("Open", $idFilemenu) Local $idHelpmenu = GUICtrlCreateMenu("?") GUICtrlCreateMenuItem("Save", $idFilemenu) GUICtrlSetState(-1, $GUI_DISABLE) Local $idInfoitem = GUICtrlCreateMenuItem("Info", $idHelpmenu) Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu) Local $idRecentfilesmenu = GUICtrlCreateMenu("Recent Files", $idFilemenu, 1) Local $idViewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu Local $idViewstatusitem = GUICtrlCreateMenuItem("Statusbar", $idViewmenu) GUICtrlSetState(-1, $GUI_CHECKED) Local $idButton_1 = GUICtrlCreateButton("Button 1", 50, 130, 70, 20) Local $idButton_2 = GUICtrlCreateButton("Button 2", 180, 130, 70, 20) GUISetState(@SW_SHOW) Local $tPoint = DllStructCreate($tagPOINT) Local $hMain = _GUICtrlMenu_GetMenu($hGui) ConsoleWrite($hMain & @CRLF) Local $aFile = _GUICtrlMenu_GetItemRect($hGui, $hMain, 0) $tPoint.X = $aFile[0] $tPoint.Y = $aFile[1] _WinAPI_ScreenToClient($hGui, $tPoint) ConsoleWrite($tPoint.X & "/" & $tPoint.Y & @CRLF) $aFile[0] = $tPoint.X $aFile[1] = $tPoint.Y $tPoint.X = $aFile[2] $tPoint.Y = $aFile[3] _WinAPI_ScreenToClient($hGui, $tPoint) ConsoleWrite($tPoint.X & "/" & $tPoint.Y & @CRLF) $aFile[2] = $tPoint.X $aFile[3] = $tPoint.Y While 1 $aPos = GUIGetCursorInfo() If $aPos[0] >= $aFile[0] And $aPos[1] >= $aFile[1] And $aPos[0] <= $aFile[2] And $aPos[1] <= $aFile[3] Then GUICtrlSetState($idButton_2, $GUI_HIDE) ElseIf $aPos[4] = $idButton_1 Then GUICtrlSetState($idButton_2, $GUI_HIDE) Else GUICtrlSetState($idButton_2, $GUI_SHOW) EndIf Switch GUIGetMsg() Case $idFileitem $sFile = FileOpenDialog("Choose file...", @TempDir, "All (*.*)") If @error <> 1 Then GUICtrlCreateMenuItem($sFile, $idRecentfilesmenu) Case $idViewstatusitem If BitAND(GUICtrlRead($idViewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($idViewstatusitem, $GUI_UNCHECKED) Else GUICtrlSetState($idViewstatusitem, $GUI_CHECKED) EndIf Case $GUI_EVENT_CLOSE, $idExititem ExitLoop Case $idInfoitem MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...") EndSwitch Sleep(30) WEnd EndFunc ;==>Example Link to comment Share on other sites More sharing options...
Nine Posted August 20, 2022 Share Posted August 20, 2022 Ya check for @error on GUIGetCursorInfo. Manage the result. “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) Screen Scraping Multi-Threading Made Easy 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