#include <EditConstants.au3>
#include <WindowsConstants.au3>
GUICreate("在线英译汉", 400, 300)
$Edit1 = GUICtrlCreateEdit("请在此输入英文", 5, 5, 390, 130, $WS_VSCROLL + $ES_WANTRETURN)
$Bt1 = GUICtrlCreateButton("", 5, 142, 225, 22)
GUICtrlSetData($Bt1, '在线翻译以上英文')
$Bt2 = GUICtrlCreateButton('清空', 230, 142, 80, 22)
$Bt3 = GUICtrlCreateButton('退出', 310, 142, 86, 22)
$Edit2 = GUICtrlCreateEdit("", 5, 170, 390, 105, $WS_VSCROLL + $ES_WANTRETURN)
GUICtrlCreateLabel('Afan - www.autoitx.com', 120, 280, 180, 17)
GUICtrlSetState(-1, 144)
GUISetState()
While 1
Switch GUIGetMsg()
Case - 3, $Bt3
Exit
Case $Bt1
$a = StringRegExpReplace(GUICtrlRead($Edit1), @CR, '%0D%0A')
If $a <> '' Then
GUICtrlSetData($Bt1, '正在提交翻译,请稍候...')
GUICtrlSetState($Bt1, 144)
$sR = StringRegExp(Post($a), 'suggestion>([^<]+)</textarea>', 3)
If @error = 0 Then
$a = StringRegExpReplace($sR[0], '<br><br>', @CRLF)
GUICtrlSetData($Edit2, $a)
Else
MsgBox(48, '出错', '网站貌似改版,读取出错,请联系本人')
EndIf
GUICtrlSetData($Bt1, '在线翻译以上英文')
GUICtrlSetState($Bt1, 80)
Else
MsgBox(48, '注意', '请在上输入框输入英文 ')
EndIf
Case $Bt2
GUICtrlSetData($Edit2, '')
GUICtrlSetData($Edit1, '')
EndSwitch
WEnd
Func Post($Word)
$oHTTP = ObjCreate("Microsoft.xmlhttp")
$oHTTP.Open("Post", "http://translate.google.com/translate_t", False)
$oHTTP.Send("text=" & $Word & "&langpair=en%7Czh-CN&hl=zh-CN&newwindow=1&ie=UTF-8&oe=UTF-8")
$sReturn = BinaryToString($oHTTP.responseBody, 4)
Return $sReturn
EndFunc ;==>Post
貌似翻译网站改版了,修改了下