Вот еще один пример.
Код:
#Include <EditConstants.au3>
#Include <GUIConstantsEx.au3>
#Include <GUIEdit.au3>
#Include <GUISlider.au3>
#Include <StaticConstants.au3>
#Include <WindowsConstants.au3>
#Include <Messages.au3>
#NoTrayIcon
if StringLower(StringRight(@ScriptFullPath, 3)) = 'au3' then
MsgBox(64, 'Messages UDF Library Demonstration', 'To run this script, you must first compile it and then run the (.exe) file.')
exit
endif
Opt('MustDeclareVars', 1)
if $CmdLine[0] = 0 then
ShellExecute(@ScriptFullPath, '1')
ShellExecute(@ScriptFullPath, '2')
ShellExecute(@ScriptFullPath, '3')
exit
endif
local $Form, $Input1, $Input2, $Radio1, $Radio2, $Radio3, $ButtonSend, $Edit, $Slider, $Check
switch $CmdLine[1]
case '1', '2', '3'
_Main(Int($CmdLine[1]))
case else
endswitch
func _Main($Index)
local $GUIMsg, $nScript, $Data, $Timer = _MsgTimerInterval(0)
$Form = GUICreate('Script' & $Index, 324, 384, (@DesktopWidth - 1018) / 2 + ($Index - 1) * 344, (@DesktopHeight - 440) / 2, BitOR($WS_CAPTION, $WS_SYSMENU), $WS_EX_TOPMOST)
GUISetFont(8.5, 400, 0, 'Tahoma', $Form)
GUICtrlCreateLabel('Message:', 14, 22, 48, 14)
$Input1 = GUICtrlCreateInput('', 64, 19, 246, 20)
GUICtrlCreateLabel('Send to:', 14, 56, 48, 14)
GUIStartGroup()
$Radio1 = GUICtrlCreateRadio('Script1', 64, 56, 56, 14)
GUICtrlSetState(-1, $GUI_CHECKED)
$Radio2 = GUICtrlCreateRadio('Script2', 130, 56, 56, 14)
$Radio3 = GUICtrlCreateRadio('Script3', 196, 56, 56, 14)
$ButtonSend = GUICtrlCreateButton('Send', 236, 88, 75, 23)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
GUICtrlCreateLabel('', 14, 128, 299, 2, $SS_ETCHEDHORZ)
GUICtrlCreateLabel('Received message:', 14, 142, 98, 14)
$Edit = GUICtrlCreateEdit('', 14, 160, 296, 129, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlCreateLabel('Timer interval (ms):', 14, 316, 98, 14)
$Slider = GUICtrlCreateSlider(110, 312, 162, 26, BitOR($TBS_AUTOTICKS, $WS_TABSTOP))
GUICtrlSetLimit(-1, 20, 1)
GUICtrlSetData(-1, $Timer / 50)
_GUICtrlSlider_SetTicFreq(-1, 1)
$Input2 = GUICtrlCreateInput($Timer, 274, 313, 36, 20, $ES_READONLY)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Check = GUICtrlCreateCheckBox('Enable receiver', 14, 354, 96, 19)
GUICtrlSetState(-1, $GUI_CHECKED)
Opt('GUICloseOnESC', 0)
GUISetState()
_MsgRegister('Script' & $Index, '_Receiver')
while 1
$GUIMsg = GUIGetMsg()
select
case $GUIMsg = $GUI_EVENT_CLOSE
exit
case $GUIMsg = $ButtonSend
for $i = $Radio1 to $Radio3
if GUICtrlRead($i) = $GUI_CHECKED then
$nScript = 1 + $i - $Radio1
exitloop
endif
next
$Data = GUICtrlRead($Input1)
if StringStripWS($Data, 3) = '' then
$Data = '(empty)'
endif
if _IsReceiver('Script' & $nScript) then
_MsgSend('Script' & $nScript, 'From Script' & $Index & ': ' & $Data)
endif
case $GUIMsg = $Slider
_MsgTimerInterval($Timer)
case $GUIMsg = $Check
if GUICtrlRead($Check) = $GUI_CHECKED then
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetBkColor($Edit, 0xFFFFFF)
GUICtrlSetState($Slider, $GUI_ENABLE)
GUICtrlSetState($Input2, $GUI_ENABLE)
_MsgRegister('Script' & $Index, '_Receiver')
else
GUICtrlSetState($Edit, $GUI_DISABLE)
GUICtrlSetBkColor($Edit, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState($Slider, $GUI_DISABLE)
GUICtrlSetState($Input2, $GUI_DISABLE)
_MsgRegister('Script' & $Index, '')
endif
endselect
$Data = GUICtrlRead($Slider) * 50
if BitXOR($Data, $Timer) then
$Timer = $Data
GUICtrlSetData($Input2, $Timer)
endif
wend
endfunc; _Main
func _Receiver($sMessage)
_GUICtrlEdit_AppendText($Edit, $sMessage & @CRLF)
return 0
endfunc; _Receiver