#include <GUIConstants.au3>
#Include <GuiMenu.au3>
Global Const $WM_SYSCOMMAND = 0x0112
Dim $hGUI = GUICreate("System Menu")
GUISetState()
GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND")
$nItem = _CreateSystemMenuItem("Hit me strongly...", -1, False, 0)
_CreateSystemMenuItem("", -1, False, 1)
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
Func _WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
Local $nID = BitAND($wParam, 0x0000FFFF)
Switch $nID
Case $nItem
MsgBox(0, "My System Menu", "Your penis is very vigorous")
EndSwitch
EndFunc
Func _InsertMenu($hMenu, $nPosition, $nFlags, $nIDNewItem, $lpNewItem)
Local $nResult = DllCall("user32.dll", "int", "InsertMenu", "hwnd", $hMenu, "int", $nPosition, "int", $nFlags, "int", $nIDNewItem, "str", $lpNewItem)
Return $nResult[0]
EndFunc
Func _CreateSystemMenuItem($sText, $hMenu = -1, $bIsPopup = False, $nPos = 0xFFFFFFFF)
If $hMenu = -1 Then $hMenu = _GUICtrlMenu_GetSystemMenu($hGUI, 0)
Local $nID = GUICtrlCreateDummy(), $nFlags = 0
If $sText = "" Then
$nFlags = $MF_SEPARATOR
ElseIf $bIsPopup Then
$nID = _GUICtrlMenu_CreatePopup()
$nFlags = $MF_POPUP
EndIf
$nFlags = BitOR($MF_BYPOSITION, $nFlags)
$nResult = _InsertMenu($hMenu, $nPos, $nFlags, $nID, $sText)
Return $nID
EndFunc
|