Click here to Skip to main content
15,885,188 members
Articles / All Topics

How AutoHotKey Saved the (Visual Studio) Day

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
19 Aug 2017CPOL2 min read 5K   2  
How AutoHotKey saved the (Visual Studio) day

Most of my development time is spent using Visual Studio, and I have grown quite attached to many of the keyboard shortcuts. Specifically, the “Save All” shortcut. By default, this is mapped to the hotkey combination, CTRL+SHIFT+S. I hit this shortcut all the time….like, every time I stop typing and definitely before I build.

For many years, I’ve done this with no particularly bad side effects. That is until Microsoft Communicator became Microsoft Lync and overrides the Ctrl-Shift-S keyboard shortcut.

The Problem

I frequently use Microsoft Lync to share my desktop with remote workers or vice-versa. This works pretty well and is reliable. However, hitting Ctrl-Shift-S during a Lync sharing session will end the sharing session without any hesitation or confirmation. This wouldn’t be so bad if it only took effect when the Lync window is active, but that’s not the case. It’s registered globally, so the sharing is killed when I’m just trying to Save-All in Visual Studio.

There’s another unfortunate side effect where if you’re in control of a remote sharing session, and you hit Ctrl-Shift-S, not only will you end the sharing session, but you’ll also leave the remote computer’s keyboard in an unusable state. What happens is that the Ctrl and/or Shift key gets logically stuck in pressed state. So anything the remote user (that you’ve been disconnected from) tries to do with keyboard executes as if the user is holding down the Ctrl and/or Shift key. As you can imagine, this causes all sorts of undesirable side-effects.

By the way, the fix for the stuck keyboard is to have the user press the Ctrl key, release, press Shift key, release.

The Fix

Lance Hilliard has created a AutoHotKey script to effectively disable the Ctrl-Shift-S keyboard shortcut for Lync.

I don’t use AutoHotKey regularly, so I created a standalone EXE from Lance’s script and I just keep it running in the background.

This turned out to be an easy task. Steps follow:

  1. Download the AllowSaveAllInVisualStudioWhenLyncScreenSharingIsBeingUsed.ahk script from Lance’s github store.
  2. You’ll need to use the Ahk2Exe utility, so download it if necessary. If you’re already using AutoHotKey, you probably already have it in the Compiler folder in your AutoHotKey install directory.
  3. From a command-line prompt, use the Ahk2Exe.exe utility to convert the script into a standalone EXE.
    Here’s the command I used – you’ll need to adjust your paths accordingly:
    Ahk2Exe.exe /in "..\Extras\Scripts\AllowSaveAllInVisualStudioWhenLyncScreenSharingIsBeingUsed.ahk"
  4. Now just launch the newly-created EXE and let it run in the background.

Conclusion

I have used this solution for a while with no issues. I use Visual Studio keyboard shortcuts extensively, but I don’t really use the Lync shortcuts at all. That makes this a perfect solution for me. If you have any ideas for improvement, well, that’s probably why it’s on GitHub, so go ahead, fork and commit to your heart’s content!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --