Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Warn
- active := 0
- return ; End of auto-execute
- F12::ShowWeather()
- F11::
- active ^= 1
- SetTimer CheckWeather, % active ? 1000 * 60 * 30 : "Delete"
- if (active)
- CheckWeather()
- else
- SetWallpaper("master")
- return
- ShowWeather()
- {
- FileRead zipCode, % A_ScriptDir "\zipcode.txt"
- if (zipCode)
- MsgBox % GetWeather(zipCode)
- }
- CheckWeather()
- {
- static zipCode := ""
- if !zipCode && !FileExist(A_ScriptDir "\zipcode.txt")
- {
- InputBox zipCode, Enter your zip code,,, 200, 100,,, Locale
- if (!zipCode)
- {
- MsgBox 0x10, Error, Zip code is required.
- ExitApp
- }
- FileOpen(A_ScriptDir "\zipcode.txt", 0x1).Write(zipCode)
- }
- weather := GetWeather(zipCode)
- SetWallpaper(weather)
- }
- GetWeather(ZipCode)
- {
- url := "http://wttr.in/" ZipCode "?format=%C"
- whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
- whr.Open("GET", url, false)
- whr.Send()
- return whr.ResponseText
- }
- SetWallpaper(Name)
- {
- file := A_ScriptDir "\Wallpapers\" Name ".png"
- if !FileExist(file)
- return
- DllCall("User32\SystemParametersInfo"
- , "Int",0x0014
- , "Int",0
- , "Str",file
- , "Int",0x2)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement