Enable/Disable a network adapter with a keyboard shortcut

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

Just go to the screen where the adapter icon is located. Right click and create shortcut (it won't allow to add shortcut to that window but it will allow it to be created in desktop). When you want to enable or disable the adapter just right click the icon on your desktop and click enable or disable.