Macro of the Day: Tell me the weather forecast for Redmond
Another good request for a macro came in the other day, this time from Brian (Thanks Brian). Here's what he wanted: A macro that can tell him the weather forecast.
Once you install this macro, you'll be able to say things like "What is the weather like in Redmond", or "Tell me the weather forecast for Redmond". It's only got a few cities in it right now, but you should be able to expand it to have as many cities as you care about.
Check it out here:
<?xml version="1.0" encoding="utf-8"?>
<speechMacros>
<command>
<listenFor>what is the weather like in [CityName]</listenFor>
<run command="https://www.weather.com/weather/local/{[CityName.zipCode]}"/>
</command>
<command>
<listenFor>Tell me the weather forecast for [CityName]</listenFor>
<speak>OK</speak>
<script language="JScript">
var xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;
xml_doc.load("https://www.rssweather.com/zipcode/{[CityName.zipCode]}/rss.php");
var titles = xml_doc.getElementsByTagName("title");
var descriptions = xml_doc.getElementsByTagName("description");
Application.Speak(titles.item(2).text + " in {[*CityName]}");
Application.Speak(descriptions.item(2).text);
</script>
</command>
<listenForList name="CityName" propname="zipCode">
<item propval="45255">Cincinnati</item>
<item propval="98075">Sammamish</item>
<item propval="98052">Redmond</item>
<item propval="98004">Bellevue</item>
<item propval="98101">Seattle</item>
</listenForList>
</speechMacros>
Comments
Anonymous
June 02, 2008
Hey Brian here, This is truly amazing! Thank you for writing the macro for me! I've been showing my friends what the WSR Marcros can do and they are extremely impressed. Keep up the good work and thanks again!Anonymous
June 03, 2008
This got me thinking, and granted I'm a newbie with WSR, but how about something like being able to pass a value to a search engine... sort of like this: <speechMacros> <command> <listenFor>search google [SearchValue]</listenFor> <run command="http://www.google.com/search?q={[SearchValue]}"/> </command> </speechMacros> Is that doable? The example doesn't work, just hoping you could share how to get that to work. Thanks.Anonymous
June 03, 2008
Yep. Totally doable. It looks like this: <speechMacros> <command> <listenFor>search google [...]</listenFor> <run command="http://www.google.com/search?q={[...]}"/> </command> </speechMacros> In this example, the macro system will listen for anything when it sees a listenFor that contains a [...] reference. Then, in the run command, you can refer back to what was actually spoken with {[...]}. Cool, eh?Anonymous
June 03, 2008
Dude, totally sweet!! I couldn't figure out the .. part :( So thanks!!Anonymous
June 05, 2008
The {[...]} part works but if say 3 words and then place them in google, the search string html is missing the "+'s" so instead you get three seperate google searches rather than one search with 3 words. I'm trying to figure out how to fix this but don't see how yet.Anonymous
June 20, 2008
The comment has been removed