0

我发现这段代码可以检索 IP 的公共信息,但我希望将此输出写入到我的 Gui 的 EditBox 中。

如何做到这一点。

如果您在 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
4

2 回答 2

0

为什么要在已经内置的情况下使用外部函数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
于 2013-10-06T19:31:05.967 回答
0
#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
于 2013-02-06T00:36:00.593 回答