Jump to content

Popup menu without a GUI


Recommended Posts

Popup menu, like right clicking the desktop? That menu?

#include <GuiMenu.au3>
#include <WindowsConstants.au3>

Global Enum $e_idOpen = 1000, $e_idSave, $e_idInfo

; Fake gui, just used to show the popup menu
Global $hGui = GUICreate("Popup")
Global $hMenu = _GUICtrlMenu_CreatePopup()
Global $aMousePos = MouseGetPos()
_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, $hGui, $aMousePos[0], $aMousePos[1])
GUIRegisterMsg($WM_COMMAND, WM_COMMAND)

; Handle WM_COMMAND messages
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Switch $wParam
        Case $e_idOpen
            ConsoleWrite("Open" & @LF)
        Case $e_idSave
            ConsoleWrite("Save" & @LF)
        Case $e_idInfo
            ConsoleWrite("Info" & @LF)
    EndSwitch
EndFunc   ;==>WM_COMMAND

There might be abetter way but this is how I figured it out. Never used a context menu by itself.

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...