nacerbaaziz Posted May 27, 2019 Posted May 27, 2019 hello sirs. i have a request from you please i've created a tray Menu tool that have multy items and i want while the tool is runing if the user open the main exe again a context menu that have the same options that in the tray menu will Appear. i search on the web about how to do that i found the _GUICtrlMenu_TrackPopupMenu() but i realy don't know how to use it can any one help me to do that please. here is the example from the help file expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <WinAPIError.au3> #include <WindowsConstants.au3> Global Enum $e_idOpen = 1000, $e_idSave, $e_idInfo Example() Func Example() ; Create GUI GUICreate("Menu", 400, 300) GUISetState(@SW_SHOW) ; Register message handlers GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example ; Handle WM_COMMAND messages Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Switch $wParam Case $e_idOpen _WinAPI_ShowMsg("Open") Case $e_idSave _WinAPI_ShowMsg("Save") Case $e_idInfo _WinAPI_ShowMsg("Info") EndSwitch EndFunc ;==>WM_COMMAND ; Handle WM_CONTEXTMENU messages Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Local $hMenu $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo) _GUICtrlMenu_TrackPopupMenu($hMenu, $wParam) _GUICtrlMenu_DestroyMenu($hMenu) Return True EndFunc ;==>WM_CONTEXTMENU and here is what i tried #include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <WinAPIError.au3> #include <WindowsConstants.au3> Global Enum $e_idOpen = 1000, $e_idSave, $e_idInfo $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo) $hwnd = WinGetHandle("[ACTIVE]", "") _GUICtrlMenu_TrackPopupMenu($hMenu, $hwnd) _GUICtrlMenu_DestroyMenu($hMenu) sleep(10000) but the problem is the menu did not Appeared
nacerbaaziz Posted May 28, 2019 Author Posted May 28, 2019 Is there a solution to this please? Because I have finished designing the tool and lacked only this option
spudw2k Posted May 31, 2019 Posted May 31, 2019 What you tried won't work very well. You need to run the TrackPopupMenu func inside of the WM_CONTEXTMENU handler. and you are also destroying the menu right after it is created. I'm not sure why the example has it coded that way (create and destroy each time), but I was able to tweak the example (below) and it seems to work. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <WinAPIError.au3> #include <WindowsConstants.au3> Global Enum $e_idOpen = 1000, $e_idSave, $e_idInfo Global $hMenu $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo) ; Create GUI GUICreate("Menu", 400, 300) GUISetState(@SW_SHOW) ; Register message handlers GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GUICtrlMenu_DestroyMenu($hMenu) ; Handle WM_COMMAND messages Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Switch $wParam Case $e_idOpen _WinAPI_ShowMsg("Open") Case $e_idSave _WinAPI_ShowMsg("Save") Case $e_idInfo _WinAPI_ShowMsg("Info") EndSwitch EndFunc ;==>WM_COMMAND ; Handle WM_CONTEXTMENU messages Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam _GUICtrlMenu_TrackPopupMenu($hMenu, $wParam) Return True EndFunc ;==>WM_CONTEXTMENU Reveal hidden contents Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
nacerbaaziz Posted May 31, 2019 Author Posted May 31, 2019 thx sir @spudw2k but not that what i need. i want when the user click on the program the context menu apear automatically. i hope that you can help me to do that
spudw2k Posted June 2, 2019 Posted June 2, 2019 I'm afraid I don't understand. Can you explain what you mean more? Reveal hidden contents Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
nacerbaaziz Posted June 4, 2019 Author Posted June 4, 2019 On 6/2/2019 at 11:49 PM, spudw2k said: I'm afraid I don't understand. Can you explain what you mean more? Expand hello sir So I'll try to explain exactly what I want i've created an tool which work from the system tray this tool has multi items for example tool opened windows hidden windows about exit and i want to create a pop-up menu that containe the same items that in the system tray i meen tool opened windows hidden windows about exit this context menu i want it to apear automaticaly if the user run the tool, and the tool is already runing i finished the tool and i want to add this function To facilitate the access to the tool options because this tool is for the blind users I hope my idea is clear and i hope you can help me to do that. thanks in advance
spudw2k Posted June 5, 2019 Posted June 5, 2019 I think I understand. Upon executing the tool, you want to display the context menu. Is that correct? I couldn't find a way to do ti without a GUI Handle to "attach" the context menu to, but you don't need to show a gui. Here is a small demo you might be able to adapt from. #include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <WinAPIError.au3> #include <WindowsConstants.au3> Global Enum $e_idOpen = 1000, $e_idSave, $e_idInfo Global $hMenu, $hGUI $hGUI = GUICreate("",0,0) $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo) ; Register message handlers ;GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ;GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") $iContextMenuItem = _GUICtrlMenu_TrackPopupMenu($hMenu, $hGUI, @DesktopWidth/2, @DesktopHeight/2, 0, 0, 2) msgbox(0,"Selected Context Menu Item Selected", $iContextMenuItem) _GUICtrlMenu_DestroyMenu($hMenu) Play around with it and let us know where you get stuck or what questions you have. Reveal hidden contents Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Nine Posted June 5, 2019 Posted June 5, 2019 I would also suggest to use 3 instead of 2 for the last parameter of the _GUICtrlMenu_TrackPopupMenu in the example provide by @spudw2k. So no notify is enabled. “They did not know it was impossible, so they did it” ― Mark Twain Reveal hidden contents 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
nacerbaaziz Posted June 5, 2019 Author Posted June 5, 2019 good morning thank you all to your help now i succeded and i did what i was looking for thank you very much to all of you please accept my greetings
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