把你的改一下。顺便自己收藏。谢谢提问。#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
$Form1 = GUICreate("Google翻译", 625, 375, 192, 124)
$Edit1 = GUICtrlCreateEdit("Google翻译结果", 24, 72, 569, 135)
$Edit2 = GUICtrlCreateEdit("其它解释", 24, 210, 569, 135)
$Input1 = GUICtrlCreateInput("请输入待翻译的英文串", 24, 24, 481, 21)
$Button1 = GUICtrlCreateButton("翻译", 528, 24, 65, 21)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
fanyi()
EndSwitch
WEnd
Func fanyi()
$key = GUICtrlRead($Input1)
If $key = "请输入待翻译的英文串" Or $key = "" Then
MsgBox(0, "错误", "请检查输入是否正确")
Else
$oIE = _IECreate("http://translate.google.cn/#en|zh-CN|"&$key,0,0)
Do
$oDiv = 0
_IELoadWait ($oIE)
if @Error then exit
$oDiv = _IEGetObjById($oIE,"suggestion")
$sText = $oDiv.innertext
Until $sText <> "0"
GUICtrlSetData($Edit1,$sText)
GUICtrlSetData($Edit2,"")
$oDiv = 0
$sText = _IEBodyReadText ($oIE)
$sText2 = StringInStr($sText, "查看字典详细内容")
if $sText2 <> 0 then
$sText = StringTrimLeft($sText,$sText2+9)
$sText = StringLeft($sText,StringInStr($sText, "更好的翻译建议")-7)
$sText = StringReplace($sText, "词", "词:")
GUICtrlSetData($Edit2,$sText)
endif
_IEQuit($oIE)
EndIf
EndFunc
|