找回密码
 加入
搜索
查看: 1973|回复: 5

如何实现在GUI上输入内容拿到IE里面的返回结果

[复制链接]
发表于 2009-11-12 23:27:01 | 显示全部楼层 |阅读模式
请问路过的大侠,如何在GUI里面输入一个内容,拿到IE页面(一定是可以打开的IE页面,函数不算)的返回结果,如翻译单词

会的教下,先谢谢了
 楼主| 发表于 2009-11-13 08:53:58 | 显示全部楼层
哪位大侠 教下呀
 楼主| 发表于 2009-11-14 14:27:26 | 显示全部楼层
哪位大侠教下
 楼主| 发表于 2009-11-15 14:05:07 | 显示全部楼层
发表于 2009-11-15 21:55:20 | 显示全部楼层
本帖最后由 afan 于 2009-11-17 15:32 编辑
#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
貌似翻译网站改版了,修改了下 http://www.autoitx.com/forum.php?mod=viewthread&tid=10934

评分

参与人数 2金钱 +1 贡献 +1 收起 理由
871224 + 1 厉害!
ebhb + 1 不错。

查看全部评分

发表于 2009-11-15 22:22:44 | 显示全部楼层
不错,收藏了。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-22 17:37 , Processed in 0.075451 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表