Код:
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <GuiIPAddress.au3>
#include <WindowsConstants.au3>
Global $nForm, $hIPAddress, $sLastIP
Global $START_IP = "127.0.0.1"
Opt("TrayMenuMode", 1)
$hIp = TrayCreateItem("IP Ping")
TrayCreateItem("")
$hExit = TrayCreateItem("Exit")
TraySetState()
$start = 0
While 1
$msg = TrayGetMsg()
Switch $msg
Case $hIp
TrayItemSetState($hIp, $TRAY_UNCHECKED + $TRAY_DISABLE)
TrayItemSetState($hExit, $TRAY_DISABLE)
$sIP = _GuiCreate()
If Not (@error) Then MsgBox(0, "", 'IP - ' & $sIP)
TrayItemSetState($hIp, $TRAY_ENABLE)
TrayItemSetState($hExit, $TRAY_ENABLE)
Case $hExit
Exit
EndSwitch
WEnd
Func _GuiCreate()
$nForm = GUICreate("", 223, 102, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
$hIPAddress = _GUICtrlIpAddress_Create($nForm, 24, 16, 162, 21)
If Not $sLastIP Then
_GUICtrlIpAddress_Set($hIPAddress, $START_IP)
Else
_GUICtrlIpAddress_Set($hIPAddress, $sLastIP)
EndIf
$Button1 = GUICtrlCreateButton("Ok", 144, 64, 43, 25)
$Button2 = GUICtrlCreateButton("Cancel", 64, 64, 75, 25)
GUISetState(@SW_SHOW, $nForm)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $Button2
GUIDelete($nForm)
Return SetError(1, 0, 0)
Case $Button1
$sLastIP = _GUICtrlIpAddress_Get($hIPAddress)
GUIDelete($nForm)
Return $sLastIP
EndSwitch
WEnd
EndFunc ;==>_GuiCreate