Viktor1703
AutoIT Гуру
- Сообщения
- 1,535
- Репутация
- 413
Пример для новичков.
Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $iState = True
GUICreate("Example", 350, 180)
$nInput = GUICtrlCreateInput("E-mail:", 10, 10, 150, 20)
$nButton = GUICtrlCreateButton("Жми", 20, 50, 80, 20)
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
Switch CursorGetMsg() ;~ Когда курсор находится над контролом
Case $nButton
If $iState Then
GUICtrlSetData($nButton, "Выход")
$iState = False
EndIf
Case $nInput
If $iState Then
GUICtrlSetData($nInput, "")
$iState = False
EndIf
Case Else
If GUICtrlRead($nButton) = "Выход" Then
GUICtrlSetData($nButton, "Жми")
$iState = True
EndIf
If GUICtrlRead($nInput) = "" Then
GUICtrlSetData($nInput, "E-mail:")
$iState = True
EndIf
EndSwitch
Switch CursorGetMsg(1) ;~ Клик по контролу первой кнопкой мыши
Case $nInput
MsgBox(0, "$nInput", "Клик по Input первой кнопкой мыши")
Case $nButton
MsgBox(0, "$nButton", "Клик по Button первой кнопкой мыши")
EndSwitch
Switch CursorGetMsg(2) ;~ Клик по контролу Второй кнопкой мыши
Case $nInput
MsgBox(0, "$nInput", "Клик по Input второй кнопкой мыши")
Case $nButton
MsgBox(0, "$nButton", "Клик по Button второй кнопкой мыши")
EndSwitch
WEnd
Func CursorGetMsg($iState = 0)
Local $aCursor = GUIGetCursorInfo()
If Not @error Then
If $iState = 0 then
Return $aCursor[4]
ElseIf $iState = 1 then
If $aCursor[4] And $aCursor[2] Then
Return $aCursor[4]
EndIf
ElseIf $iState = 2 then
If $aCursor[4] And $aCursor[3] Then
Return $aCursor[4]
EndIf
EndIf
EndIf
EndFunc