; ******************************************************* ; AutoIt Script to Get Ready Data for WxSim ; Jim McMurry 2006 jmcmurry@mwt.net ; I don't pretend to be a programmer, just lazy enough to hack this out ; AutoIt available at http://www.autoitscript.com/autoit3/ ; Modified by Stuart T Rogers 2006 stuart@stella-maris.org.uk ; Now will copy & paste text into ready file and quit editor & IE ; Also added separate variables section at start to be customised by user ; Now does MAPS - all you need to do is set the Airport ID and the correct flag to do MAPS ; Modified 22 Nov 2008 to cope with changes on NOAA website ; ******************************************************* ; #include #include ; ************************************************************************************ ; Here are the variables you must set for this script to run for your own setup $rdy = "1" ; Set this to 0 if for some reason you dont want Ready Data $lat = "33.65" ; Latitude $long = "-84.4" ; Longitude $editor = "notepad.exe" ; Name of editor executable usually notepad.exe $ready = "c:\wxsim\readydat.txt" ; Full path & filename of your Ready Data $title = "readydat - Notepad" ; Editors window title text $gfs = "1" ; 1=84 hour 2=180 hour - the correct model will be selected no matter how many options appear ; This next set will do MAPS if required, if not leave alone and nothing will happen $maps = "1" ; Set this to one if you want maps data extracted then correct this line below to point to your required data $mapport = "ATL" ; Airport ID for Maps ; End of variables section ; ************************************************************************************ if $gfs = "1" then $gfstext = "GFS Model (0-84h, 3hrly, Global)" $gfs2 = " GFS#" $gfs3 = " HOURS OF CALCULATION: 84 &" endif if $gfs = "2" then $gfstext = "GFS Model (0-180h, 6hrly, Global)" $gfs2 = " GFSx#" $gfs3 = ' HOURS OF CALCULATION: 180 &' endif $readyedit1 = $editor & " " & $ready ; MsgBox(0x40040, "Run", $readyedit1) Run($readyedit1) WinWaitActive($title) send("^a") ;Select All send("{DEL}") ;Delete old data $oIE = _IECreate ("http://www.arl.noaa.gov/ready/cmet.html") ;Open the browser and go to the NOAA site WinWait("Air Resources Laboratory") If Not WinActive("Air Resources Laboratory") Then WinActivate("Air Resources Laboratory") EndIf WinWaitActive("Air Resources Laboratory") _IELoadWait ($oIE) if $rdy = "1" then $oL = _IEGetObjByName ($oIE, "Lat") ;Fortunately these form elements are named _IEFormElementSetValue ($oL, $lat) $oL = _IEGetObjByName ($oIE, "Lon") _IEFormElementSetValue ($oL, $long) $oFirstForm = _IEFormGetCollection ($oIE, 1) ;Gets reference to the second form (zero based) on the page which is where it is _IEFormSubmit ($oFirstForm, 0) ;Hits Continue and takes us to the second page ;MsgBox(0, "Testing", "IE window opened READY Programs Options Menu") WinWait("READY Program Options Menu", "", 5) If Not WinActive("READY Program Options Menu") Then WinActivate("READY Program Options Menu") EndIf WinWaitActive("READY Program Options Menu", "", 5) _IELoadWait ($oIE) ;MsgBox(0, "Testing", "IE window opened READY Programs Options Menu") $oForm = _IEFormGetObjByName ($oIE, "menu1") $oSelect = _IEFormElementGetObjByName ($oForm, "m") _IEFormElementOptionSelect ($oSelect, $gfstext, 1, "byText") WinWait("READY") If Not WinActive("READY") Then WinActivate("READY") EndIf WinWaitActive("READY") _IELoadWait ($oIE) $oForm = _IEFormGetCollection ($oIE, 0) ; Get reference to the first (and only) form since I can't find a name. _IEFormElementRadioSelect ($oForm, "1", "textonly", 1, "byIndex") ;Go to second set of radio buttons & select 2nd option Send("{PGDN}") $passwd = _IEFormElementGetObjByName($oForm, "password") _IEAction($passwd, "focus") ;Now User must enter password and hit return. WinWait("READY Meteorogram") ;Wait for default ready data page If Not WinActive("READY Meteorogram") Then WinActivate("READY Meteorogram") EndIf WinWaitActive("READY Meteorogram") _IELoadWait ($oIE) ; This code copies the first set of text to the clip board and pastes it into the readydat.txt file after having stripped off the ; not needed data $sText = _IEBodyReadText ($oIE) ;MsgBox(0, "Body Text", "testing") $sText1 = StringSplit($sText, $gfs2, 1) $sText2 = StringSplit($sText1[2], ' READY ', 1) $sText2[1] = StringStripWS($sText2[1] , 2) ClipPut($gfs2 & $sText2[1]) WinActivate($title) send("^v") send("{ENTER}") send("{ENTER}") ; Now we continue to the second set of text WinActivate("READY Meteorogram") WinWait("READY Meteorogram") If Not WinActive("READY Meteorogram") Then WinActivate("READY Meteorogram") EndIf WinWaitActive("READY Meteorogram") Send("{BROWSER_BACK}") _IELoadWait ($oIE) $oForm = _IEFormGetCollection ($oIE, 0) ; For some reason have to go get it again _IEFormElementRadioSelect ($oForm, "2", "type", 1, "byIndex") ;Go to first set of radio buttons & select third button $oSelect = _IEFormElementGetObjByName ($oForm, "Field1") _IEFormElementOptionSelect ($oSelect, "TCLD", 1, "byValue") ;Selects Total Cloud Cover $oSelect = _IEFormElementGetObjByName ($oForm, "Field2") _IEFormElementOptionSelect ($oSelect, "FLAG", 1, "byValue") ;Selects Wind Flags $oSelect = _IEFormElementGetObjByName ($oForm, "Field3") _IEFormElementOptionSelect ($oSelect, "TEMP", 1, "byValue") ;Temp 3d $oSelect = _IEFormElementGetObjByName ($oForm, "Level3") _IEFormElementOptionSelect ($oSelect, "4", 1, "byValue") ;925 $oSelect = _IEFormElementGetObjByName ($oForm, "Field4") _IEFormElementOptionSelect ($oSelect, "RELH", 1, "byValue") ;RH1 $oSelect = _IEFormElementGetObjByName ($oForm, "Level4") _IEFormElementOptionSelect ($oSelect, "4", 1, "byValue") ;925 $oSelect = _IEFormElementGetObjByName ($oForm, "Field5") _IEFormElementOptionSelect ($oSelect, "RELH", 1, "byValue") ;RH2 $oSelect = _IEFormElementGetObjByName ($oForm, "Level5") _IEFormElementOptionSelect ($oSelect, "6", 1, "byValue") ;850 $oSelect = _IEFormElementGetObjByName ($oForm, "Field6") _IEFormElementOptionSelect ($oSelect, "RELH", 1, "byValue") ;RH3 $oSelect = _IEFormElementGetObjByName ($oForm, "Level6") _IEFormElementOptionSelect ($oSelect, "9", 1, "byValue") ;700 $oSelect = _IEFormElementGetObjByName ($oForm, "Field7") _IEFormElementOptionSelect ($oSelect, "RELH", 1, "byValue") ;RH4 $oSelect = _IEFormElementGetObjByName ($oForm, "Level7") _IEFormElementOptionSelect ($oSelect, "13", 1, "byValue") ;500 $oSelect = _IEFormElementGetObjByName ($oForm, "Field8") _IEFormElementOptionSelect ($oSelect, "RELH", 1, "byValue") ;RH5 $oSelect = _IEFormElementGetObjByName ($oForm, "Level8") _IEFormElementOptionSelect ($oSelect, "17", 1, "byValue") ;300 _IEFormSubmit ($oForm) ; This code copies the second set of text to the clip board and pastes it into the readydat.txt file after having stripped off the ; not needed data $sText = _IEBodyReadText ($oIE) ClipPut($sText) $sText1 = StringSplit($sText, $gfs3 , 1) $sText2 = StringSplit($sText1[2], ' READY ', 1) $sText2[1] = StringStripWS($sText2[1] , 3) ClipPut($sText2[1]) WinActivate($title) send("^v") send("^s") ; save file if $maps <> "1" then send("!x") ; exit editor WinActivate("READY Meteorogram") _IEQuit ($oIE) ; exit IE Exit EndIf EndIf ; ;The following can get MAPS Data if updated with your airfield/coordinates ; WinActivate("READY Meteorogram") $mapsurl = "http://rucsoundings.noaa.gov/gifs/reply-skewt.cgi?data_source=MAPS&lon=&lat=&airport=" $mapsurl = $mapsurl & $mapport _IENavigate ($oIE, $mapsurl) WinWait("MAPS Sounding for") _IELinkClickByText ($oIE, "FAA 604 format for SHARP") WinWait("http://rucsoundings.noaa.gov/gifs/") $sText = _IEBodyReadText ($oIE) $sText1 = StringSplit($sText, 'Use your browser', 1) ClipPut($sText1[1]) WinActivate($title) send("{ENTER}") send("{ENTER}") send("^v") send("^s") ; save file send("!fx") ; exit notepad _IEQuit ($oIE) ; exit IE Exit