我找到了这块代码女巫检索IP的公共信息,但我希望在editbox中写入此输出,我必须在我的GUI中进行。
如何完成。
这是代码,如果您在SCITE编辑器中运行,则将信息放在Sciite的控制台中。我想要的是单击一个按钮将信息放在我的GUI上的编辑框中。
_RetrievePublicInfo()
Func _RetrievePublicInfo($iRefresh = 0)
ConsoleWrite(@CRLF & "IP: " & BinaryToString(InetRead('http://api.externalip.net/ip/', $iRefresh), 4) & @CRLF & @CRLF & _
"Hostname: " & BinaryToString(InetRead('http://api.externalip.net/hostname/', $iRefresh), 4) & @CRLF)
EndFunc
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Func _RetrievePublicInfo($iRefresh = 0)
GUICtrlSetData($Edit , @CRLF & "IP: " & BinaryToString(InetRead('http://api.externalip.net/ip/', $iRefresh), 4) & @CRLF & @CRLF & _
"Hostname: " & BinaryToString(InetRead('http://api.externalip.net/hostname/', $iRefresh), 4) & @CRLF)
EndFunc
$hGUI = GUICreate("Test", 370, 240, 192, 124)
$Edit = GUICtrlCreateEdit("", 0, 0, 313, 193, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY))
$button = GUICtrlCreateButton("Get ip",310,180,50,30)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $button
_RetrievePublicInfo()
Case $GUI_EVENT_CLOSE
Exit
Case $Edit
EndSwitch
WEnd
当已经构建AutoIt
UDF
?
Use _GetIP()
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <Inet.au3>
Local $hgui, $hIPAddress
$hgui = GUICreate("IP Address Control Clear Example", 150, 100)
$hIPAddress = _GUICtrlIpAddress_Create($hgui, 10, 10)
_GUICtrlIpAddress_Set($hIPAddress, "0.0.0.0")
$Button = GUICtrlCreateButton("Get my IP!", 20, 50, 100)
GUISetState(@SW_SHOW)
; Wait for user to close GUI
Do
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button
Local $PublicIP = _GetIP ()
_GUICtrlIpAddress_ClearAddress( $hIPAddress)
_GUICtrlIpAddress_Set($hIPAddress, $PublicIP)
EndSelect
Until GUIGetMsg() = $GUI_EVENT_CLOSE