找回密码
 加入
搜索
查看: 2160|回复: 6

■■如何实现调用IE页面里面的功能吗?■■

[复制链接]
发表于 2009-11-11 18:51:03 | 显示全部楼层 |阅读模式
本帖最后由 871224 于 2009-11-11 21:51 编辑

例如做一个翻译的GUI
URL:http://translate.google.cn/trans ... mp;history_state0=#
是Google提供的一个翻译网页

思路大概是:在GUI里输入要翻译的文字,点击“翻译”,其实就是往URL页面里面输入要翻译的内容,然后提取翻译之后的内容,显示在GUI上。

最好还能把翻译语种的那个select也搬到GUI上。。。
发表于 2009-11-12 09:17:17 | 显示全部楼层
#Region - Demo
_GoogleToMsgBox("Hello World", "en", "en")
_GoogleToMsgBox("Hello World", "en", "ja")
_GoogleToMsgBox("Hello World", "en", "es")
_GoogleToMsgBox("Hello World", "en", "it")
_GoogleToMsgBox("Hello World", "en", "zh-cn")
_GoogleToMsgBox("Hello World", "en", "ar")
_GoogleToMsgBox("Hello World", "en", "bg")
_GoogleToMsgBox("Hello World", "en", "fr")
_GoogleToMsgBox("Hello World", "en", "de")
_GoogleToMsgBox(InputBox("在线快速翻译", "请输入您要翻译的内容", ""), "en", "zh-cn")
   
    Func _GoogleToMsgBox($sText, $sFrom, $sTo)
        Msgbox(4096, "在线快速翻译 [" & $sFrom & ":" & $sTo & "]", $sText & @TAB & @TAB & @TAB & @CRLF & @CRLF & _GoogleTranslate($sText, $sFrom, $sTo))
    EndFunc
#EndRegion


Func _GoogleTranslate($sText, $sFrom = "en", $sTo = "zh-cn")
    Local Const $FileName = "Translation.jsn"
    Local Const $Pattern = '"translatedText":"([^"]+)"'
    Local $GoogleURL = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=%s&langpair=%s%%7C%s"
    Local $File
   
    $GoogleURL = StringFormat($GoogleURL, $sText, $sFrom, $sTo)
   
    If Not InetGet($GoogleURL, $FileName, 1) Then Return SetError(1, 0, 0)
        
    $File = FileOpen($FileName, 4)
    FileGetSize($FileName)
    $Translation = FileRead($File, FileGetSize($FileName))
    FileClose($File)
    FileDelete($FileName)
   
    $Translation = BinaryToString($Translation, 4)

    If StringRegExp($Translation , $Pattern) Then
        $Translation = StringRegExp($Translation , $Pattern, 1)
        $Translation = $Translation[0]
        
        Return $Translation
    EndIf
EndFunc
 楼主| 发表于 2009-11-12 09:56:12 | 显示全部楼层
pcbar 大侠
你提供的代码,我研究了半天,大部分还是看不懂
http://ajax.googleapis.com/ajax/ ... p;langpair=%s%%7C%s这个不是一个页面吧。
能不能 根据 页面 设计代码呢?
 楼主| 发表于 2009-11-12 09:57:46 | 显示全部楼层
pcbar 大侠
你提供的代码,我研究了半天,大部分还是看不懂
http://ajax.googleapis.com/ajax/ ... p;langpair=%s%%7C%s这个不是一个页面吧。
能不能 根据 页面 设计代码呢? 这样我能学习到更多知识,能活用到其他页面了
发表于 2009-11-12 14:36:59 | 显示全部楼层
4# 871224

如果要别人完全根据你的要求设计代码,这里有专门的交易区
人家已经给你例子了,你为什么不自己仔细学习灵活应用呢?
如果出现解决不了的新问题,再单独拿出来提问就是了
 楼主| 发表于 2009-11-12 18:59:01 | 显示全部楼层

额。。就是把IE上面的东西搬到GUI上。。怎么搬的。。。
发表于 2009-12-19 03:42:26 | 显示全部楼层
新手看起来太难了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-22 15:29 , Processed in 0.079812 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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