Windows 7 – Enable/Disable a Network Adapter with a Keyboard Shortcut

autohotkeykeyboard shortcutswindows 7

I started out trying to use a shortcut to display the Local Area Connection Status window on my desktop by creating a shortcut and assigning it Ctrl+, (comma).

Windows didn't like that, so it added Alt, which ended up being Ctrl+Alt++,.

Since I couldn't figure out a way to eliminate Alt as part of the shortcut keys, I am now trying a different strategy and it's not working. My latest attempt is to use AutoHotkey with the following command:

^,::Run, explorer ::{BA126ADB-2166-11D1-B1D0-00805FC1270E}

Which is what the shortcut target number is, but it won't open the window.

Best Answer

I am going to list the manual steps necessary to quickly enable or disable a network adapter. Then, I will translate these steps into AutoHotkey.


By hand:

  1. Open Network Connections from the command line.

    explorer ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
    

    Network Connections

  2. Once the window is active, press Space to set the focus to the list of adapters.

    list

  3. If the adapter you want to enable/disable is currently selected (i.e. the 1st` on the list), skip to Step #5.

  4. If the adapter is not selected, press Right until it is selected. For example press Right 1 time if the adapter is 2nd on the list, 2 times if it is 3rd, etc.

    2nd

  5. Right-click the adapter and press Down to highlight the Enable or Disable option.

    disable

    enable

  6. Press Enter to Enable or Disable.

  7. Close Network Connections.


Autohotkey:

Using the keyboard shortcut Ctrl+,

^,::

   ;1.
   Run, explorer ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}

   ;2.
   WinWaitActive, Network Connections
   Send, {Space}

   ;3. & 4.
   ;If the adapter is not the 1st, navigate to it.
   ;For example, without the comment (semi-colon):
   ;    Send, {Right 1}
   ;if it is the 2nd adapter.
   ;    Send, {Right 2}
   ;if it is the 3rd, etc.

   ;5.
   Send, {AppsKey}
   Sleep, 250 ;adjust as needed
   Send, {Down}

   ;6.
   Send, {Enter}

   ;7.
   WinClose, Network Connections

   return
Related Question