DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: FARR mini weather report from wttr.in  (Read 10,776 times)

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,175
    • Coding Snacks
    • Participated in NANY Challenge Three Times
    • Plugin Coding Medal
FARR mini weather report from wttr.in
« on: November 19, 2020, 05:55 PM »
Wttr is a fun and fast URL based command line weather report tool.
Background and syntax here https://github.com/chubin/wttr.in

This post describes how to show wttr weather as text directly in the FARR searchbox.

wttr.gif

Step 1. create a FARR alias
name: weather
regex: ^(weath|weat|wea)$
result: weather | appcap "C:\folder\FARR_weather_helper.exe"

Step 2. prepare helper AutoHotkey script
- Save code to C:\folder\FARR_weather_helper.ahk
- Modify the wttr URL in the code: which location? what data to show? language? extra text?
- Compile the script to an .exe file (necessary since FARR's appcap doesn't work if we run .ahk scripts uncompiled, it seems)
Code: ( autohotkey)
#NoEnv
#SingleInstance force
SetBatchLines, -1

; FARR_weather_helper.ahk
; 2020-11-19 by Nod5
; helper script to show weather from wttr.in in FARR searchbox
; wttr details and syntax at https://github.com/chubin/wttr.in

; prepare wttr URL (must escape each % character with `)
vUrl := "https://wttr.in/london?format=`%c+`%t+`%C"
; example output: ☀️ +9°C Sunny

; download weather page to variable
vString := urlDownloadToVar(vUrl)

; replace FARR searchbox string with weather string via clipboard paste
; clipboard pastes all at once so won't trigger other aliases
vBackup := ClipboardAll
Clipboard := vString
Send ^a^v
sleep 500
Clipboard := vBackup
vBackup := ""
ExitApp


; function: dowload URL and return it as variable
UrlDownloadToVar(url, raw :=0)
{
  ; prefix https:// if not found
  if( !regExMatch(url,"i)https?://") )
    url := "https://" url
  try
  {
    hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
    hObject.Open("GET",url)
    hObject.Send()
    return raw ? hObject.ResponseBody : hObject.ResponseText
  }catch err{
      MsgBox % err.message
  }
  return 0
}

Alternatives
Here are some alternative ways to use wttr in FARR
  • Load the wttr URL as embedded webpage in FARR
  • Run a script to get the URL weather text and show as a FARR results line via appcapresults
  • Run a script to get the URL weather text and show it in FARR searchbox via FARR's command line parameter -search
But in all these three cases FARR does not show the unicode weather emoji correctly.
However wttr also has options for richer output formats such as multiline or even mapped weather reports as .png images, and that could probably look quite nice in FARR's HTML view.
« Last Edit: November 20, 2020, 02:30 PM by Nod5 »

skajfes

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 267
Re: FARR mini weather report from wttr.in
« Reply #1 on: November 24, 2020, 11:45 AM »
Cool idea, but wouldn't it be easier to have the weather be shown in the results?
something like an alias with htmlviewurl https://wttr.in/london?format=%c+%t+%C in the results?
It is impossible to make anything foolproof because fools are so ingenious.

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,175
    • Coding Snacks
    • Participated in NANY Challenge Three Times
    • Plugin Coding Medal
Re: FARR mini weather report from wttr.in
« Reply #2 on: November 24, 2020, 11:53 PM »
Cool idea, but wouldn't it be easier to have the weather be shown in the results?
something like an alias with htmlviewurl https://wttr.in/london?format=%c+%t+%C in the results?
Then the emoji did not show correctly when I tested it - see note at the end of my post. But works for only text/numbers.

Original address: https://www.donationcoder.com/forum/index.php?topic=50722.0