找回密码
 加入
搜索
查看: 2232|回复: 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 编辑
  1. #include <EditConstants.au3>
  2. #include <WindowsConstants.au3>

  3. GUICreate("在线英译汉", 400, 300)
  4. $Edit1 = GUICtrlCreateEdit("请在此输入英文", 5, 5, 390, 130, $WS_VSCROLL + $ES_WANTRETURN)
  5. $Bt1 = GUICtrlCreateButton("", 5, 142, 225, 22)
  6. GUICtrlSetData($Bt1, '在线翻译以上英文')
  7. $Bt2 = GUICtrlCreateButton('清空', 230, 142, 80, 22)
  8. $Bt3 = GUICtrlCreateButton('退出', 310, 142, 86, 22)
  9. $Edit2 = GUICtrlCreateEdit("", 5, 170, 390, 105, $WS_VSCROLL + $ES_WANTRETURN)
  10. GUICtrlCreateLabel('Afan - www.autoitx.com', 120, 280, 180, 17)
  11. GUICtrlSetState(-1, 144)
  12. GUISetState()

  13. While 1
  14.         Switch GUIGetMsg()
  15.                 Case - 3, $Bt3
  16.                         Exit
  17.                 Case $Bt1
  18.                         $a = StringRegExpReplace(GUICtrlRead($Edit1), @CR, '%0D%0A')
  19.                         If $a <> '' Then
  20.                                 GUICtrlSetData($Bt1, '正在提交翻译,请稍候...')
  21.                                 GUICtrlSetState($Bt1, 144)
  22.                                 $sR = StringRegExp(Post($a), 'suggestion>([^<]+)</textarea>', 3)
  23.                                 If @error = 0 Then
  24.                                         $a = StringRegExpReplace($sR[0], '&lt;br&gt;&lt;br&gt;', @CRLF)
  25.                                         GUICtrlSetData($Edit2, $a)
  26.                                 Else
  27.                                         MsgBox(48, '出错', '网站貌似改版,读取出错,请联系本人')
  28.                                 EndIf
  29.                                 GUICtrlSetData($Bt1, '在线翻译以上英文')
  30.                                 GUICtrlSetState($Bt1, 80)
  31.                         Else
  32.                                 MsgBox(48, '注意', '请在上输入框输入英文 ')
  33.                         EndIf
  34.                 Case $Bt2
  35.                         GUICtrlSetData($Edit2, '')
  36.                         GUICtrlSetData($Edit1, '')
  37.         EndSwitch
  38. WEnd

  39. Func Post($Word)
  40.         $oHTTP = ObjCreate("Microsoft.xmlhttp")
  41.         $oHTTP.Open("Post", "http://translate.google.com/translate_t", False)
  42.         $oHTTP.Send("text=" & $Word & "&langpair=en%7Czh-CN&hl=zh-CN&newwindow=1&ie=UTF-8&oe=UTF-8")
  43.         $sReturn = BinaryToString($oHTTP.responseBody, 4)
  44.         Return $sReturn
  45. 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, 2026-9-21 00:03 , Processed in 0.102226 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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