Sample Macro

Toggle Online/Offline

Written by Kevin Heaton, Insight Software Solutions, Inc.

What it does

Opens the Network Connections control panel dialog and toggles the computer Online or Offline.

When reading email messages it is generally clear which ones are legitimate and which ones are spam or junk. However, occasionally, it is difficult to tell. The simple act of opening an email message can signal to the sender that you have opened it and that the email address they sent it to is valid. This can result in more spam being sent to that email address. Some email clients have a setting that prevents the display of embedded images for just this reason.

My habit has been to disconnect my computer from the internet before opening questionable email messages or before running programs that I am not certain about. At first, several years ago, I would physically disconnect the network cable from my computer. Then later, conveniently, a feature was added to the internet security spftware that I use to toggle the network connection by clicking on an icon in the command line. This was a great convience that still allowed safe viewing of questionable messages.

This year I updated that internet security software. Much to my dismay, this useful feature was removed. I immediately began my search for an alternate solution. Again, Macro Express came to the rescue and my ‘Toggle Online/Offline’ macro was born.

To install

Download the macro file umonlineoffline.mex and save it to your hard drive. Open the macro file or import the macro into your existing macro file by clicking File, Import, Import Macros.

To use

I include this macro in a popup menu macro so, as written, it does not have a macro activation. You can run it from the Macro Explorer window by highlighting it, right-clicking and selecting Run Macro Now. Or you may choose to add it to a popup menu or add some other activation.

How it works

This macro opens the Network Connections window, finds the ‘Local Area Connection’ item and right-clicks the mouse to disable or enable it.

The items listed in the context menu (that comes up when you right-click) are slightly different when you are online or offline. Because of this the macro sends both the keystroke to enable and the keystroke to disable your Local Area Connection. The invalid entry causes Windows to beep so the macro also mutes and unmutes your speakers.

As it runs, this macro uses the new ‘Lock Keyboard and Mouse’ command available in Macro Express Pro. This prevents the user inadvertently causing the macro to fail by moving the mouse or pressing a key on the keyboard. As an added convenience, the position of the mouse is saved when the macro begins and restored when it end.

Requirements

 – Windows XP
– Macro Express Pro
– This could be written for Macro Express 3 but some functionality would be lost.