rasim Posted December 12, 2008 Share Posted December 12, 2008 (edited) Hi guys!Why the popup-menu is not closed if I have click the mouse left button anywhere.Exampe: if I click the mouse right button when the cursor hovered on the Notepad maximize button, so popup-menu is appeared, then if I click anywhere the popup-menu is not close. The popup-menu is closed only if I minimize or close the Notepad window.expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> #include <Misc.au3> Global $hDLL = DllOpen("User32.dll") $hGUI = GUICreate("Test", 300, 200) $cDummy = GUICtrlCreateDummy() $cMenu = GUICtrlCreateContextMenu($cDummy) GUICtrlCreateMenuItem("Open", $cMenu) GUICtrlCreateMenuItem("", $cMenu) GUICtrlCreateMenuItem("New", $cMenu) $hMenu = GUICtrlGetHandle($cMenu) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch If _IsPressed("02", $hDLL) Then _TrackPopupMenu($hMenu, 0, MouseGetPos(0), MouseGetPos(1), $hGUI) WEnd DllClose($hDLL) Func _TrackPopupMenu($hMenu, $iFlags, $iX, $iY, $hWnd) DllCall("User32.dll", "int", "TrackPopupMenu", _ "hwnd", $hMenu, _ "int", $iFlags, _ "int", $iX, _ "int", $iY, _ "int", 0, _ "hwnd", $hWnd, _ "hwnd", 0) EndFunc Edited December 13, 2008 by rasim Link to comment Share on other sites More sharing options...
monoceres Posted December 12, 2008 Share Posted December 12, 2008 Can't reproduce on Vista. The popup disappears just fine when I click somewhere else. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
ProgAndy Posted December 12, 2008 Share Posted December 12, 2008 the active window must be one of your application So, just create a 1x1-GUI and delete it again Func _TrackPopupMenu($hMenu, $iFlags, $iX, $iY, $hWnd) Local $GUI = GUICreate("",1,1,$iX,$iY,$WS_POPUP,$WS_EX_TOOLWINDOW) GUISetState() Local $ret = DllCall("User32.dll", "int", "TrackPopupMenuEx", _ "hwnd", $hMenu, _ "int", $iFlags, _ "int", $iX, _ "int", $iY, _ "hwnd", $hWnd, _ "ptr", 0) GUIDelete($GUI) Return $ret[0] EndFunc FireFox 1 *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
martin Posted December 12, 2008 Share Posted December 12, 2008 the active window must be one of your application So, just create a 1x1-GUI and delete it again Func _TrackPopupMenu($hMenu, $iFlags, $iX, $iY, $hWnd) Local $GUI = GUICreate("",1,1,$iX,$iY,$WS_POPUP,$WS_EX_TOOLWINDOW) GUISetState() Local $ret = DllCall("User32.dll", "int", "TrackPopupMenuEx", _ "hwnd", $hMenu, _ "int", $iFlags, _ "int", $iX, _ "int", $iY, _ "hwnd", $hWnd, _ "ptr", 0) GUIDelete($GUI) Return $ret[0] EndFuncThat's interesting. I was puzzled the problem and by your solution ProgAndy (of course it works) but the quote below from msdn explains it and it might help someone else understand it. To display a context menu for a notification icon, the current window must be the foreground window before the application calls TrackPopupMenu or TrackPopupMenuEx. Otherwise, the menu will not disappear when the user clicks outside of the menu or the window that created the menu (if it is visible). Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
rasim Posted December 13, 2008 Author Share Posted December 13, 2008 (edited) ProgAndythe active window must be one of your application So, just create a 1x1-GUI and delete it againYou are a genius!!! Thank you! martinbut the quote below from msdn explains itVery interesting, can you post the link of this quote?Has found in remarks. I need more coffee today Edited December 13, 2008 by rasim 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