Organizing Windows on the Desktop and Connecting to Network Drives with AutoHotKey

AutoHotKey is a powerful Windows automation tool, capable of doing pretty much anything you could do yourself on your PC. I have a number of scripts I run regularly (or always have running) to speed up my work and/or make it more accurate and efficient.

One of my favorite scripts responds to the key combination of Ctrl-Alt-0 (that's a zero). When I press that combo, a couple things happen:

1) First, the script checks to see if the machine is connected to WiFi, and if so, grabs the name of the WiFi's SSID.

If the SSID matches my home network's SSID, the script can assume I'm at home

2) Next, it captures the number of active monitors connected to the machine

If I'm mobile with the laptop, there will only be one monitor. If I'm at work docked at my desk (and on the local network), there will be three monitors.

3) If the number of monitors = 3 (at work!):

  • It moves three applications (which are almost always open for me) to specific places on those monitors - it arranges my desktop

    I always want Chrome maximized in Window 1, Outlook maximized in Window 3, and Skype for Business tucked into the upper right corner of Window 2.

  • It disconnects any old network drive connections and re-maps the 6 network drives available while I'm at work

4) If the number of monitors isn't 3, but the WiFi SSID matches my home SSID:

  • It disconnects any old network drive connections and re-maps the 4 network drives on my home (Samba) file server.

Since I regularly dock/undock the machine at work, and take it home almost daily, this script ends up saving a ton of time.

The business of disconnecting and reconnecting network drives is handled by a VBScript script, which is described in the article Mapping Network Drives at Multiple Locations.

One last make things more portable, I separated the function for detecting the current WiFi SSID into its own file. I like having libraries of useful and reusable tools like this.

If you want to take a look for yourself, here's the script:


...and here's the utility file to help grab the WiFi SSID:


To work as-is, the comBowenwebUtilityNetworking.ahk library needs to be in a subfolder (named "Lib") to the location of the organize_monitors.ahk script. This concept is explained here on the AutoHotKey web site.


2016-11-16, 10:11 pm