zerozha 发表于 2009-2-26 15:11:39

_IECreate的参数问题

#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#cs
函数名:_GoogleWeatherSearchCN
功能:利用google.cn搜索中国城市的天气预报
入口参数:城市名称中文或者拼音,如:"合肥"或者"hefei",例子_GoogleWeatherSearchCN("合肥")
出口参数:包含天气信息的html代码。失败返回""

作者:zerozha@qq.com
QQ:451450451
版本:0.1
#ce
Func _GoogleWeatherSearchCN($s_q)
$Url = 'http://www.google.cn/search?q=tq%20' & $s_q
$oIE = _IECreate($Url, 0, 0, 1, 0)
If @error Then
$sHTML = _IEBodyReadHTML($oIE)
$sHTML = StringRegExpReplace($sHTML, "\r\n", "")
$TmpHTML = StringRegExp($sHTML, "</A></DIV></TD></TR>(.*?)</TBODY></TABLE></DIV><SCRIPT>", 1)
If @error Then
   $city = StringRegExp($sHTML, "<FONT color=#cc0033>(.*?)</FONT>", 1)
   $tmptext = StringReplace($TmpHTML, "/images", "http://www.google.cn/images")
   $text = $city & "<table>" & $tmptext & "</table>"
Else
   MsgBox(8208, "输入错误", "请输入城市中文名称或拼音")
   $text = ""
EndIf
Else
$text = ""
EndIf
Return $text
EndFunc   ;==>_GoogleWeatherSearchCN


这是我写的一个利用google搜索查询天气的函数,有个小问题,没有解决。
$oIE = _IECreate($Url, 0, 0, 1, 0)
这句参数明明是隐藏ie,为什么不行呢?老是弹出ie查询的窗口。

zerozha 发表于 2009-2-26 15:15:57

这是一个例子,界面直接用了论坛里一位哥们的代码。

#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Icon=C:\Documents and Settings\Administrator\桌面\googleweather.ico
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

#include <_GoogleWeatherSearch.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Google天气查询", 575, 570, 193, 125)
$Group1 = GUICtrlCreateGroup("", 8, 8, 551, 49)
$Label1 = GUICtrlCreateLabel("城 市:", 48, 24, 76, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$Button1 = GUICtrlCreateButton("搜索", 376, 24, 75, 24, 0)
$Input1 = GUICtrlCreateInput("请输入城市中文名称或拼音", 136, 24, 225, 24)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;封闭组框
$oShell = ObjCreate("Shell.Explorer.2")
$GUIActiveX = GUICtrlCreateObj($oShell, 8, 70, 558, 480)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUISetState() ;Show GUI

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

                Case $Button1
                        $s_q = GUICtrlRead($Input1)
                        $text = _GoogleWeatherSearchCN($s_q)
                        If $text = "" Then
                                MsgBox(8208, "输入错误", "请输入城市中文名称或拼音,并确认网络链接正常")
                        EndIf
                        If FileExists(@TempDir & "\Weathertemp.htm") Then
                                FileDelete(@TempDir & "\Weathertemp.htm")
                        EndIf
                        FileWrite(@TempDir & "\Weathertemp.htm", $text)
                        $oShell.navigate(@TempDir & "\Weathertemp.htm")
        EndSwitch
WEnd
GUIDelete()


页: [1]
查看完整版本: _IECreate的参数问题