LurchMan Posted June 23, 2011 Share Posted June 23, 2011 (edited) Hey everyone - I made a simple weather app that I'm just wanting opinions on. Its still a rough project but I'm curious if it works for other people like it does mine. It requires an active internet connection but upon loading it determines where you are located and loads the weather information for that city at first. You can change cities once loaded - you can enter either city and state or zip code. Any thoughts, tips, or questions appreciated. Download both *.au3 files, create a folder named data the same place the weather.au3 is located and put the marquee.au3 in the data folder. Thanks for your time! Edit - Updated weather.au3 attachment. (Previous downloads: 77)Marquee.au3Weather.au3 Edited June 30, 2011 by LurchMan Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 23, 2011 Share Posted June 23, 2011 Nice. It works fine on my PC (unfortunately Vista). I don't think I'll have much use for this, but weather apps peak my interest. I use to have a weather station tied to my desktop PC and a website, someday (definitely not soon..) I hope to get it running again (with written by czardas integrated somehow).. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
taietel Posted June 23, 2011 Share Posted June 23, 2011 Works great (Windows 7/32 bit). It located my town acurately. I've changed Fahrenheit to Celsius, because I'm used to it. Thanks LurchMan. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
LurchMan Posted June 23, 2011 Author Share Posted June 23, 2011 Works great (Windows 7/32 bit). It located my town acurately. I've changed Fahrenheit to Celsius, because I'm used to it.Thanks LurchMan.Good to hear, that means it works on all 3 OS version (except win 7 64 bit which I'll test tonight. The celsius thing is something else I'm going to be implementing, just haven't made it that far. Thanks for the testing! Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
guinness Posted June 23, 2011 Share Posted June 23, 2011 (edited) Doesn't work on Win 7 x64, problem with the Array on line 94. Why not use my which doesn't load Java in the background? And it works on XP SP3 above. Also it uses InetRead() instead of InetGet(). Edited June 23, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
BrewManNH Posted June 23, 2011 Share Posted June 23, 2011 That works really well. Other than the cosmetics, which aren't that bad, I really like it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
LurchMan Posted June 24, 2011 Author Share Posted June 24, 2011 Doesn't work on Win 7 x64, problem with the Array on line 94. Why not use my which doesn't load Java in the background? And it works on XP SP3 above. Also it uses InetRead() instead of InetGet(). I'm not sure why it would fail at that point on x64 - I'll do more testing. I didn't want to use a pre-built UDFs this was just my attempt at a weather app.That works really well. Other than the cosmetics, which aren't that bad, I really like it.Thank you, The cosmetics are rough right now I just have to figure out a better way of doing them, but for testing it works. Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
taietel Posted June 28, 2011 Share Posted June 28, 2011 LurchMan, I've played with your script and guinness's also and came up with this: expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> Global $sINI = @TempDir & "\config.dll" Global $aINI, $sXML, $hGUI, $hGUIm, $hExit, $hRefresh, $hLocation, $hCurrPic, $hCurrHumidity, $hCurrTemp, $hCurrWeather, $hCurrWind, $aForecast[4][4] Global $hSLocation, $hSLanguage, $hConfig, $hStartup $aINI = _LoadINI() _GW_Location($aINI[1], $aINI[2]) _Weather($aINI[1]) _Refresh() While 1 Sleep(10) Global $Msg = GUIGetMsg() Switch $Msg Case $hExit _Exit() Case $hLocation _Config() Case $hRefresh _Refresh() EndSwitch WEnd Func _ChangeGui() GUISetState(@SW_ENABLE, $hGUI) GUIDelete($hConfig) EndFunc ;==>_ChangeGui Func _CheckStartup() $aINI = _LoadINI() If $aINI[0] = 1 Then Switch @OSVersion Case "WIN_2003", "WIN_XP", "WIN_XPe" FileCreateShortcut(@ScriptFullPath, @StartupCommonDir & "\" & @ScriptName & ".lnk") Case "WIN_2008R2", "WIN_7", "WIN_2008", "WIN_VISTA" FileCreateShortcut(@ScriptFullPath, @AppDataDir & "\Microsoft\Windows\Start Menu\Programs\Startup\" & @ScriptName & ".lnk") EndSwitch Else Switch @OSVersion Case "WIN_2003", "WIN_XP", "WIN_XPe" FileDelete(@StartupCommonDir & "\" & @ScriptName & ".lnk") Case "WIN_2008R2", "WIN_7", "WIN_2008", "WIN_VISTA" FileDelete(@AppDataDir & "\Microsoft\Windows\Start Menu\Programs\Startup\" & @ScriptName & ".lnk") EndSwitch EndIf EndFunc ;==>_CheckStartup Func _Config() GUISetState(@SW_DISABLE, $hGUI) Local $hBack Local $iX, $iY, $aPos, $iW = 218, $iH = 100, $nMsg $aPos = MouseGetPos() $iX = $aPos[0] $iY = $aPos[1] $hConfig = GUICreate("Weather Gadget", $iW, $iH, $iX - $iW, $iY, BitOR($WS_SYSMENU, $WS_POPUP), $WS_EX_TOPMOST) GUISetBkColor(0x111111) GUICtrlCreateLabel("Configuration", 8, 6, $iW - 32, 17, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetColor(-1, 0xfefefe) GUICtrlSetBkColor(-1, 0x202020) $hBack = GUICtrlCreateIcon("shell32.dll", -132, $iW - 22, 6, 16, 16, BitOR($SS_NOTIFY, $WS_GROUP)) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "Save, close and refresh") _RoundCorners($hConfig, 0.6) GUICtrlSetDefBkColor(0x111111) GUICtrlSetDefColor(0xefefef) GUICtrlCreateLabel("Search location:", 8, 34, 100, 17) $hSLocation = GUICtrlCreateInput($aINI[1], 108, 32, 100, 18, -1, $WS_EX_STATICEDGE) GUICtrlCreateLabel("Weather language:", 8, 56, 100, 17) $hSLanguage = GUICtrlCreateInput($aINI[2], 108, 54, 100, 18, -1, $WS_EX_STATICEDGE) GUICtrlSetTip(-1, "ro - Romanian," & @CRLF & "en - English" & @CRLF & "fr - French etc.") $hStartup = GUICtrlCreateCheckbox("Start with Windows", 8, $iH - 24, $iW - 16, 17, BitOR($BS_CHECKBOX, $BS_AUTOCHECKBOX, $BS_MULTILINE, $WS_TABSTOP)) GUICtrlSetState($hStartup, IniRead($sINI, "Config", "StartWithWindows", "4")) GUICtrlCreatePic("", 0, 0, $iW, $iH, BitOR($GUI_SS_DEFAULT_PIC, $SS_CENTERIMAGE), $GUI_WS_EX_PARENTDRAG) WinSetTrans($hConfig, "", 220) GUISetState() While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $hBack _WriteConfig() _ChangeGui() _Refresh() Return Case $hStartup IniWrite($sINI, "Config", "StartWithWindows", GUICtrlRead($hStartup)) _CheckStartup() EndSwitch WEnd EndFunc ;==>_Config Func _Exit() For $i = 0 To 220 Step 10 WinSetTrans($hGUI, "", 220 - $i) Sleep(10) Next GUIDelete($hGUI) Exit EndFunc ;==>_Exit Func _GW_Current() Local $aRet[11], $a, $bError $bError = StringRegExp($sXML, '<problem_cause data="(.*?)"/>', 1) If IsArray($bError) Or $bError Then MsgBox(48, "Eroare", "Unable to find the city." & @CRLF & "Please try again.") Return Else $a = StringRegExp($sXML, '<forecast_information><city data="(.*?)"/>', 1) $aRet[0] = $a[0] $a = StringRegExp($sXML, '<postal_code data="(.*?)"/>', 1) $aRet[1] = $a[0] $a = StringRegExp($sXML, '<forecast_date data="(.*?)"/>', 1) $aRet[2] = StringRegExpReplace($a[0], "(.*?)-(.*?)-(.*)", "$3.$2.$1");date from yyyy-mm-dd to dd.mm.yyyy $a = StringRegExp($sXML, '<current_date_time data="(.*?)"/>', 1) $a = StringRegExp($a[0], "\d{2}:\d{2}:\d{2}", 1) $aRet[3] = $a[0] $a = StringRegExp($sXML, '<unit_system data="(.*?)"/>', 1) $aRet[4] = $a[0] $a = StringRegExp($sXML, '<current_conditions><condition data="(.*?)"/>', 1) $aRet[5] = $a[0] $a = StringRegExp($sXML, '<temp_f data="(.*?)"/>', 1) $aRet[6] = $a[0] & Chr(176) & "F" $a = StringRegExp($sXML, '<temp_c data="(.*?)"/>', 1) $aRet[7] = $a[0] & Chr(176) & "C" $a = StringRegExp($sXML, '<humidity data="(.*?)"/>', 1) $aRet[8] = $a[0] $a = StringRegExp($sXML, '<icon data="(.*?)"/>', 1) InetGet("[url="http://www.google.com"]http://www.google.com[/url]" & $a[0], @TempDir & "iconp.gif") $aRet[9] = @TempDir & "iconp.gif" $a = StringRegExp($sXML, '<wind_condition data="(.*?)"/>', 1) If IsArray($a) Then $aRet[10] = $a[0] Else $aRet[10] = $a EndIf Return $aRet EndIf EndFunc ;==>_GW_Current Func _GW_Forecast() Local $p0, $p1, $p2, $p3, $p4, $bError $bError = StringRegExp($sXML, '<problem_cause data="(.*?)"/>', 1) If IsArray($bError) Or $bError Then Return Else Local $aRet[4][5] $p0 = StringRegExp($sXML, '<day_of_week data="(.*?)"/>', 3) $p1 = StringRegExp($sXML, '<condition data="(.*?)"/>', 3) $p2 = StringRegExp($sXML, '<icon data="(.*?)"/>', 3) $p3 = StringRegExp($sXML, '<high data="(.*?)"/>', 3) $p4 = StringRegExp($sXML, '<low data="(.*?)"/>', 3) For $i = 0 To 3 $aRet[$i][0] = $p0[$i] $aRet[$i][1] = $p1[$i + 1] InetGet("[url="http://www.google.com"]http://www.google.com[/url]" & $p2[$i + 1], @TempDir & "iconf" & $i & ".gif") $aRet[$i][2] = @TempDir & "iconf" & $i & ".gif" $aRet[$i][3] = $p3[$i] & Chr(176) & "C" $aRet[$i][4] = $p4[$i] & Chr(176) & "C" Next Return $aRet EndIf EndFunc ;==>_GW_Forecast Func _GW_Location($sLoc = "", $sLang = "") Local $sURL, $hXML $sURL = "[url="http://www.google.com/ig/api?weather"]http://www.google.com/ig/api?weather[/url]=" & $sLoc & "&hl=" & $sLang; InetGet($sURL, @TempDir & "vremea.xml") $hXML = FileOpen(@TempDir & "vremea.xml") If $hXML = -1 Then MsgBox(48, "Eroare", "Unable to retrieve data." & @CRLF & "Please check your internet connection.") Exit EndIf $sXML = FileRead($hXML) FileClose($hXML) EndFunc ;==>_GW_Location Func _LoadINI() Local $aRet[3] If Not FileExists($sINI) Then Local $ft = FileOpen($sINI, 2) Local $sText = "[Config]" & @CRLF $sText &= "StartWithWindows=4" & @CRLF $sText &= "Location=Hunedoara" & @CRLF $sText &= "Language=en" & @CRLF FileWrite($ft, $sText) FileClose($ft) EndIf $aRet[0] = IniRead($sINI, "Config", "StartWithWindows", "4") $aRet[1] = IniRead($sINI, "Config", "Location", "Hunedoara") $aRet[2] = IniRead($sINI, "Config", "Language", "en") Return $aRet EndFunc ;==>_LoadINI Func _Refresh() $aINI = _LoadINI() _GW_Location($aINI[1], $aINI[2]) Local $aCurrent[11], $aFore[4][4] $aCurrent = _GW_Current() If Not IsArray($aCurrent) Then Return Else GUICtrlSetData($hLocation, $aCurrent[0]) GUICtrlSetImage($hCurrPic, $aCurrent[9]) GUICtrlSetData($hCurrTemp, $aCurrent[7] & "/" & $aCurrent[6]) GUICtrlSetData($hCurrWeather, $aCurrent[5]) GUICtrlSetData($hCurrHumidity, $aCurrent[8]) GUICtrlSetData($hCurrWind, $aCurrent[10]) $aFore = _GW_Forecast() For $i = 0 To 3 GUICtrlSetData($aForecast[$i][0], $aFore[$i][0]) GUICtrlSetData($aForecast[$i][1], $aFore[$i][3]) GUICtrlSetData($aForecast[$i][2], $aFore[$i][4]) GUICtrlSetImage($aForecast[$i][3], $aFore[$i][2]) GUICtrlSetTip($aForecast[$i][3], $aFore[$i][1]) Next EndIf EndFunc ;==>_Refresh Func _RoundCorners($hWnd, $iR = 1) Local $x, $pos $pos = WinGetPos($hWnd) If $pos[2] > $pos[3] Then $x = 10 * $pos[2] / $pos[3] Else $x = 10 * $pos[3] / $pos[2] EndIf Local $aResult = DllCall("gdi32.dll", "handle", "CreateRoundRectRgn", "int", 0, "int", 0, "int", $pos[2], "int", $pos[3], _ "int", $iR * $x, "int", $iR * $x) Local $aRet = DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $hWnd, "handle", $aResult[0], "bool", True) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc ;==>_RoundCorners Func _Weather($sLoc) Local $iW = 315, $iH = 166 Local $iX, $iY $iX = @DesktopWidth - $iW - 1 $iY = @DesktopHeight - $iH - 29 $hGUI = GUICreate("Meteo", $iW, $iH, $iX, $iY, BitOR($WS_SYSMENU, $WS_POPUP, $WS_BORDER), $WS_EX_TOOLWINDOW) _RoundCorners($hGUI, 0.6) GUISetBkColor(0x000000) GUICtrlSetDefBkColor($GUI_BKCOLOR_TRANSPARENT) GUICtrlSetDefColor(0xefefef) $hLocation = GUICtrlCreateLabel($sLoc, 40, 5, $iW - 115, 28) GUICtrlSetFont(-1, 12, 400, 0, "Arial", 5) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "Click to change location") $hCurrPic = GUICtrlCreatePic("", 5, 5, 30, 30) $hCurrTemp = GUICtrlCreateLabel("", $iW - 100, 5, 95, 25, $SS_RIGHT) GUICtrlSetFont(-1, 14, 400, 0, "Arial", 5) $hCurrWeather = GUICtrlCreateLabel("", 50, 30, $iW - 55, 17, $SS_RIGHT) GUICtrlSetFont(-1, 10, 400, 0, "Arial", 5) $hCurrHumidity = GUICtrlCreateLabel("", $iW - 105, 47, 100, 17, $SS_RIGHT) GUICtrlSetFont(-1, 10, 400, 0, "Arial", 5) $hCurrWind = GUICtrlCreateLabel("", $iW / 2 - 5, 64, $iW / 2, 17, $SS_RIGHT) GUICtrlSetFont(-1, 10, 400, 0, "Arial", 5) For $i = 0 To 3 $aForecast[$i][0] = GUICtrlCreateLabel("", 5 + 80 * $i, 85, 65, 17) $aForecast[$i][1] = GUICtrlCreateLabel("" & ChrW(176), 5 + 80 * $i, 102, 25, 17) $aForecast[$i][2] = GUICtrlCreateLabel("" & ChrW(176), 5 + 80 * $i, 119, 25, 17) $aForecast[$i][3] = GUICtrlCreatePic("", 30 + 80 * $i, 102, 40, 30) Next For $i = 0 To 2 GUICtrlCreateLabel("", 75 + 80 * $i, 88, 1, 47) GUICtrlSetBkColor(-1, 0x808080) Next GUICtrlCreateLabel("", 5, 140, $iW - 10, 1) GUICtrlSetBkColor(-1, 0x808080) GUICtrlCreateLabel("Weather 2011 - v" & FileGetVersion(@ScriptName) & " beta", 5, $iH - 20, $iW - 50, 17) $hExit = GUICtrlCreateIcon("shell32.dll", -132, $iW - 22, $iH - 22, 16, 16) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "Exit") $hRefresh = GUICtrlCreateIcon("shell32.dll", -239, $iW - 42, $iH - 22, 16, 16) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "Refresh the info") GUICtrlCreatePic("", 0, 0, $iW, $iH, BitOR($GUI_SS_DEFAULT_PIC, $SS_CENTERIMAGE), $GUI_WS_EX_PARENTDRAG) WinSetTrans($hGUI, "", 0) GUISetState() For $i = 0 To 220 Step 10 WinSetTrans($hGUI, "", $i) Sleep(10) Next EndFunc ;==>_Weather Func _WriteConfig() IniWrite($sINI, "Config", "StartWithWindows", GUICtrlRead($hStartup)) If GUICtrlRead($hSLocation) <> "" Then IniWrite($sINI, "Config", "Location", GUICtrlRead($hSLocation)) If GUICtrlRead($hSLanguage) <> "" Then IniWrite($sINI, "Config", "Language", GUICtrlRead($hSLanguage)) EndFunc ;==>_WriteConfig It's not perfect, but ... thanks! Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
guinness Posted June 28, 2011 Share Posted June 28, 2011 Very nice indeed taietel! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
LurchMan Posted June 29, 2011 Author Share Posted June 29, 2011 (edited) LurchMan, I've played with your script and guinness's also and came up with this:It's not perfect, but ... thanks!taietel - I like the GUI and I'm already currently working on rewriting the RegEx to make it cleaner and easier to manage. If you have no objections I'm going to incorporate your GUI with the new RegEx I'm using.Edit: New RegEx credit goes to GeoSoft (I don't have much credit in this project anymore, just putting it together) Edited June 29, 2011 by LurchMan Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
taietel Posted June 29, 2011 Share Posted June 29, 2011 LurchMan, as far as I'm concearn, if it wasn't your project, my GUI wasn't here either. Then I saw guinness's udf and, after testing with few cities I've concluded that google api is very suitable for my area. Of course, I have modified to fit my needs, but the idea wasn't mine. You can use the gui whatever you like. Thanks again, both of you! Regards, taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
guinness Posted June 29, 2011 Share Posted June 29, 2011 taietel you've inspired me to re-think about the GoogleWeather UDF Example UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
guinness Posted June 29, 2011 Share Posted June 29, 2011 taietel you're missing "\" after @TempDir. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
taietel Posted June 29, 2011 Share Posted June 29, 2011 Yep, I know. I've replaced the initial location of the files with CTRL+H and missed that. I've modified on my computer, but not on the post (I'll do that when the shrinking/expanding module of the gui is ready - just like those gadgets from win7). Thanks again! Regards, taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
LurchMan Posted June 29, 2011 Author Share Posted June 29, 2011 Here is my newest version of this, I've used the GUI from taietel and the RegEx from GeoSoft and came up with this: expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include "data\marquee.au3" #include <ie.au3> Global $hGUI, _ $hLocation, _ $hCurrPic, _ $hCurrTemp, _ $hCurrWeather, _ $hCurrHumidity, _ $hCurrWind, _ $hExit, _ $hRefresh, _ $hExit, _ $hConfig, _ $hStartup, _ $hSLocation, _ $hSLanguage, _ $hSCelFor, _ $hSFerFor, _ $hFIndLocStart, _ $sPageCode, _ $sStartUrl, _ $sLoc Global $sINI = @ScriptDir & "\data\options.ini" GLobal $aINI = _LoadINI() If $aINI[4] = 1 Then $sLoc = _GetLocation () $sUrlLoc = StringReplace ($sLoc, " ", "+") Else $sLoc = $aINI[1] $sUrlLoc = StringReplace ($sLoc, " ", "+") EndIf Global $sPageCode = _RefreshPage() Global $aCurrent = _GetCurrent($sPageCode) Global $aForecast = _GetForecast($sPageCode) _Weather($sLoc) _RefreshData () While 1 Sleep (100) Global $Msg = GUIGetMsg() Switch $Msg Case $hExit _Exit() Case $hLocation _Config() Case $hRefresh _RefreshPage() _RefreshData() EndSwitch WEnd Func _Weather($sLoc) Local $iW = 315, $iH = 166 Local $iX, $iY $iX = @DesktopWidth - $iW - 1 $iY = @DesktopHeight - $iH - 29 $hGUI = GUICreate("Weather", $iW, $iH, $iX, $iY, BitOR($WS_SYSMENU, $WS_POPUP, $WS_BORDER), $WS_EX_TOOLWINDOW) _RoundCorners($hGUI, 0.6) GUISetBkColor(0x000000) GUICtrlSetDefBkColor($GUI_BKCOLOR_TRANSPARENT) GUICtrlSetDefColor(0xefefef) $hLocation = GUICtrlCreateLabel($sLoc, 40, 5, $iW - 115, 28) GUICtrlSetFont(-1, 12, 400, 0, "Arial", 5) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "Click to Change Options") $hCurrPic = GUICtrlCreatePic("", 5, 5, 30, 30) $hCurrTemp = GUICtrlCreateLabel("", $iW - 100, 5, 95, 25, $SS_RIGHT) GUICtrlSetFont(-1, 14, 400, 0, "Arial", 5) $hCurrWeather = GUICtrlCreateLabel("", 50, 30, $iW - 55, 17, $SS_RIGHT) GUICtrlSetFont(-1, 10, 400, 0, "Arial", 5) $hCurrHumidity = GUICtrlCreateLabel("", $iW - 105, 47, 100, 17, $SS_RIGHT) GUICtrlSetFont(-1, 10, 400, 0, "Arial", 5) $hCurrWind = GUICtrlCreateLabel("", $iW / 2 - 5, 64, $iW / 2, 17, $SS_RIGHT) GUICtrlSetFont(-1, 10, 400, 0, "Arial", 5) For $i = 0 To 3 $aForecast[$i][0] = GUICtrlCreateLabel("", 5 + 80 * $i, 85, 65, 17) $aForecast[$i][1] = GUICtrlCreateLabel("" & ChrW(176), 5 + 80 * $i, 102, 25, 17) $aForecast[$i][2] = GUICtrlCreateLabel("" & ChrW(176), 5 + 80 * $i, 119, 25, 17) $aForecast[$i][3] = GUICtrlCreatePic("", 30 + 80 * $i, 102, 40, 30) Next For $i = 0 To 2 GUICtrlCreateLabel("", 75 + 80 * $i, 88, 1, 47) GUICtrlSetBkColor(-1, 0x808080) Next GUICtrlCreateLabel("", 5, 140, $iW - 10, 1) GUICtrlSetBkColor(-1, 0x808080) GUICtrlCreateLabel("Weather 2011 - v" & FileGetVersion(@ScriptName) & " beta", 5, $iH - 20, $iW - 50, 17) $hExit = GUICtrlCreateIcon("shell32.dll", -132, $iW - 22, $iH - 22, 16, 16) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "Exit") $hRefresh = GUICtrlCreateIcon("shell32.dll", -147, $iW - 42, $iH - 22, 16, 16) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "Refresh") GUICtrlCreatePic("", 0, 0, $iW, $iH, BitOR($GUI_SS_DEFAULT_PIC, $SS_CENTERIMAGE), $GUI_WS_EX_PARENTDRAG) WinSetTrans($hGUI, "", 0) GUISetState() For $i = 0 To 220 Step 10 WinSetTrans($hGUI, "", $i) Sleep(10) Next EndFunc ;==>_Weather Func _RefreshData() $aINI = _LoadINI() Local $aCurrent[11], $aFore[4][4] $sPageCode = _RefreshPage () $aCurrent = _GetCurrent ($sPageCode) If Not IsArray($aCurrent) Then Return Else GUICtrlSetData($hLocation, $sLoc) GUICtrlSetImage($hCurrPic, @ScriptDir & "\data\current.gif") If $aINI[3] = "F" Then GUICtrlSetData($hCurrTemp, $aCurrent[1] & " °F") Else GUICtrlSetData($hCurrTemp, $aCurrent[2] & " °C") EndIf GUICtrlSetData($hCurrWeather, $aCurrent[0]) GUICtrlSetData($hCurrHumidity, $aCurrent[3]) GUICtrlSetData($hCurrWind, $aCurrent[5]) $aFore = _GetForecast($sPageCode) For $i = 0 To 3 GUICtrlSetData($aForecast[$i][0], $aFore[$i][0]) If $aINI[3] = "F" Then GUICtrlSetData($aForecast[$i][1], $aFore[$i][2]) GUICtrlSetData($aForecast[$i][2], $aFore[$i][1]) Else GUICtrlSetData($aForecast[$i][1], Round((($aFore[$i][2]-32)*5)/9, 0)) GUICtrlSetData($aForecast[$i][2], Round((($aFore[$i][1]-32)*5)/9, 0)) EndIf GUICtrlSetImage($aForecast[$i][3], @ScriptDir & "\data\day" & $i & ".gif") GUICtrlSetTip($aForecast[$i][3], $aFore[$i][0]) Next EndIf EndFunc ;==>_Refresh Func _RefreshPage() Local $s_PageCode $aINI = _LoadINI () $sUrlLoc = StringReplace($aINI[1], " ", "+") $sLoc = $aINI[1] $sURL = "http://www.google.com/ig/api?weather=" & $sUrlLoc & "&hl=" & $aINI[2] $s_PageCode = BinaryToString(InetRead ($sURL)) Return ($s_PageCode) EndFunc #cs ; _GetCurrent() ; Pass it the String from the page code. Use _RefreshPage() to get that. ; Array Elements ; [0] = Condition Data ; [1] = Temp F ; [2] = Temp C ; [3] = Humidity ; [4] = Image ; [5] = Wind #ce Func _GetCurrent($s_String) Local $a_Cur_Cond = StringRegExp(StringRegExpReplace($s_String, "(?i).+<current_conditions>(.+)</current_conditions>.+", "$1"), "(?i)data=\x22(.+?)\x22/>", 3) If @Error Then Return SetError(1) InetGet ("http://www.google.com/" & $a_Cur_Cond[4], @ScriptDir & "\data\current.gif") Return($a_Cur_Cond) EndFunc #cs ; _GetForecast() ; Pass it the String from the page code. Use _RefreshPage() to get that. ; Array Elements ; [n][0] = Weekday ; [n][1] = Lo Temp ; [n][2] = Hi Temp ; [n][3] = Image ; [n][4] = Conditions #ce Func _GetForecast($s_String) Local $a_Fcast_Cond = StringRegExp(StringRegExpReplace($s_String, "(?i).+?(<forecast_conditions>.+</forecast_conditions>).+", "$1"), "(?i)<forecast_conditions>(.+?)</forecast_conditions>", 3) Local $aHold Dim $aRtn[UBound($a_Fcast_Cond)][5] For $i = 0 To UBound($a_Fcast_Cond) -1 $aHold = StringRegExp($a_Fcast_Cond[$i], "(?i)data=\x22(.+?)\x22/>", 3) $aHold[3] = StringRegExpReplace($aHold[3], "^.+/(.+)$", "$1");; You can remove this if you want to use InetGet() to download the image. InetGet ("http://www.google.com/ig/images/weather/" & $aHold[3], @ScriptDir & "\data\day" & $i & ".gif") For $j = 0 To UBound($aHold) -1 $aRtn[$i][$j] = $aHold[$j] Next Next Return($aRtn) EndFunc Func _RoundCorners($hWnd, $iR = 1) Local $x, $pos $pos = WinGetPos($hWnd) If $pos[2] > $pos[3] Then $x = 10 * $pos[2] / $pos[3] Else $x = 10 * $pos[3] / $pos[2] EndIf Local $aResult = DllCall("gdi32.dll", "handle", "CreateRoundRectRgn", "int", 0, "int", 0, "int", $pos[2], "int", $pos[3], _ "int", $iR * $x, "int", $iR * $x) Local $aRet = DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $hWnd, "handle", $aResult[0], "bool", True) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc ;==>_RoundCorners Func _LoadINI() Local $aRet[5] If Not FileExists($sINI) Then Local $ft = FileOpen($sINI, 2) Local $sText = "[Config]" & @CRLF $sText &= "StartWithWindows=4" & @CRLF $sText &= "Location=" & $sLoc & @CRLF $sText &= "Language=EN" & @CRLF $sText &= "FindLocationOnStart=1" & @CRLF $sText &= "TempDisp=F" & @CRLF FileWrite($ft, $sText) FileClose($ft) EndIf $aRet[0] = IniRead($sINI, "Config", "StartWithWindows", "4") $aRet[1] = IniRead($sINI, "Config", "Location", $sLoc) $aRet[2] = IniRead($sINI, "Config", "Language", "en") $aRet[3] = IniRead($sINI, "Config", "TempDisp", "F") $aRet[4] = IniRead($sINI, "Config", "FindLocationOnStart", "1") Return $aRet EndFunc ;==>_LoadINI Func _Exit() For $i = 0 To 220 Step 10 WinSetTrans($hGUI, "", 220 - $i) Sleep(10) Next GUIDelete($hGUI) Exit EndFunc ;==>_Exit Func _GetLocation () $fLoading = GUICreate("Loading", 205, 50, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $WS_BORDER), $WS_EX_TOOLWINDOW) GUISetBkColor(0x111111) GUICtrlCreateLabel("Loading Weather", 50, 6, 100, 17, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetColor(-1, 0xfefefe) GUICtrlSetBkColor(-1, 0x202020) _RoundCorners($fLoading, 0.6) GUICtrlSetDefBkColor(0x111111) GUICtrlSetDefColor(0xefefef) $ID1 = _GUICtrlProgressMarqueeCreate(2,23, 200, 20) _GUICtrlProgressSetMarquee($ID1) GUISetState (@SW_SHOW, $fLoading) InetGet ("http://www.ipaddresslocation.org/", @ScriptDir & "\Data\location.html") $oIE = _IECreate ("http://www.ipaddresslocation.org/", 1, 0) $sRead = _IEBodyReadText ($oIE) _IEQuit ($oIE) $iLoc = StringInStr ($sRead, "My IP Location (Guessed City)") $sTrim = StringTrimLeft ($sRead, $iLoc-1) $aSplit = StringSplit ($sTrim, @CRLF) $sLocation = $aSplit[3] GUISetState (@SW_HIDE, $fLoading) Return $sLocation EndFunc Func _Config() GUISetState(@SW_DISABLE, $hGUI) Local $hBack Local $iX, $iY, $aPos, $iW = 218, $iH = 150, $nMsg $aPos = WinGetPos ($hGUI) $iX = $aPos[0] $iY = $aPos[1] $hConfig = GUICreate("Weather Gadget", $iW, $iH, $iX - $iW, $iY, BitOR($WS_SYSMENU, $WS_POPUP), $WS_EX_TOPMOST) GUISetBkColor(0x111111) GUICtrlCreateLabel("Configuration", 8, 6, $iW - 32, 17, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetColor(-1, 0xfefefe) GUICtrlSetBkColor(-1, 0x202020) $hBack = GUICtrlCreateIcon("shell32.dll", -132, $iW - 22, 6, 16, 16, BitOR($SS_NOTIFY, $WS_GROUP)) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "Save, Close and Refresh") _RoundCorners($hConfig, 0.6) GUICtrlSetDefBkColor(0x111111) GUICtrlSetDefColor(0xefefef) GUICtrlCreateLabel("Search location:", 8, 34, 100, 17) $hSLocation = GUICtrlCreateInput($aINI[1], 108, 32, 100, 18, -1, $WS_EX_STATICEDGE) GUICtrlCreateLabel("Weather language:", 8, 56, 100, 17) $hSLanguage = GUICtrlCreateInput($aINI[2], 108, 54, 100, 18, $ES_UPPERCASE, $WS_EX_STATICEDGE) GUICtrlSetTip(-1, "en - English," & @CRLF & "ro - Romanian" & @CRLF & "fr - French, etc.") GUICtrlCreateLabel("°C / °F:", 8, 78, 100, 17) $hSCelFor = GUICtrlCreateRadio("°C", 108, 76, 40, 18, -1, $WS_EX_STATICEDGE) $hSFerFor = GUICtrlCreateRadio("°F", 149, 76, 40, 18, -1, $WS_EX_STATICEDGE) If $aINI[3] = "F" Then GUICtrlSetState (-1, $GUI_CHECKED) Else GUICtrlSetState ($hSCelFor, $GUI_CHECKED) EndIf $hFIndLocStart = GUICtrlCreateCheckbox("Find Location on Startup", 8, $iH - 44, $iW - 16, 17, BitOR($BS_CHECKBOX, $BS_AUTOCHECKBOX, $BS_MULTILINE, $WS_TABSTOP)) GUICtrlSetState($hFIndLocStart, IniRead($sINI, "Config", "FindLocationOnStart", "1")) $hStartup = GUICtrlCreateCheckbox("Start with Windows", 8, $iH - 24, $iW - 16, 17, BitOR($BS_CHECKBOX, $BS_AUTOCHECKBOX, $BS_MULTILINE, $WS_TABSTOP)) GUICtrlSetState($hStartup, IniRead($sINI, "Config", "StartWithWindows", "4")) GUICtrlCreatePic("", 0, 0, $iW, $iH, BitOR($GUI_SS_DEFAULT_PIC, $SS_CENTERIMAGE), $GUI_WS_EX_PARENTDRAG) WinSetTrans($hConfig, "", 220) GUISetState() While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $hBack _WriteConfig() _ChangeGui() _RefreshPage() _RefreshData() Return Case $hStartup IniWrite($sINI, "Config", "StartWithWindows", GUICtrlRead($hStartup)) _CheckStartup() EndSwitch WEnd EndFunc ;==>_Config Func _WriteConfig() IniWrite($sINI, "Config", "StartWithWindows", GUICtrlRead($hStartup)) If GUICtrlRead($hSLocation) <> "" Then IniWrite($sINI, "Config", "Location", GUICtrlRead($hSLocation)) If GUICtrlRead($hSLanguage) <> "" Then IniWrite($sINI, "Config", "Language", GUICtrlRead($hSLanguage)) If GUICtrlRead ($hSCelFor) = $GUI_CHECKED Then IniWrite($sINI, "Config", "TempDisp", "C") If GUICtrlRead ($hSFerFor) = $GUI_CHECKED Then IniWrite($sINI, "Config", "TempDisp", "F") IniWrite($sINI, "Config", "FindLocationOnStart", GUICtrlRead($hFIndLocStart)) EndFunc ;==>_WriteConfig Func _ChangeGui() GUISetState(@SW_ENABLE, $hGUI) GUIDelete($hConfig) EndFunc ;==>_ChangeGui Func _CheckStartup() $aINI = _LoadINI() If $aINI[0] = 1 Then RegWrite ("HKLU\Software\Microsoft\Windows\CurrentVersion\Run", "WeatherApp", "REG_SZ", @ScriptFullPath) Else RegDelete ("HKLU\Software\Microsoft\Windows\CurrentVersion\Run", "WeatherApp") EndIf EndFunc ;==>_CheckStartup Again - the marquee.au3 is needed (I changed how and when the location finder works). Let me know the new thoughts! Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
taietel Posted June 30, 2011 Share Posted June 30, 2011 I've modified a little because I get an error on _GetForecast ($a_Fcast_Cond was returned 1): just after the line 34, $sLoc = _GetLocation () I've added this line: $sLoc = _GetLocation () IniWrite($sINI, "Config", "Location", $sLoc) And for the forecast tooltip (it shows the day), I've replaced on line 143 GUICtrlSetTip($aForecast[$i][3], $aFore[$i][0]) with this, to indicate the conditions GUICtrlSetTip($aForecast[$i][3], $aFore[$i][4]) Now it works just great! Thanks (again)! Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
Dubstep Posted June 30, 2011 Share Posted June 30, 2011 Very nice job! It located my town accurately. I certainly couldn't code anything like this. I'm so new to all of this.. Link to comment Share on other sites More sharing options...
BrewManNH Posted June 30, 2011 Share Posted June 30, 2011 I would like to suggest adding this line just before the code that creates the radio buttons for the config menu.DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) On Vista, with a theme set, the labels for the radio buttons and the 2 checkboxes don't show up. I'm using a dark theme on my computer and the text was displaying in black text on a nearly black background. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
LurchMan Posted June 30, 2011 Author Share Posted June 30, 2011 I've modified a little because I get an error on _GetForecast ($a_Fcast_Cond was returned 1): just after the line 34, And for the forecast tooltip (it shows the day), I've replaced on line 143Now it works just great! Thanks (again)!I would like to suggest adding this line just before the code that creates the radio buttons for the config menu.DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) On Vista, with a theme set, the labels for the radio buttons and the 2 checkboxes don't show up. I'm using a dark theme on my computer and the text was displaying in black text on a nearly black background.taietel - No thank you for testing it and showing me the faults it has and the new GUI (I'm terrible with GUIs and this has taught me a lot)BrewManNH - Thank you for the tip - I didn't think about the dark backgroundI've updated the first post to have the newest version in it. Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now