871224 发表于 2009-11-11 18:51:03

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

本帖最后由 871224 于 2009-11-11 21:51 编辑

例如做一个翻译的GUI
URL:http://translate.google.cn/translate_t?prev=hp&hl=zh-CN&js=y&text=&file=&sl=en&tl=zh-CN&history_state0=#
是Google提供的一个翻译网页

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

最好还能把翻译语种的那个select也搬到GUI上。。。:face (9):

pcbar 发表于 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
      
      Return $Translation
    EndIf
EndFunc

871224 发表于 2009-11-12 09:56:12

pcbar 大侠
你提供的代码,我研究了半天,大部分还是看不懂:face (18):
http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=%s&langpair=%s%%7C%s这个不是一个页面吧。
能不能 根据 页面 设计代码呢?

871224 发表于 2009-11-12 09:57:46

pcbar 大侠
你提供的代码,我研究了半天,大部分还是看不懂:face (18):
http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=%s&langpair=%s%%7C%s这个不是一个页面吧。
能不能 根据 页面 设计代码呢? 这样我能学习到更多知识,能活用到其他页面了:face (22):

wisly 发表于 2009-11-12 14:36:59

4# 871224

如果要别人完全根据你的要求设计代码,这里有专门的交易区
人家已经给你例子了,你为什么不自己仔细学习灵活应用呢?
如果出现解决不了的新问题,再单独拿出来提问就是了

871224 发表于 2009-11-12 18:59:01

:face (2):
额。。就是把IE上面的东西搬到GUI上。。怎么搬的。。。

qq123123 发表于 2009-12-19 03:42:26

新手看起来太难了
页: [1]
查看完整版本: ■■如何实现调用IE页面里面的功能吗?■■