- Сообщения
- 8,673
- Репутация
- 2,484
AutoIt: 3.3.6.1
Версия: 1.2
Категория: Окна / Элементы управления
Описание: Устанавливает событие для элементов управления определённого окна. Полезно для слежения за нажатием кнопок во внешних приложениях (окнах).
Пример:
Screenshot: N/A
Источник: CreatoR, http://www.autoitscript.com/forum/index.php?showtopic=96003
Версия: 1.2
Категория: Окна / Элементы управления
Описание: Устанавливает событие для элементов управления определённого окна. Полезно для слежения за нажатием кнопок во внешних приложениях (окнах).
Пример:
Код:
#include <WinControlSetEvent.au3>
;============== Calc Demo ==============
;In this example we use the main loop to avoid blocking of mouse processing from inside CalcGetResult_Proc() function.
HotKeySet("^q", "_Quit")
$iGetCalcResults = False
Run("Calc.exe")
If Not WinWait("[CLASS:SciCalc]", "", 3) Then
Exit
EndIf
For $i = 0 To 9
_WinControlSetEvent("[CLASS:SciCalc]", String($i), "", "", _
"_CalcGetResult_Trigger_Proc", "'" & $i & "' Button has been pressed")
Next
_WinControlSetEvent("[CLASS:SciCalc]", "=", "", "", "_CalcGetResult_Trigger_Proc", "'=' Button has been pressed")
_WinControlSetEvent("[CLASS:SciCalc]", "/", "", "", "_CalcGetResult_Trigger_Proc", "'/' Button has been pressed")
_WinControlSetEvent("[CLASS:SciCalc]", "*", "", "", "_CalcGetResult_Trigger_Proc", "'*' Button has been pressed")
_WinControlSetEvent("[CLASS:SciCalc]", "-", "", "", "_CalcGetResult_Trigger_Proc", "'-' Button has been pressed")
_WinControlSetEvent("[CLASS:SciCalc]", "+", "", "", "_CalcGetResult_Trigger_Proc", "'+' Button has been pressed")
;~ _WinControlSetEvent("[CLASS:SciCalc]", "Button28", "", "", "_CalcGetResult_Trigger_Proc", "'X' Button has been pressed")
While WinExists("[CLASS:SciCalc]")
Sleep(10)
WEnd
;Warning: blocking of this function by window messages with commands such as "Msgbox()" can lead to unexpected behavior,
;the return to the system should be as fast as possible !!!
Func _CalcGetResult_Trigger_Proc($sParams, $hWnd, $nCtrlID)
ConsoleWrite("Passed params: " & $sParams & @CRLF)
$iGetCalcResults = $nCtrlID
AdlibRegister("_CalcGetResult_Main_Proc", 1)
EndFunc
Func _CalcGetResult_Main_Proc()
AdlibUnRegister()
If $iGetCalcResults = 168 Then Exit ;Calc closed
$sCtrl_Data = ControlGetText("[CLASS:SciCalc]", "", $iGetCalcResults)
If $sCtrl_Data = "=" Then
Local $sResult = StringStripWS(ControlGetText("[CLASS:SciCalc]", "", "Edit1"), 3)
If StringRight($sResult, 1) = "," Then $sResult = StringTrimRight($sResult, 1)
ToolTip("The result has been calculated: " & $sResult, Default, Default, "Calc Info", 1, 5)
ElseIf $sCtrl_Data <> "" Then
ToolTip("Calc Button Pressed: " & $sCtrl_Data, Default, Default, "Calc Info", 1, 5)
EndIf
EndFunc
Func _Quit()
Exit
EndFunc
Screenshot: N/A
Источник: CreatoR, http://www.autoitscript.com/forum/index.php?showtopic=96003