Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   AutoIt (http://forum.oszone.net/forumdisplay.php?f=103)
-   -   [решено] Как вывести ГУЙ окошко при нажатии правой кнопки мышки? (http://forum.oszone.net/showthread.php?t=211004)

Romanka 12-07-2011 11:37 1711718

Как вывести ГУЙ окошко при нажатии правой кнопки мышки?
 
Как вывести ГУЙ окошко со своей кнопкой, при нажатии правой кнопки мышки в тексте? Подскажите, пожалуйста.

Yashied 13-07-2011 22:34 1712764

Хорошо еще, что ГУЙ, а не...

:)

Romanka 14-07-2011 09:32 1712987

ну это то да, а вопрос открытым остался, я что только не перепробЫвал, не получается, помогите пожалуйста.

madmasles 14-07-2011 10:43 1713029

Цитата:

Цитата Romanka
при нажатии правой кнопки мышки в тексте »

В каком тексте? Где этот текст находится?

Romanka 14-07-2011 11:37 1713067

Любой текст, просто когда в любом месте окна нажмем правой кнопкой мышки. Так скажем сделать своё меню )

madmasles 14-07-2011 15:25 1713294

Romanka,
Попробуйте так:
Код:

#NoTrayIcon
#include <WinAPI.au3>
#include <Misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $tStruct, $hHandle, $sClassName, $hWinMenu
$tStruct = DllStructCreate($tagPoint)

HotKeySet('{ESC}', '_Exit')

While 1
    If _IsPressed('02') Then
        _Get_Pos()
        $hHandle = _WinAPI_WindowFromPoint($tStruct)
        $sClassName = _WinAPI_GetClassName($hHandle)
        If StringInStr($sClassName, 'Edit') Or StringInStr($sClassName, 'Static') Then
            $hWinMenu = WinGetHandle('[CLASS:#32768]')
            If $hWinMenu Then
                If BitAND(WinGetState($hWinMenu), 2) Then
                    WinClose($hWinMenu)
                EndIf
            EndIf
            _My_GUICreate($hHandle)
        EndIf
    EndIf
    Sleep(10)
WEnd

Func _Get_Pos()
    DllStructSetData($tStruct, 'x', MouseGetPos(0))
    DllStructSetData($tStruct, 'y', MouseGetPos(1))
EndFunc  ;==>_Get_Pos

Func _Exit()
    Exit
EndFunc  ;==>_Exit

Func _My_GUICreate($h_HWnd)
    Local $h_GUI, $n_Button, $n_Msg, $i_X, $i_X_Rotate, $i_Y, $i_Y_Rotate, $i_W = 200, $i_H = 100

    $i_X = MouseGetPos(0)
    $i_Y = MouseGetPos(1)

    If $i_X >= @DesktopWidth - $i_W Then
        $i_X = @DesktopWidth - $i_W - 3
    EndIf
    If $i_Y >= @DesktopHeight - $i_H Then
        $i_Y = @DesktopHeight - $i_H - 3
    EndIf
    $h_HWnd = _WinAPI_GetAncestor($h_HWnd, $GA_ROOT)
    $h_GUI = GUICreate('My GUI', $i_W, $i_H, $i_X, $i_Y, $WS_POPUP)
    GUISetBkColor(0x808080)
    $n_Button = GUICtrlCreateButton('Click me', 50, 35, 100, 30)
    GUISetState()
    While 1
        If Not WinExists($h_HWnd) Then ExitLoop
        WinSetOnTop($h_GUI, '', 1)
        $n_Msg = GUIGetMsg()
        Switch $n_Msg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $n_Button
                MsgBox(64, 'Info', 'Button click', 5, $h_GUI)
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($h_GUI)
EndFunc  ;==>_My_GUICreate


Romanka 14-07-2011 15:37 1713303

Супер! спасибо работает


Время: 22:03.

Время: 22:03.
© OSzone.net 2001-