Jump to content

WeatherTray


random667
 Share

Recommended Posts

A simple little script to put the current local temperature in the system tray beside the clock.

1. You have to wait a minute for it to be seen at first, when the time changes the temp will be displayed.

2. If the temperature is cut off on the right: right click the task bar, hit properties, hit ok.

#NoTrayIcon
#include <INet.au3>
#include <String.au3>
#include <array.au3>

$ZipCode = 90210

While 1
    $File = _INetGetSource("http://www.weather.com/weather/local/" & $ZipCode)
    $TempArray = _StringBetween($File, "temp=", "&")
    If $TempArray <> 0 Then
        $Temp = $TempArray[0] & "°  "
        RegWrite("HKEY_CURRENT_USER\Control Panel\International", "s1159", "REG_SZ", "AM  " & $Temp)
        RegWrite("HKEY_CURRENT_USER\Control Panel\International", "s2359", "REG_SZ", "PM  " & $Temp)
        Sleep(60000)
    EndIf
WEnd
Edited by random667

It is really sad to see a family torn apart by something as simple as a pack of wolves.

Link to comment
Share on other sites

thats very cool. how would you go about turning it off. to put it back to time?

EDIT:

ok, i got it, never mind

Edited by billthecreator

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Link to comment
Share on other sites

how would you go about resetting the task bar with a command... in the script... cause i have it were the condition shows, and it need to be reset on its own?

ex:

10:55 PM 19° Mostly Cloudy

EDIT: I fixed it, and made changes of my own... there are two scripts that need to be saved.

the first one is the only one that need to be started, then the second one is turned on by the first.

Updated Dec. 8, 2008, 3:24AM

#include <INet.au3>
#include <String.au3>
#include <array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <GUIConstants.au3>
$ZipCode = IniRead(@AppDataDir & "\TempTrayInfo.ini", "Settings", "Zip", "")

Global $Town, $PIC[3]
$Title = ""
$w = 1
If Not FileExists(@AppDataDir& "\WeatherTray") Then
    DirCreate(@AppDataDir& "\WeatherTray")
    For $i = 0 to 48
        InetGet("http://image.weather.com/web/common/wxicons/52/" & $i & ".gif?12122006",@AppDataDir& "\WeatherTray\Pic" & $i & ".gif")
        If @error Then
        EndIf
    Next
EndIf

#Region ### START Koda GUI section ### Form=
$Form1      = GUICreate("Weather.com", 373, 119, -1, -1)
            GUISetBkColor(0x0A2C2A)
            GUISetIcon("C:\Users\William\Documents\Downloads\temp.ico")
$Graphic1   = GUICtrlCreateGraphic(0, 0, 373, 81,$SS_WHITERECT)
            GUICtrlSetColor(-1, 0xFFFFFF)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label1     = GUICtrlCreateLabel("Enter ZIP", 8, 8, 72, 17)
            GUICtrlSetColor(-1, 0x0A2C2A)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
            GUICtrlSetFont(-1, 8.5, 400, 0, "Verdana")
$Edit1      = GUICtrlCreateEdit($ZipCode, 8, 32, 95, 20, $ES_NUMBER)
            GUICtrlSetLimit(-1, 5)
$Label2     = GUICtrlCreateLabel("", 8, 54, 120, 17); Town
            GUICtrlSetState(-1, $GUI_DISABLE)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label3     = GUICtrlCreateLabel("", 264, 8, 109, 41, $SS_CENTER); Temp
            GUICtrlSetFont(-1, 24, 800, 0, "Verdana")
            GUICtrlSetColor(-1, 0x0A2C2A)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label4     = GUICtrlCreateLabel("", 130, 52, 155, 28, $SS_CENTER); Condition
            GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
            GUICtrlSetColor(-1, 0x0A2C2A)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label5     = GUICtrlCreateLabel("Feels Like", 285, 52, 88, 28, $SS_CENTER); Feels Like
            GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
            GUICtrlSetColor(-1, 0x0A2C2A)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label6     = GUICtrlCreateLabel("Direct Link", 256, 92, 108, 17, $SS_CENTER); Direct Link
            GUICtrlSetFont(-1, 8, 800, 4, "Verdana")
            GUICtrlSetColor(-1, 0xFFFFFF)
            GUICtrlSetCursor(-1, 0)
            GUICtrlSetTip(-1, "http://www.weather.com/weather/local/" & GUICtrlRead($Edit1))
$Label7     = GUICtrlCreateLabel("Refresh", 105, 35, 50, 17); Refresh
            GUICtrlSetFont(-1, 8, 800, 4, "Verdana")
            GUICtrlSetColor(-1, 0x0A2C2A)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
            GUICtrlSetCursor(-1, 0)
                    
            
$Button1    = GUICtrlCreateButton("Set Tray", 16, 88, 75, 25)
$Button2    = GUICtrlCreateButton("Exit", 96, 88, 75, 25)
            GUICtrlSetState(-1, $GUI_FOCUS)
$Button3    = GUICtrlCreateButton("Default Tray", 176, 88, 75, 25)
            GUICtrlSetTip(-1, "Tray will reset when the time changes.")
_GetWeatherInfo()
GUISetState(@SW_SHOW)
TraySetToolTip("Tray Weather")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
#EndRegion ### START Koda GUI section ### Form= 
;
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Button2
            Exit
        Case $Button1
            $ZipCode = GUICtrlRead($Edit1)
            _SetTempInfo($ZipCode, $Town)
            Run(FileGetShortName(@AutoItExe) & " SetTrayTemp.au3" )
            Exit
        Case $Button3
            RegWrite("HKEY_CURRENT_USER\Control Panel\International", "s1159", "REG_SZ", "AM  ")
            RegWrite("HKEY_CURRENT_USER\Control Panel\International", "s2359", "REG_SZ", "PM  ")
            Exit
        Case $Label6
            ShellExecute("http://www.weather.com/weather/local/" & GUICtrlRead($Edit1))
        Case $Label7
            _GetWeatherInfo()
    EndSwitch
WEnd

Func _SetTempInfo($zip, $cTown)
    IniWrite(@AppDataDir & "\TempTrayInfo.ini", "Settings", "Zip", $zip)
    IniWrite(@AppDataDir & "\TempTrayInfo.ini", "Settings", "Town", $cTown)
EndFunc   ;==>_SetTempInfo

Func _GetWeatherInfo()
    If _GUICtrlEdit_GetTextLen($Edit1) = 5 Then
        GUICtrlSetData($Label2, "Retrieving Information...")
        $File = _INetGetSource("http://www.weather.com/weather/local/" & GUICtrlRead($Edit1))
        $Town = _StringBetween($File, "<B>Right Now for</B><BR>", " (")
        If @error Then
            GUICtrlSetData($Label2, "No results found")
        Else
            $TempArray = _StringBetween($File, "temp=", "&")
            $CondArray = _StringBetween($File, "<B CLASS=obsTextA>", "</B>")
            
            $PictArray = _StringBetween($File, '<IMG SRC="http://image.weather.com/web/common/wxicons/52/', '.gif?12122006" WIDTH=52 HEIGHT=52 BORDER=0 ALT=>')
            $Picw = $PictArray[0]
            If $TempArray <> 0 Then
                $Temp = $TempArray[0] & "°F"
                $Cond = $CondArray[0]
                $Feel = $CondArray[1]
                $Feel = StringReplace($Feel, "<BR>", @CRLF)
                $Feel = StringReplace($Feel, "&deg;", "° ")
            EndIf
            $Town = $Town[0]
            GUICtrlSetData($Label2, $Town)
            GUICtrlSetData($Label3, $Temp)
            GUICtrlSetData($Label4, $Cond)
            GUICtrlSetData($Label5, $Feel)
            GUICtrlSetState($Label6, $GUI_SHOW)
            GUICtrlSetState($Label7, $GUI_SHOW)
            WinSetTitle($Title, "", $Town)
            GUICtrlSetTip($Label6, "http://www.weather.com/weather/local/" & GUICtrlRead($Edit1))
            $PIC[$w] = GUICtrlCreatePic(@AppDataDir & "\WeatherTray\Pic" & $Picw & ".gif", 181.5, 0, 52, 52)
            GUICtrlSetState(-1, $GUI_SHOW)
            If $w = 1 Then $w = 2
            If $w = 2 Then $w = 1
            GUICtrlSetState($Button1, $GUI_ENABLE)
            $Title = $Town
        EndIf
    ElseIf _GUICtrlEdit_GetTextLen($Edit1) < 5 Then
        GUICtrlSetData($Label2, "")
        GUICtrlSetData($Label3, "")
        GUICtrlSetData($Label4, "")
        GUICtrlSetData($Label5, "")
        GUICtrlSetState($Label6, $GUI_HIDE)
        GUICtrlSetState($Label7, $GUI_HIDE)
        GUICtrlDelete($PIC[$w])
        GUICtrlSetState($Button1, $GUI_DISABLE)
    EndIf
EndFunc

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode
    $hWndEdit1 = GUICtrlGetHandle($Edit1)
    $hWndFrom = $ilParam
    $iIDFrom = _WinAPI_LoWord($iwParam)
    $iCode = _WinAPI_HiWord($iwParam)
    Switch $hWndFrom
        Case $hWndEdit1
            Switch $iCode
                Case $EN_CHANGE
                    _GetWeatherInfo()
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND
Edited by billthecreator

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Link to comment
Share on other sites

A simple way to refresh the size of the system tray is to flash our scripts icon.

#NoTrayIcon
#include <INet.au3>
#include <String.au3>
#include <array.au3>

$ZipCode = 90210; Set zipcode

While 1
    $File = _INetGetSource("http://www.weather.com/weather/local/" & $ZipCode); Get the page source
    $TempArray = _StringBetween($File, "temp=", "&"); Find the temperature
    $CondArray = _StringBetween($File, "<B CLASS=obsTextA>", "</B>")    
    If $TempArray <> 0 Then; Check if temperature was found
        $Temp = $TempArray[0] & "° "
        $Cond = $CondArray[0]
        RegWrite("HKEY_CURRENT_USER\Control Panel\International", "s1159", "REG_SZ", "AM   " & $Temp & $Cond); Write temperature to the registry
        RegWrite("HKEY_CURRENT_USER\Control Panel\International", "s2359", "REG_SZ", "PM   " & $Temp & $Cond)
        $time = @MIN
        $now = @MIN
        While $now = $time; Wait till time changes
            Sleep(10)
            $now = @MIN
        WEnd
        Opt("TrayIconHide", 0); Flashing our scripts tray icon will refresh the system trays size
        Opt("TrayIconHide", 1)
    EndIf
    Sleep(55000); Wait untill 5 seconds before time changes again to restart the loop
WEnd
Edited by random667

It is really sad to see a family torn apart by something as simple as a pack of wolves.

Link to comment
Share on other sites

how would you go about resetting the task bar with a command... in the script... cause i have it were the condition shows, and it need to be reset on its own?

ex:

10:55 PM 19° Mostly Cloudy

EDIT: I fixed it, and made changes of my own... there are two scripts that need to be saved.

the first one is the only one that need to be started, then the second one is turned on by the first.

I was working on something like this bt have stopped case I like yours better... Thanks!

Link to comment
Share on other sites

Doesn't works for me , maybe because i'm from Singapore .

It doesn't work for me neither, but that's because my Windows is configured with a 24H clock. No AM or PM are displayed. I gues it's the same for you xVivoCity

If you doubleclick on the clock, you will probably see PM or AM with a Fahrenheit temperature.

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Link to comment
Share on other sites

I was working on something like this bt have stopped case I like yours better... Thanks!

thank you. here, this one is a whole lot better, you can keep the second one, but replace the first one with this:

#include <INet.au3>
#include <String.au3>
#include <array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <GUIConstants.au3>
$ZipCode = IniRead(@AppDataDir & "\TempTrayInfo.ini", "Settings", "Zip", "")

Global $Town, $PIC


If Not FileExists(@AppDataDir& "\WeatherTray") Then
    DirCreate(@AppDataDir& "\WeatherTray")
    For $i = 0 to 48
        InetGet("http://image.weather.com/web/common/wxicons/52/" & $i & ".gif?12122006",@AppDataDir& "\WeatherTray\Pic" & $i & ".gif")
        If @error Then
        EndIf
    Next
EndIf

#Region ### START Koda GUI section ### Form=
$Form1      = GUICreate("Weather.com", 373, 119, -1, -1)
            GUISetBkColor(0x0A2C2A)
            GUISetIcon("C:\Users\William\Documents\Downloads\temp.ico")
$Graphic1   = GUICtrlCreateGraphic(0, 0, 373, 81,$SS_WHITERECT)
            GUICtrlSetColor(-1, 0xFFFFFF)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label1     = GUICtrlCreateLabel("Enter ZIP", 8, 8, 72, 17)
            GUICtrlSetColor(-1, 0x0A2C2A)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
            GUICtrlSetFont(-1, 8.5, 400, 0, "Verdana")
$Edit1      = GUICtrlCreateEdit($ZipCode, 8, 32, 95, 20, $ES_NUMBER)
            GUICtrlSetLimit(-1, 5)
$Label2     = GUICtrlCreateLabel("", 8, 54, 95, 17); Town
            GUICtrlSetState(-1, $GUI_DISABLE)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label3     = GUICtrlCreateLabel("", 264, 8, 117, 41, $SS_CENTER); Temp
            GUICtrlSetFont(-1, 24, 800, 0, "Verdana")
            GUICtrlSetColor(-1, 0x0A2C2A)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label4     = GUICtrlCreateLabel("", 176, 50, 101, 17, $SS_CENTER); Condition
            GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
            GUICtrlSetColor(-1, 0x0A2C2A)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label5     = GUICtrlCreateLabel("Feels Like", 272, 50, 108, 30, $SS_CENTER); Feels Like
            GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
            GUICtrlSetColor(-1, 0x0A2C2A)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label6     = GUICtrlCreateLabel("Direct Link", 256, 92, 108, 17, $SS_CENTER); Feels Like
            GUICtrlSetFont(-1, 8, 800, 4, "Verdana")
            GUICtrlSetColor(-1, 0xFFFFFF)
            GUICtrlSetCursor(-1, 0)
            GUICtrlSetTip(-1, "http://www.weather.com/weather/local/" & GUICtrlRead($Edit1))
                    
            
$Button1    = GUICtrlCreateButton("Set Tray", 16, 88, 75, 25)
$Button2    = GUICtrlCreateButton("Exit", 96, 88, 75, 25)
            GUICtrlSetState(-1, $GUI_FOCUS)
$Button3    = GUICtrlCreateButton("Default Tray", 176, 88, 75, 25)
            GUICtrlSetTip(-1, "Tray will reset when the time changes.")
_GetWeatherInfo()
GUISetState(@SW_SHOW)
TraySetToolTip("Tray Weather")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
#EndRegion ### START Koda GUI section ### Form= 
;
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Button2
            Exit
        Case $Button1
            $ZipCode = GUICtrlRead($Edit1)
            _SetTempInfo($ZipCode, $Town)
            Run(FileGetShortName(@AutoItExe) & " SetTrayTemp.au3" )
            Exit
        Case $Button3
            RegWrite("HKEY_CURRENT_USER\Control Panel\International", "s1159", "REG_SZ", "AM  ")
            RegWrite("HKEY_CURRENT_USER\Control Panel\International", "s2359", "REG_SZ", "PM  ")
            Exit
        Case $Label6
            ShellExecute("http://www.weather.com/weather/local/" & GUICtrlRead($Edit1))
    EndSwitch
WEnd

Func _SetTempInfo($zip, $cTown)
    IniWrite(@AppDataDir & "\TempTrayInfo.ini", "Settings", "Zip", $zip)
    IniWrite(@AppDataDir & "\TempTrayInfo.ini", "Settings", "Town", $cTown)
EndFunc   ;==>_SetTempInfo

Func _GetWeatherInfo()
    If _GUICtrlEdit_GetTextLen($Edit1) = 5 Then
        GUICtrlSetData($Label2, "Loading...")
        $File = _INetGetSource("http://www.weather.com/weather/local/" & GUICtrlRead($Edit1))
        $Town = _StringBetween($File, "<B>Right Now for</B><BR>", " (")
        If @error Then
            GUICtrlSetData($Label2, "No results found")
        Else
            $TempArray = _StringBetween($File, "temp=", "&")
            $CondArray = _StringBetween($File, "<B CLASS=obsTextA>", "</B>")
            
            $PictArray = _StringBetween($File, '<IMG SRC="http://image.weather.com/web/common/wxicons/52/', '.gif?12122006" WIDTH=52 HEIGHT=52 BORDER=0 ALT=>')
            $Picw = $PictArray[0]
            If $TempArray <> 0 Then
                $Temp = $TempArray[0] & "°F"
                $Cond = $CondArray[0]
                $Feel = $CondArray[1]
                $Feel = StringReplace($Feel, "<BR>", @CRLF)
                $Feel = StringReplace($Feel, "&deg;", "° ")
            EndIf
            $Town = $Town[0]
            GUICtrlSetData($Label2, $Town)
            GUICtrlSetData($Label3, $Temp)
            GUICtrlSetData($Label4, $Cond)
            GUICtrlSetData($Label5, $Feel)
            GUICtrlSetState($Label6, $GUI_SHOW)
            GUICtrlSetTip($Label6, "http://www.weather.com/weather/local/" & GUICtrlRead($Edit1))
            $PIC = GUICtrlCreatePic(@AppDataDir & "\WeatherTray\Pic" & $Picw & ".gif", 200, 0, 52, 52)
            GUICtrlSetState($PIC, $GUI_SHOW)
            GUICtrlSetState($Button1, $GUI_ENABLE)
        EndIf
    ElseIf _GUICtrlEdit_GetTextLen($Edit1) < 5 Then
        GUICtrlSetData($Label2, "")
        GUICtrlSetData($Label3, "")
        GUICtrlSetData($Label4, "")
        GUICtrlSetData($Label5, "")
        GUICtrlSetState($Label6, $GUI_HIDE)
        GUICtrlSetState($PIC, $GUI_HIDE)
        GUICtrlSetState($Button1, $GUI_DISABLE)
    EndIf
EndFunc

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode
    $hWndEdit1 = GUICtrlGetHandle($Edit1)
    $hWndFrom = $ilParam
    $iIDFrom = _WinAPI_LoWord($iwParam)
    $iCode = _WinAPI_HiWord($iwParam)
    Switch $hWndFrom
        Case $hWndEdit1
            Switch $iCode
                Case $EN_CHANGE
                    _GetWeatherInfo()
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND
Edited by billthecreator

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Link to comment
Share on other sites

thank you. here, this one is a whole lot better, you can keep the second one, but replace the first one with this:

#include <INet.au3>
#include <String.au3>
#include <array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <GUIConstants.au3>
$ZipCode = IniRead(@AppDataDir & "\TempTrayInfo.ini", "Settings", "Zip", "")

Global $Town, $PIC


If Not FileExists(@AppDataDir& "\WeatherTray") Then
    DirCreate(@AppDataDir& "\WeatherTray")
    For $i = 0 to 48
        InetGet("http://image.weather.com/web/common/wxicons/52/" & $i & ".gif?12122006",@AppDataDir& "\WeatherTray\Pic" & $i & ".gif")
        If @error Then
        EndIf
    Next
EndIf

#Region ### START Koda GUI section ### Form=
$Form1      = GUICreate("Weather.com", 373, 119, -1, -1)
            GUISetBkColor(0x0A2C2A)
            GUISetIcon("C:\Users\William\Documents\Downloads\temp.ico")
$Graphic1   = GUICtrlCreateGraphic(0, 0, 373, 81,$SS_WHITERECT)
            GUICtrlSetColor(-1, 0xFFFFFF)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label1     = GUICtrlCreateLabel("Enter ZIP", 8, 8, 72, 17)
            GUICtrlSetColor(-1, 0x0A2C2A)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
            GUICtrlSetFont(-1, 8.5, 400, 0, "Verdana")
$Edit1      = GUICtrlCreateEdit($ZipCode, 8, 32, 95, 20, $ES_NUMBER)
            GUICtrlSetLimit(-1, 5)
$Label2     = GUICtrlCreateLabel("", 8, 54, 95, 17); Town
            GUICtrlSetState(-1, $GUI_DISABLE)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label3     = GUICtrlCreateLabel("", 264, 8, 117, 41, $SS_CENTER); Temp
            GUICtrlSetFont(-1, 24, 800, 0, "Verdana")
            GUICtrlSetColor(-1, 0x0A2C2A)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label4     = GUICtrlCreateLabel("", 176, 50, 101, 17, $SS_CENTER); Condition
            GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
            GUICtrlSetColor(-1, 0x0A2C2A)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label5     = GUICtrlCreateLabel("Feels Like", 272, 50, 108, 30, $SS_CENTER); Feels Like
            GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
            GUICtrlSetColor(-1, 0x0A2C2A)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label6     = GUICtrlCreateLabel("Direct Link", 256, 92, 108, 17, $SS_CENTER); Feels Like
            GUICtrlSetFont(-1, 8, 800, 4, "Verdana")
            GUICtrlSetColor(-1, 0xFFFFFF)
            GUICtrlSetCursor(-1, 0)
            GUICtrlSetTip(-1, "http://www.weather.com/weather/local/" & GUICtrlRead($Edit1))
                    
            
$Button1    = GUICtrlCreateButton("Set Tray", 16, 88, 75, 25)
$Button2    = GUICtrlCreateButton("Exit", 96, 88, 75, 25)
            GUICtrlSetState(-1, $GUI_FOCUS)
$Button3    = GUICtrlCreateButton("Default Tray", 176, 88, 75, 25)
            GUICtrlSetTip(-1, "Tray will reset when the time changes.")
_GetWeatherInfo()
GUISetState(@SW_SHOW)
TraySetToolTip("Tray Weather")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
#EndRegion ### START Koda GUI section ### Form= 
;
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Button2
            Exit
        Case $Button1
            $ZipCode = GUICtrlRead($Edit1)
            _SetTempInfo($ZipCode, $Town)
            Run(FileGetShortName(@AutoItExe) & " SetTrayTemp.au3" )
            Exit
        Case $Button3
            RegWrite("HKEY_CURRENT_USER\Control Panel\International", "s1159", "REG_SZ", "AM  ")
            RegWrite("HKEY_CURRENT_USER\Control Panel\International", "s2359", "REG_SZ", "PM  ")
            Exit
        Case $Label6
            ShellExecute("http://www.weather.com/weather/local/" & GUICtrlRead($Edit1))
    EndSwitch
WEnd

Func _SetTempInfo($zip, $cTown)
    IniWrite(@AppDataDir & "\TempTrayInfo.ini", "Settings", "Zip", $zip)
    IniWrite(@AppDataDir & "\TempTrayInfo.ini", "Settings", "Town", $cTown)
EndFunc   ;==>_SetTempInfo

Func _GetWeatherInfo()
    If _GUICtrlEdit_GetTextLen($Edit1) = 5 Then
        GUICtrlSetData($Label2, "Loading...")
        $File = _INetGetSource("http://www.weather.com/weather/local/" & GUICtrlRead($Edit1))
        $Town = _StringBetween($File, "<B>Right Now for</B><BR>", " (")
        If @error Then
            GUICtrlSetData($Label2, "No results found")
        Else
            $TempArray = _StringBetween($File, "temp=", "&")
            $CondArray = _StringBetween($File, "<B CLASS=obsTextA>", "</B>")
            
            $PictArray = _StringBetween($File, '<IMG SRC="http://image.weather.com/web/common/wxicons/52/', '.gif?12122006" WIDTH=52 HEIGHT=52 BORDER=0 ALT=>')
            $Picw = $PictArray[0]
            If $TempArray <> 0 Then
                $Temp = $TempArray[0] & "°F"
                $Cond = $CondArray[0]
                $Feel = $CondArray[1]
                $Feel = StringReplace($Feel, "<BR>", @CRLF)
                $Feel = StringReplace($Feel, "&deg;", "° ")
            EndIf
            $Town = $Town[0]
            GUICtrlSetData($Label2, $Town)
            GUICtrlSetData($Label3, $Temp)
            GUICtrlSetData($Label4, $Cond)
            GUICtrlSetData($Label5, $Feel)
            GUICtrlSetState($Label6, $GUI_SHOW)
            GUICtrlSetTip($Label6, "http://www.weather.com/weather/local/" & GUICtrlRead($Edit1))
            $PIC = GUICtrlCreatePic(@AppDataDir & "\WeatherTray\Pic" & $Picw & ".gif", 200, 0, 52, 52)
            GUICtrlSetState($PIC, $GUI_SHOW)
            GUICtrlSetState($Button1, $GUI_ENABLE)
        EndIf
    ElseIf _GUICtrlEdit_GetTextLen($Edit1) < 5 Then
        GUICtrlSetData($Label2, "")
        GUICtrlSetData($Label3, "")
        GUICtrlSetData($Label4, "")
        GUICtrlSetData($Label5, "")
        GUICtrlSetState($Label6, $GUI_HIDE)
        GUICtrlSetState($PIC, $GUI_HIDE)
        GUICtrlSetState($Button1, $GUI_DISABLE)
    EndIf
EndFunc

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode
    $hWndEdit1 = GUICtrlGetHandle($Edit1)
    $hWndFrom = $ilParam
    $iIDFrom = _WinAPI_LoWord($iwParam)
    $iCode = _WinAPI_HiWord($iwParam)
    Switch $hWndFrom
        Case $hWndEdit1
            Switch $iCode
                Case $EN_CHANGE
                    _GetWeatherInfo()
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

I'm living in Ha noi, Viet Nam and i can get my town's weather?

4m848p10.gif 

Link to comment
Share on other sites

Personally I don't see a need for city plus you will end up with you systray being way too big taking prime realestate away from opened apps.. Unless you mean in a different spot of course? LOL

lol. nah. i mean that putting in the city in the input would give results too.

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Link to comment
Share on other sites

RegWrite("HKEY_CURRENT_USER\Control Panel\International", "s1159", "REG_SZ", "AM  ")
RegWrite("HKEY_CURRENT_USER\Control Panel\International", "s2359", "REG_SZ", "PM  ")

Edited by billthecreator

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

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...