I've done this in the past with Windows task scheduler and a php+mysqllite script.
The php+mysqllite script just checked to see if it could reach google, if it got redirected, it checked to see if it had a routine for the domain it got redirected to, if so, it ran it. The mysqllite was to keep the cookies for the headless browser I implemented in php. It would probably be a lot less work to just use a greasemonkey equivalent to do the log-in. (with the down side being the browser would pop up and do things every time your scheduler gets tripped.)
The task scheduler trigger will vary from machine to machine. I had one laptop that would log wifi connections as events and they included the ssid so I could filter to only trigger on the ones I cared about.
On my current laptop, it seems the only event that reliably gets fired is the DHCP client connect. Of course, this fries every time I get an IP address and doesn't tell me an SSID.
You can check what events are available for you to trigger off of with the windows event viewer. I just turned on and off my wifi 3 times and checked what events were triggered 3 times in the last hour.