Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GUIConstantsEx.au3>
- #include <WinAPI.au3>
- $hGUI=GUICreate('My Program', 250, 260)
- $iExport=GUICtrlCreateButton('Start', 10, 10, 120, 22)
- $iExportContext = GUICtrlCreateDummy()
- $iExportContextMenu = GUICtrlCreateContextMenu($iExportContext)
- $iExportContextItem1 = GUICtrlCreateMenuItem('HTML', $iExportContextMenu)
- $iExportContextItem2 = GUICtrlCreateMenuItem('fuf', $iExportContextMenu)
- $iExportContextItem3 = GUICtrlCreateMenuItem('ещё', $iExportContextMenu)
- $iExportContextItem4 = GUICtrlCreateMenuItem('угу', $iExportContextMenu)
- GUISetState ()
- GUIRegisterMsg(0x004E, "WM_NOTIFY")
- While 1
- $msg = GUIGetMsg()
- Switch $msg
- Case $iExport
- _GUICtrlButton_ContextMenuEx($hGUI, $iExport, $iExportContextMenu)
- Case -3
- Exit
- EndSwitch
- WEnd
- Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
- #forceref $hWnd, $Msg, $wParam
- Local Const $BCN_HOTITEMCHANGE = -1249
- Local $tNMBHOTITEM = DllStructCreate("hwnd hWndFrom;int IDFrom;int Code;dword dwFlags", $lParam)
- Local $nNotifyCode = DllStructGetData($tNMBHOTITEM, "Code")
- ; Local $nID = DllStructGetData($tNMBHOTITEM, "IDFrom")
- ; Local $hCtrl = DllStructGetData($tNMBHOTITEM, "hWndFrom")
- Local $dwFlags = DllStructGetData($tNMBHOTITEM, "dwFlags")
- Switch $nNotifyCode
- Case $BCN_HOTITEMCHANGE ; Win XP and Above
- If BitAND($dwFlags, 0x10) = 0x10 Then
- _GUICtrlButton_ContextMenuEx($hGUI, $iExport, $iExportContextMenu)
- ControlFocus($iExport, "", "Edit1")
- ElseIf BitAND($dwFlags, 0x20) = 0x20 Then
- ; Send('{Enter}')
- ; Send('{DOWN}')
- EndIf
- EndSwitch
- Return $GUI_RUNDEFMSG
- EndFunc
- Func _GUICtrlButton_ContextMenuEx($hHandle, $iControlID, $iContextMenu)
- Local $aControlGetPos, $hMenu, $iX, $iY
- $hMenu = GUICtrlGetHandle($iContextMenu)
- $aControlGetPos = ControlGetPos($hHandle, "", $iControlID)
- $iX = $aControlGetPos[0]
- $iY = $aControlGetPos[1] + $aControlGetPos[3]
- _ClientToScreen($hHandle, $iX, $iY)
- DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $iX, "int", $iY, "hwnd", $hHandle, "ptr", 0)
- EndFunc ;==>_GUICtrlButton_ContextMenuEx
- Func _ClientToScreen($hHandle, ByRef $iX, ByRef $iY)
- Local $tPoint
- $tPoint = DllStructCreate("int X;int Y")
- DllStructSetData($tPoint, 1, $iX)
- DllStructSetData($tPoint, 2, $iY)
- _WinAPI_ClientToScreen($hHandle, $tPoint)
- $iX = DllStructGetData($tPoint, 1)
- $iY = DllStructGetData($tPoint, 2)
- EndFunc ;==>_ClientToScreen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement