#include "SendMessage.au3"
Global Const $WM_RBUTTONDOWN = 0x0204
Global Const $WM_RBUTTONUP = 0x0205
$GUI=GUICreate('My Program', 250, 260, 10, 400)
$Gui2 = WinGetHandle($Gui)
$Button1=GUICtrlCreateButton('кнопка', 10, 10, 120, 22)
$buttoncontext = GUICtrlCreateContextMenu($Button1)
GUICtrlCreateMenuItem("меню кнопки", $buttoncontext)
$context = GUICtrlCreateContextMenu(-1)
GUICtrlCreateMenuItem("меню GUI", $context)
GUISetState ()
_SendMessageA(GUICtrlGetHandle($Button1), $WM_RBUTTONDOWN)
_SendMessageA(GUICtrlGetHandle($Button1), $WM_RBUTTONUP)
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
EndSwitch
WEnd