Sign in to follow this  
Followers 0
Azevedo

Popup menu without a GUI

3 posts in this topic

#1 ·  Posted (edited)

In ahk it is possible to show a popup menu without a gui. Is it possible in AutoIt or it can only be triggered from a gui component?

Edited by Azevedo

Share this post


Link to post
Share on other sites



#2 ·  Posted

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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Exactly that! Thanks mate!

Edited by Azevedo

Share this post


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
Sign in to follow this  
Followers 0