Jump to content

InetGet not working properly


Recommended Posts

So this function is set on a loop for every ten minutes. On first run, everything works flawlessly. But when the loop is activated it doesn't re-download images, even if they've changes.

Func _GetOverViewImages()
    Global $sSource = BinaryToString(InetRead($Url))
    $Image1 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 1.*-->", 1)
    $Image2 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 2.*-->", 1)
    $Image3 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 3.*-->", 1)
    $Image4 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 4.*-->", 1)
For $i = 1 To 4
    If $i = 1 Then
    $OverViewImage[1] = $Image1[0]
ElseIf $i = 2 Then
    $OverViewImage[2] = $Image2[0]
ElseIf $i = 3 Then
    $OverViewImage[3] = $Image3[0]
ElseIf $i = 4 Then
    $OverViewImage[4] = $Image4[0]
EndIf
Next
For $i = 1 To 4
    If $i = 1 Then
        FileDelete(@ScriptDir & "ImagesImage1.png")
        $RightNowImage = InetGet($OverViewImage[1], @ScriptDir & "ImagesImage1.png")
EndIf
    If $i = 2 Then
        FileDelete(@ScriptDir & "ImagesImage2.png")
        $TodayImage = InetGet($OverViewImage[2], @ScriptDir & "ImagesImage2.png")
EndIf
    If $i = 3 Then
        FileDelete(@ScriptDir & "ImagesImage3.png")
        $TonightImage = InetGet($OverViewImage[3], @ScriptDir & "ImagesImage3.png")
EndIf
    If $i = 4 Then
        FileDelete(@ScriptDir & "ImagesImage4.png")
        $TomorrowImage = InetGet($OverViewImage[4], @ScriptDir & "ImagesImage4.png")
    EndIf
Next
EndFunc

Did I do something wrong in here, or what? I can't think of why it wouldn't be working. All I do to re-call the func is I added an Adlib to call the function.

Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Hmm. I changed both of those but it didn't seem to fix the problem.

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Here is the Widget that actually displays all the data/images

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Icon.ico
#AutoIt3Wrapper_Res_Comment=Beta testing
#AutoIt3Wrapper_Res_Description=Pulls data from Weather.com
#AutoIt3Wrapper_Res_Fileversion=1.3.0.0
#AutoIt3Wrapper_Res_LegalCopyright=RobertSSoftware
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#Include <WinAPI.au3>
#include "WeatherUDF.au3"
#include <array.au3>
Opt("GUIOnEventMode", 1)
Global $Statuses = IniReadSection("Statuses.ini", "Status")
Global $XY = IniReadSection("Statuses.ini", "XY")
Global $ZipCode, $GUI, $hgraphic, $himage, $RightNowGui, $TodayGui, $TonightGui, $TomorrowGui, $RefreshTime
$ZipCode = InputBox("Zip code", "Please input your zip code")
$ZipCode2 = "http://www.zip-codes.com/zip-code/" & $ZipCode
Global $sSource = BinaryToString(InetRead($ZipCode2))
$City = StringRegExp($sSource,'(?i)(?s)<a href="/city/(.*?)-(.*?).asp',1)
$State = StringRegExp($sSource,'(?i)(?s)<a href="/state(.*?)/(.*?).asp',1)
$Url = 'http://www.weather.com/weather/today/' & $City[1] & '+' & $State[1] & '+' & $Zipcode
Global $h_Desktop_SysListView32
_GetDesktopHandle()
$Width = @DesktopWidth
$Height = @DesktopHeight
_GetOverViewTimes()
    _GetOverViewTemperature()
    _GetOverViewImages()
    _GetOverViewStatus()
$RefreshRate = InputBox("Refresh Rate", "Please input a numerical value of 1-60." & @CRLF & @CRLF & "1 being one minute, 60 being an hour." & @CRLF & @CRLF & "This will be your refresh time for the Weather Widget","","",350,250)
If $RefreshRate = 0 Then
  MsgBox(48,"Refresh Rate", "You've selected to have no refresh rate. To refresh the Weather Widget you may right click on it and select 'Refresh'")
  _RightNowGUI()
Else
For $i = 1 To $RefreshRate Step +1
  $RefreshTime += 60000
Next
AdlibRegister("_Refresh", $RefreshTime)
_RightNowGUI()
EndIf
Func _RightNowGUI()
    GuiDelete($RightNowGUI)
    GuiDelete($TodayGUI)
    GuiDelete($TonightGUI)
    GuiDelete($TomorrowGUI)
    $RightNowGUI = GUICreate("", 150, 300, $Width-151, $Height-600, BitOR($WS_POPUP,$WS_BORDER), Default, WinGetHandle(AutoItWinGetTitle()))
    GuiSetFont(13)
    GUICtrlSetDefColor(0xFFFFFF)
    GUISetBkColor(0x000000)
    WinSetTrans($RightNowGUI,"",200)
    GuiSetState()
    GuiCtrlCreateLabel($OverViewTime[1],38,10,200,50)
For $i = 1 To $Statuses[0][0]
  If $Statuses[$i][1] = $OverViewStatus[1] Then
   For $i = 1 To $XY[0][0]
    If $XY[$i][0] = $OverViewStatus[1] Then
     $Split = StringSplit($XY[$i][1],",")
    EndIf
   Next
   GuiCtrlCreateLabel($OverViewStatus[1],$Split[1],$Split[2])
   GuiCtrlSetFont(-1,7.8)
  EndIf
  Next
    GuiCtrlCreateLabel("Temperature",35,230,200,40)
    GuiCtrlCreateLabel($OverViewTemp[1] & "°F",64,250,200,40)
    $ContextMenu = GuiCtrlCreateContextMenu()
    $RightNowItem = GuiCtrlCreateMenuItem($OverViewTime[1], $ContextMenu)
    GUICtrlSetOnEvent($RightNowItem, "_RightNowGUI")
    $TodayItem = GuiCtrlCreateMenuItem($OverViewTime[2], $ContextMenu)
    GUICtrlSetOnEvent($TodayItem, "_TodayGUI")
    $TonightItem = GuiCtrlCreateMenuItem($OverViewTime[3], $ContextMenu)
    GUICtrlSetOnEvent($TonightItem, "_TonightGUI")
    $TomorrowItem = GuiCtrlCreateMenuItem($OverViewTime[4], $ContextMenu)
    GUICtrlSetOnEvent($TomorrowItem, "_TomorrowGUI")
    $RefreshItem = GuiCtrlCreateMenuItem("Refresh", $ContextMenu)
    GUICtrlSetOnEvent($RefreshItem, "_Refresh")
    $ExitItem = GuiCtrlCreateMenuItem("Close", $ContextMenu)
    GUICtrlSetOnEvent($ExitItem, "_Exit")
    DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $RightNowGUI, "hwnd", $h_Desktop_SysListView32)
    _GDIPlus_StartUp()
    $hImage   = _GDIPlus_ImageLoadFromFile(@ScriptDir & "/Images/Image1.png")
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($RightNowGUI)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 13, 35, 130,160)
EndFunc
Func _TodayGUI()
    GuiDelete($RightNowGUI)
    GuiDelete($TodayGUI)
    GuiDelete($TonightGUI)
    GuiDelete($TomorrowGUI)
    $TodayGUI = GUICreate("", 150, 300, $Width-151, $Height-600, BitOR($WS_POPUP,$WS_BORDER), Default, WinGetHandle(AutoItWinGetTitle()))
    GuiSetFont(13)
    GUICtrlSetDefColor(0xFFFFFF)
    GUISetBkColor(0x000000)
    WinSetTrans($TodayGui,"",200)
     GuiSetState()
For $i = 1 To $Statuses[0][0]
  If $Statuses[$i][1] = $OverViewStatus[2] Then
   For $i = 1 To $XY[0][0]
    If $XY[$i][0] = $OverViewStatus[2] Then
     $Split = StringSplit($XY[$i][1],",")
    EndIf
   Next
   GuiCtrlCreateLabel($OverViewStatus[2],$Split[1],$Split[2])
   GuiCtrlSetFont(-1,7.8)
  EndIf
  Next
If $OverViewTime[2] = "Today" Then
    GuiCtrlCreateLabel($OverViewTime[2], 48,10,200,50)
ElseIf $OverViewTime[2] = "Tonight" Then
GuiCtrlCreateLabel($OverViewTime[2], 45,10,200,50)
Else
MsgBox(0, "Test", "Error")
EndIf
    GuiCtrlCreateLabel("Temperature",35,230,200,40)
    GuiCtrlCreateLabel($OverViewTemp[2] & "°F",64,250,200,40)
     $ContextMenu = GuiCtrlCreateContextMenu()
    $RightNowItem = GuiCtrlCreateMenuItem($OverViewTime[1], $ContextMenu)
    GUICtrlSetOnEvent($RightNowItem, "_RightNowGUI")
    $TodayItem = GuiCtrlCreateMenuItem($OverViewTime[2], $ContextMenu)
    GUICtrlSetOnEvent($TodayItem, "_TodayGUI")
    $TonightItem = GuiCtrlCreateMenuItem($OverViewTime[3], $ContextMenu)
    GUICtrlSetOnEvent($TonightItem, "_TonightGUI")
    $TomorrowItem = GuiCtrlCreateMenuItem($OverViewTime[4], $ContextMenu)
    GUICtrlSetOnEvent($TomorrowItem, "_TomorrowGUI")
    $RefreshItem = GuiCtrlCreateMenuItem("Refresh", $ContextMenu)
    GUICtrlSetOnEvent($RefreshItem, "_Refresh")
    $ExitItem = GuiCtrlCreateMenuItem("Close", $ContextMenu)
    GUICtrlSetOnEvent($ExitItem, "_Exit")
    DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $RightNowGUI, "hwnd", $h_Desktop_SysListView32)
     _GDIPlus_StartUp()
    $hImage   = _GDIPlus_ImageLoadFromFile(@ScriptDir & "/Images/Image2.png")
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($TodayGUI)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 13, 35, 130,160)
EndFunc
Func _TonightGUI()
    GuiDelete($RightNowGUI)
    GuiDelete($TodayGUI)
    GuiDelete($TonightGUI)
    GuiDelete($TomorrowGUI)
    $TonightGUI = GUICreate("", 150, 300, $Width-151, $Height-600, BitOR($WS_POPUP,$WS_BORDER), Default, WinGetHandle(AutoItWinGetTitle()))
    GuiSetFont(13)
    GUICtrlSetDefColor(0xFFFFFF)
    GUISetBkColor(0x000000)
    WinSetTrans($TonightGui,"",200)
GuiSetState()
For $i = 1 To $Statuses[0][0]
  If $Statuses[$i][1] = $OverViewStatus[3] Then
   For $i = 1 To $XY[0][0]
    If $XY[$i][0] = $OverViewStatus[3] Then
     $Split = StringSplit($XY[$i][1],",")
    EndIf
   Next
   GuiCtrlCreateLabel($OverViewStatus[3],$Split[1],$Split[2])
   GuiCtrlSetFont(-1,7.8)
  EndIf
  Next
If $OverViewTime[3] = "Tonight" Then
    GuiCtrlCreateLabel($OverViewTime[3], 48,10,200,50)
ElseIf $OverViewTime[3] = "Tomorrow" Then
GuiCtrlCreateLabel($OverViewTime[3], 43,10,200,50)
Else
MsgBox(0, "Test", "Error")
EndIf
    GuiCtrlCreateLabel("Temperature",35,230,200,40)
    GuiCtrlCreateLabel($OverViewTemp[3] & "°F",64,250,200,40)
    $ContextMenu = GuiCtrlCreateContextMenu()
    $RightNowItem = GuiCtrlCreateMenuItem($OverViewTime[1], $ContextMenu)
    GUICtrlSetOnEvent($RightNowItem, "_RightNowGUI")
    $TodayItem = GuiCtrlCreateMenuItem($OverViewTime[2], $ContextMenu)
    GUICtrlSetOnEvent($TodayItem, "_TodayGUI")
    $TonightItem = GuiCtrlCreateMenuItem($OverViewTime[3], $ContextMenu)
    GUICtrlSetOnEvent($TonightItem, "_TonightGUI")
    $TomorrowItem = GuiCtrlCreateMenuItem($OverViewTime[4], $ContextMenu)
    GUICtrlSetOnEvent($TomorrowItem, "_TomorrowGUI")
    $RefreshItem = GuiCtrlCreateMenuItem("Refresh", $ContextMenu)
    GUICtrlSetOnEvent($RefreshItem, "_Refresh")
    $ExitItem = GuiCtrlCreateMenuItem("Close", $ContextMenu)
    GUICtrlSetOnEvent($ExitItem, "_Exit")
    DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $RightNowGUI, "hwnd", $h_Desktop_SysListView32)
     _GDIPlus_StartUp()
    $hImage   = _GDIPlus_ImageLoadFromFile(@ScriptDir & "/Images/Image3.png")
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($TonightGUI)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 13, 35, 130,160)
EndFunc
Func _TomorrowGUI()
    GuiDelete($RightNowGUI)
    GuiDelete($TodayGUI)
    GuiDelete($TonightGUI)
    GuiDelete($TomorrowGUI)
    $TomorrowGUI = GUICreate("", 150, 300, $Width-151, $Height-600, BitOR($WS_POPUP,$WS_BORDER), Default, WinGetHandle(AutoItWinGetTitle()))
    GuiSetFont(13)
    GUICtrlSetDefColor(0xFFFFFF)
    GUISetBkColor(0x000000)
    WinSetTrans($TomorrowGui,"",200)
GuiSetState()
For $i = 1 To $Statuses[0][0]
  If $Statuses[$i][1] = $OverViewStatus[4] Then
   For $i = 1 To $XY[0][0]
    If $XY[$i][0] = $OverViewStatus[4] Then
     $Split = StringSplit($XY[$i][1],",")
    EndIf
   Next
   GuiCtrlCreateLabel($OverViewStatus[4],$Split[1],$Split[2])
   GuiCtrlSetFont(-1,7.8)
  EndIf
  Next
If $OverViewTime[4] = "Tomorrow" Then
    GuiCtrlCreateLabel($OverViewTime[4], 45,10,200,50)
ElseIf $OverViewTime[4] = "Tomorrow Night" Then
GuiCtrlCreateLabel($OverViewTime[4], 22,10,200,50)
EndIf
    GuiCtrlCreateLabel("Temperature",35,230,200,40)
    GuiCtrlCreateLabel($OverViewTemp[4] & "°F",64,250,200,40)
    $ContextMenu = GuiCtrlCreateContextMenu()
    $RightNowItem = GuiCtrlCreateMenuItem($OverViewTime[1], $ContextMenu)
    GUICtrlSetOnEvent($RightNowItem, "_RightNowGUI")
    $TodayItem = GuiCtrlCreateMenuItem($OverViewTime[2], $ContextMenu)
    GUICtrlSetOnEvent($TodayItem, "_TodayGUI")
    $TonightItem = GuiCtrlCreateMenuItem($OverViewTime[3], $ContextMenu)
    GUICtrlSetOnEvent($TonightItem, "_TonightGUI")
    $TomorrowItem = GuiCtrlCreateMenuItem($OverViewTime[4], $ContextMenu)
    GUICtrlSetOnEvent($TomorrowItem, "_TomorrowGUI")
    $RefreshItem = GuiCtrlCreateMenuItem("Refresh", $ContextMenu)
    GUICtrlSetOnEvent($RefreshItem, "_Refresh")
    $ExitItem = GuiCtrlCreateMenuItem("Close", $ContextMenu)
    GUICtrlSetOnEvent($ExitItem, "_Exit")
    DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $RightNowGUI, "hwnd", $h_Desktop_SysListView32)
_GDIPlus_StartUp()
    $hImage   = _GDIPlus_ImageLoadFromFile(@ScriptDir & "/Images/Image4.png")
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($TomorrowGUI)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 13, 35, 130,160)
EndFunc
Func _Quit()
    Exit
EndFunc
While 1
    Sleep(10)
WEnd

Func _GetDesktopHandle()
    $h_Desktop_SysListView32 = 0
    Local Const $hDwmApiDll = DllOpen("dwmapi.dll")
    Local $sChkAero = DllStructCreate("int;")
    DllCall($hDwmApiDll, "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($sChkAero))
    Local $aero_on = DllStructGetData($sChkAero, 1)
    If Not $aero_on Then
        $h_Desktop_SysListView32 = WinGetHandle("Program Manager")
        Return 1
    Else
        Local $hCBReg = DllCallbackRegister("_GetDesktopHandle_EnumChildWinProc", "hwnd", "hwnd;lparam")
        If $hCBReg = 0 Then Return SetError(2)
        DllCall("user32.dll", "int", "EnumChildWindows", "hwnd", _WinAPI_GetDesktopWindow(), "ptr", DllCallbackGetPtr($hCBReg), "lparam", 101)
        Local $iErr = @error
        DllCallbackFree($hCBReg)
        If $iErr Then
            Return SetError(3, $iErr, "")
        EndIf
        Return 2
    EndIf
EndFunc
Func _Refresh()
_GetOverViewTimes()
    _GetOverViewTemperature()
    _GetOverViewImages()
    _GetOverViewStatus()
    _RightNowGUI()
EndFunc
Func _Exit()
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ShutDown()
    Exit
EndFunc

And here is the UDF that pulls the data/images

#include <array.au3>
#Include-Once
Global $OverViewTemp[10], $OverViewImage[5], $OverViewStatus[5], $OverViewTime[5]
Global $Url, $RightNowImage, $TodayImage, $TonightImage, $TomorrowImage
Func _GetOverViewTimes()
Global $sSource = BinaryToString(InetRead($Url),1)
For $i = 1 To 5
If $i = 1 Then
  $Time1 = StringRegExp($sSource,'(?i)(?s)<span class="twc-forecast-when twc-none">(.*?)</span>',1)
ElseIf $i = 2 Then
  $Time2 = StringRegExp($sSource,'(?i)(?s)<td class="twc-col-2 twc-forecast-when">(.*?)</td>',1)
ElseIf $i = 3 Then
  $Time3 = StringRegExp($sSource,'(?i)(?s)<td class="twc-col-3 twc-forecast-when">(.*?)</td>',1)
ElseIf $i = 4 Then
  $Time4 = StringRegExp($sSource,'(?i)(?s)<td class="twc-col-4 twc-forecast-when">(.*?)</td>',1)
EndIf
Next
For $i = 1 To 4
If $i = 1 Then
$OverViewTime[1] = $Time1[0]
ElseIf $i = 2 Then
$OverViewTime[2] = $Time2[0]
ElseIf $i = 3 Then
$OverViewTime[3] = $Time3[0]
ElseIf $i = 4 Then
$OverViewTime[4] = $Time4[0]
EndIf
Next
EndFunc
Func _GetOverViewTemperature()
Global $sSource = BinaryToString(InetRead($Url),1)
For $i = 1 To 5
If $i = 1 Then
  $Temp1 = StringRegExp($sSource,'(?i)(?s)<td class="twc-col-1 twc-forecast-temperature"><strong>(.*?)&deg',1)
ElseIf $i = 2 Then
  $Temp2 = StringRegExp($sSource,'(?i)(?s)<td class="twc-col-2 twc-forecast-temperature"><strong>(.*?)&deg',1)
ElseIf $i = 3 Then
  $Temp3 = StringRegExp($sSource,'(?i)(?s)<td class="twc-col-3 twc-forecast-temperature"><strong>(.*?)&deg',1)
ElseIf $i = 4 Then
  $Temp4 = StringRegExp($sSource,'(?i)(?s)<td class="twc-col-4 twc-forecast-temperature"><strong>(.*?)&deg',1)
EndIf
Next
For $i = 1 To 4
If $i = 1 Then
$OverViewTemp[1] = $Temp1[0]
ElseIf $i = 2 Then
$OverViewTemp[2] = $Temp2[0]
ElseIf $i = 3 Then
$OverViewTemp[3] = $Temp3[0]
ElseIf $i = 4 Then
$OverViewTemp[4] = $Temp4[0]
EndIf
Next
EndFunc
Func _GetOverViewImages()
Global $sSource = BinaryToString(InetRead($Url),16)
$Image1 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 1.*-->", 1)
$Image2 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 2.*-->", 1)
$Image3 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 3.*-->", 1)
$Image4 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 4.*-->", 1)
For $i = 1 To 4
If $i = 1 Then
$OverViewImage[1] = $Image1[0]
ElseIf $i = 2 Then
$OverViewImage[2] = $Image2[0]
ElseIf $i = 3 Then
$OverViewImage[3] = $Image3[0]
ElseIf $i = 4 Then
$OverViewImage[4] = $Image4[0]
EndIf
Next
For $i = 1 To 4
If $i = 1 Then
  FileDelete(@ScriptDir & "ImagesImage1.png")
  $RightNowImage = InetGet($OverViewImage[1], @ScriptDir & "ImagesImage1.png",1)
EndIf
If $i = 2 Then
  FileDelete(@ScriptDir & "ImagesImage2.png")
  $TodayImage = InetGet($OverViewImage[2], @ScriptDir & "ImagesImage2.png",1)
EndIf
If $i = 3 Then
  FileDelete(@ScriptDir & "ImagesImage3.png")
  $TonightImage = InetGet($OverViewImage[3], @ScriptDir & "ImagesImage3.png",1)
EndIf
If $i = 4 Then
  FileDelete(@ScriptDir & "ImagesImage4.png")
  $TomorrowImage = InetGet($OverViewImage[4], @ScriptDir & "ImagesImage4.png",1)
EndIf
Next
EndFunc
Func _GetOverViewStatus()
Global $sSource = BinaryToString(InetRead($Url),1)
For $i = 1 To 4
If $i = 1 Then
  $Status1Start = StringRegExp($sSource,'(?i)(?s)<td class="twc-col-1(.*?)<!-- Column 1 -->',1)
  $Status1 = StringRegExp($Status1Start[0],'(?i)(?s)alt="(.*?)"',1)
ElseIf $i = 2 Then
  $Status2 = StringRegExp($sSource,'(?i)(?s)<td class="twc-col-2 ">(.*?)</td>',1)
ElseIf $i = 3 Then
  $Status3 = StringRegExp($sSource,'(?i)(?s)<td class="twc-col-3 ">(.*?)</td>',1)
ElseIf $i = 4 Then
  $Status4 = StringRegExp($sSource,'(?i)(?s)<td class="twc-col-4 ">(.*?)</td>',1)
EndIf
Next
For $i = 1 To 4
If $i = 1 Then
$OverViewStatus[1] = $Status1[0]
ElseIf $i = 2 Then
$OverViewStatus[2] = $Status2[0]
ElseIf $i = 3 Then
$OverViewStatus[3] = $Status3[0]
ElseIf $i = 4 Then
$OverViewStatus[4] = $Status4[0]
EndIf
Next
EndFunc

Add a folder where the Widget script is located labeled Images

And create an INI with the name "Statuses.ini" and add the following

[Status]
1=Partly Cloudy
2=Isolated T-Storms
3=Mostly Cloudy
4=Mostly Sunny
5=Clear
6=Mostly Clear
7=Sunny
8=Rain / Thunder
9=Scattered T-Storms
10=Clouds Early / Clearing Late
11=Cloudy
12=Few Showers
13=Showers
14=PM T-Storms
15=Scattered Showers
16=Snow Shower
17=AM Snow Showers
18=Showers / Wind
19=Scattered Showers / Wind
20=Rain / Snow Showers
21=Scattered Snow Showers
22=AM Clouds / PM Sun
23=T-Showers
24=Light Rain
25=Showers in the Vicinity
26=T-Storm
[XY]
Partly Cloudy=45,200
Isolated T-Storms=37,200
Mostly Cloudy=45,200
Mostly Sunny=47,200
Clear=63,200
Mostly Clear=48,200
Sunny=63,200
Rain / Thunder=41,200
Scattered T-Storms=34,200
Clouds Early / Clearing Late=12,200
Cloudy=61,200
Few Showers=47,200
Showers=58,200
PM T-Storms=47,200
Scattered Showers=36,200
Snow Shower=47,200
AM Snow Showers=35,200
Showers / Wind=41,200
Scattered Showers / Wind=18,200
Rain / Snow Showers=30,200
Scattered Snow Showers=18,200
AM Clouds / PM Sun=31,200
T-Showers=52,200
Light Rain=52,200
Showers in the Vicinity=26,200
T-Storm=58,200

This will result in a complete working code. But once you refresh it and the images have changed on Weather.com it doesn't show on the GUI.

And

Global $sSource = BinaryToString(InetRead($Url),16)
was tested with a 1, not a 16 at first. Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Maybe your URL is wrong. For me this code it works well (of course, it must exist in @ScriptDir a directory named "Images"):

Global $Url = 'http://www.weather.com/weather/today/Phoenix+Arizona+85001'
Global $OverViewImage[5]

For $Index = 1 To 5
    _GetOverViewImages()
    Sleep(5000)
Next

Func _GetOverViewImages()
    Global $sSource = BinaryToString(InetRead($Url))
    $Image1 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 1.*-->", 1)
    $Image2 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 2.*-->", 1)
    $Image3 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 3.*-->", 1)
    $Image4 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 4.*-->", 1)
    For $i = 1 To 4
        If $i = 1 Then
            $OverViewImage[1] = $Image1[0]
        ElseIf $i = 2 Then
            $OverViewImage[2] = $Image2[0]
        ElseIf $i = 3 Then
            $OverViewImage[3] = $Image3[0]
        ElseIf $i = 4 Then
            $OverViewImage[4] = $Image4[0]
        EndIf
    Next
    For $i = 1 To 4
        If $i = 1 Then
            FileDelete(@ScriptDir & "ImagesImage1.png")
            $RightNowImage = InetGet($OverViewImage[1], @ScriptDir & "ImagesImage1.png",1)
        EndIf
        If $i = 2 Then
            FileDelete(@ScriptDir & "ImagesImage2.png")
            $TodayImage = InetGet($OverViewImage[2], @ScriptDir & "ImagesImage2.png",1)
        EndIf
        If $i = 3 Then
            FileDelete(@ScriptDir & "ImagesImage3.png")
            $TonightImage = InetGet($OverViewImage[3], @ScriptDir & "ImagesImage3.png",1)
        EndIf
        If $i = 4 Then
            FileDelete(@ScriptDir & "ImagesImage4.png")
            $TomorrowImage = InetGet($OverViewImage[4], @ScriptDir & "ImagesImage4.png",1)
        EndIf
    Next
EndFunc
Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

If the URL is wrong, how could it pull the data at first but not at refresh?

And yes, that would work, but the question is would it update it if the data changes without closing and re-running the script?

Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Please run the script and take a look in directory images. Here looks like files are deleted and get new images.

This code proves that the function works well but I cannot tell you ifyou have other bug in your script:

Global $Url = 'http://www.weather.com/weather/today/Phoenix+Arizona+85001'
Global $OverViewImage[5]

_GetOverViewImages()
$Url = 'http://www.weather.com/weather/today/Fort Shafter+Hawaii+96858'
_GetOverViewImages()

Func _GetOverViewImages()
    Global $sSource = BinaryToString(InetRead($Url))
    $Image1 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 1.*-->", 1)
    $Image2 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 2.*-->", 1)
    $Image3 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 3.*-->", 1)
    $Image4 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 4.*-->", 1)
    For $i = 1 To 4
        If $i = 1 Then
            $OverViewImage[1] = $Image1[0]
        ElseIf $i = 2 Then
            $OverViewImage[2] = $Image2[0]
        ElseIf $i = 3 Then
            $OverViewImage[3] = $Image3[0]
        ElseIf $i = 4 Then
            $OverViewImage[4] = $Image4[0]
        EndIf
    Next
    For $i = 1 To 4
        If $i = 1 Then
            FileDelete(@ScriptDir & "ImagesImage1.png")
            $RightNowImage = InetGet($OverViewImage[1], @ScriptDir & "ImagesImage1.png",1)
        EndIf
        If $i = 2 Then
            FileDelete(@ScriptDir & "ImagesImage2.png")
            $TodayImage = InetGet($OverViewImage[2], @ScriptDir & "ImagesImage2.png",1)
        EndIf
        If $i = 3 Then
            FileDelete(@ScriptDir & "ImagesImage3.png")
            $TonightImage = InetGet($OverViewImage[3], @ScriptDir & "ImagesImage3.png",1)
        EndIf
        If $i = 4 Then
            FileDelete(@ScriptDir & "ImagesImage4.png")
            $TomorrowImage = InetGet($OverViewImage[4], @ScriptDir & "ImagesImage4.png",1)
        EndIf
    Next
EndFunc
Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

Alright, so its true that that works.. but I have since gone over every line of code in both the UDF and Widget to try and figure out why it's not working. But to no avail. What really confuses me is that the Temp works 100% on all counts, but the images don't. And those no difference between URL's or major differences in the StringReg. :/

Anymore help on this?

And thanks for your help so far Andreik

Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Bump, still looking for some help :oops:

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...