jvds Posted June 3, 2019 Share Posted June 3, 2019 I want to create a context menu that does not freeze the script while the menu is open, is that possible?, here is a modified sample script, when the menu is open the loop is stuck expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("My GUI Context Menu", 300, 200) Local $idContextmenu = GUICtrlCreateContextMenu() Local $idNewsubmenu = GUICtrlCreateMenu("new", $idContextmenu) Local $idNewsubmenuText = GUICtrlCreateMenuItem("text", $idNewsubmenu) Local $idButton = GUICtrlCreateButton("OK", 100, 100, 70, 20) Local $idButtoncontext = GUICtrlCreateContextMenu($idButton) Local $idMenuAbout = GUICtrlCreateMenuItem("About button", $idButtoncontext) Local $idMenuOpen = GUICtrlCreateMenuItem("Open", $idContextmenu) Local $idMenuSave = GUICtrlCreateMenuItem("Save", $idContextmenu) GUICtrlCreateMenuItem("", $idContextmenu) ; separator Local $idMenuInfo = GUICtrlCreateMenuItem("Info", $idContextmenu) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton MsgBox($MB_SYSTEMMODAL, "Button Clicked", 'OK') Case $idMenuAbout MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'About') Case $idMenuOpen MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Open') Case $idMenuSave MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Save') Case $idMenuInfo MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Info') Case $idNewsubmenuText MsgBox($MB_SYSTEMMODAL, "SubMenu Selected", 'Text') EndSwitch sleep(1000) ConsoleWrite('test loop'&@CRLF) WEnd GUIDelete() EndFunc ;==>Example Link to comment Share on other sites More sharing options...
LarsJ Posted June 4, 2019 Share Posted June 4, 2019 Make the context menu modeless. Add these two lines Local $hCM = GUICtrlGetHandle( $idContextmenu ) _GUICtrlMenu_SetMenuStyle($hCM, BitXOR(_GUICtrlMenu_GetMenuStyle($hCM), $MNS_MODELESS)) immediately after this line Local $idContextmenu = GUICtrlCreateContextMenu() You can repeat that for all context menus. Also add #include <GuiMenu.au3> at the top of the script. jvds 1 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...
jvds Posted June 6, 2019 Author Share Posted June 6, 2019 Thanks! 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