onelowzx6r Posted June 11, 2008 Share Posted June 11, 2008 I'm dumb...I had version 2.0 had new clue there was a new one. I was just barely decent at that. This is really simple, the problem is i cant get a message box or something to pop up saying a bit different. I'm sure this looks like crap but it works. Any suggestions here would be great. If $line > $LowTemp Or $line < $HighTemp Then MsgBox(0, 'Great Weather!', 'Go Riding!') except id rather the message say "The weather is within range", but if "Storm" or "Snow" are in line 24 have it decipher between Temp Ok, Weather OK. Temp Ok Weather Not. Temp Not Weather ok. and Temp not Weather not. expandcollapse popupIf FileExists('C:\\Program Files\\MotoWeather\\Config.ini') Then Else DirCreate('C:\\Program Files\\MotoWeather') $LowTemp = InputBox('Should You Ride Today?', 'Enter the LOWEST temperature (Fahrenheit) you would ride in') $HighTemp = InputBox('Should You Ride Today?', 'Enter the HIGHEST temperature (Fahrenheit) you would ride in') $Zip = InputBox('AutoIt', 'Enter your zip code') IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'Low', $LowTemp) IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'High', $HighTemp) IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'Zip', 'Code', $Zip) EndIf $Zip = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'Zip', 'Code', "") $LowTemp = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'Low', "") $HighTemp = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'High', "") Run('C:\\Program Files\\Internet Explorer\\iexplore.exe', '', @SW_HIDE) Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase WinActivate('Internet Explorer') WinWaitActive('Internet Explorer') $status = StatusbarGetText("Internet Explorer") If $status = 'Done' Then EndIf Sleep(500) Send('!d') Send('^a') Send('{DELETE}') Sleep(1000) Send('http://weather.yahooapis.com/forecastrss?p=' & $Zip) Send('{ENTER}') WinWaitActive('Yahoo!') If $status = 'Done' Then EndIf Send('^a') Sleep(500) Send('^c') Sleep(500) Send('!{F4}') WinWaitClose('Internet Explorer') Sleep(2000) FileWrite('C:\\Program Files\\MotoWeather\\WeatherData.txt', ClipGet()) $file = FileOpen('C:\\Program Files\\MotoWeather\\WeatherData.txt', 0) $line = FileReadLine($file, 24) If $line > $LowTemp Or $line < $HighTemp Then MsgBox(0, 'Great Weather!', 'Go Riding!') ElseIf $line <= $LowTemp Or $line >= $HighTemp Then MsgBox(0, 'Bad Weather', 'Fuck That!') EndIf FileClose($file) FileDelete('C:\\Program Files\\MotoWeather\\WeatherData.txt') Exit Link to comment Share on other sites More sharing options...
onelowzx6r Posted June 11, 2008 Author Share Posted June 11, 2008 (edited) I realize there is a ton of spelling errors in this, sorry. Ive been struggling with this for awhile now. I'm not sure how to use selects, if that's even an option? it would not respond correctly using If Then statements. I can't see how to edit that first post and i realize its impossible to read. Is' fairly simple. You enter your min and max values for temp and location. It saves to the ini file. Then it opens the page adding your zip, copies all the crap to a text file then reads only the lines i specified. Everything works fine, i got he message box to display exactly this: "Weather is within range <-this would change but it was never correct no matter what "if thens" i tried. But Weather is bad. <same here Local Forecast <worked fine Tomorrows forecast <worked fine OK" program would quit. The if then statements didn't work: they arn't in the code now, the comp took a crap and no time to save. This isnt exact because its late but i'm sure you guys get the idea. If $line > $LowTemp And $line < $HighTemp And Not 'storm' and not 'snow' Then MsgBox(0, 'Great Weather!', 'Go Riding!') i need the RIGHT code for this my mumbly ass shit. I need some direction... Edited June 11, 2008 by onelowzx6r Link to comment Share on other sites More sharing options...
weaponx Posted June 11, 2008 Share Posted June 11, 2008 Since the Yahoo Weather is RSS you can use a more reliable method: expandcollapse popup#include <_XMLDomWrapper.au3> #include <Array.au3> #include <INet.au3> Dim $aKeys[1], $aValues[1] Const $Zip = 85259 ;$sXMLFile = "12345.xml" ;$result = _XMLFileOpen($sXMLFile, 'xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"') ;If $result = 0 Then Exit $WeatherXML = _INetGetSource("http://weather.yahooapis.com/forecastrss?p=" & $Zip) _XMLLoadXML($WeatherXML, 'xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"') If @ERROR Then MsgBox(0,"",@ERROR) Exit EndIf ;Retrieve city (single attribute access) $sCity = _XMLGetAttrib("/rss/channel/yweather:location", "city") ConsoleWrite("City: " & $sCity & @CRLF) ;Retrieve region (single attribute access) $sRegion = _XMLGetAttrib("/rss/channel/yweather:location", "region") ConsoleWrite("Region: " & $sRegion & @CRLF) ConsoleWrite(@CRLF) ;Dump location attributes $aNodes = _XMLGetAllAttrib("/rss/channel/yweather:location", $aKeys, $aValues) If IsArray($aNodes) Then ConsoleWrite("Location Attributes: " & $aNodes[0][0] & @CRLF) For $X = 0 to Ubound($aKeys)-1 ConsoleWrite("[" & $X & "]: " & $aKeys[$X] & ": " & $aValues[$X] & @CRLF) Next ConsoleWrite(@CRLF) EndIf ;Dump condition attributes $aNodes = _XMLGetAllAttrib("/rss/channel/item/yweather:condition", $aKeys, $aValues) If IsArray($aNodes) Then ConsoleWrite("Condition Attributes: " & $aNodes[0][0] & @CRLF) For $X = 0 to Ubound($aKeys)-1 ConsoleWrite("[" & $X & "]: " & $aKeys[$X] & ": " & $aValues[$X] & @CRLF) Next ConsoleWrite(@CRLF) EndIf ;Dump ALL forecast attributes $count = _XMLGetNodeCount("/rss/channel/item/yweather:forecast") For $X = 1 to $count $aNodes = _XMLGetAllAttrib("/rss/channel/item/yweather:forecast["&$X&"]", $aKeys, $aValues) ConsoleWrite("Forecast Attributes: " & $aNodes[0][0] & @CRLF) For $Y = 0 to Ubound($aKeys)-1 ConsoleWrite("[" & $Y & "]: " & $aKeys[$Y] & ": " & $aValues[$Y] & @CRLF) Next ConsoleWrite(@CRLF) Next 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