How often do you actually use CapsLock – deliberately that is?
Most of the time I hit it accidentally then END UP SHOUTING in emails or Tweets. It’s especially a pain sometimes while coding…
We can stop CapsLock from doing it’s capsy thing using AutoHotkey.
The following remaps the CapsLock key to nothing:
Capslock::
Now the CapsLock key doesn’t do anything, the caps LED on the keyboard doesn’t even light up.
We could also remap CapsLock to F6, so we can hit CapsLock in Visual Studio to do a build:
Capslock::F6
This will trigger F6 in all applications, not just in Visual Studio.
To limit the remapping to only when we are in Visual Studio:
SetTitleMatchMode, 2
#IfWinActive Microsoft Visual Studio
Capslock::F6
#IfWinActive
Here the remapping only occurs if the window title contains “Microsoft Visual Studio”. (The SetTitleMatchMode command tells AutoHotKey to look in any part of the title for the match.
Now, outside of Visual Studio, CapsLock behaves normally, but inside VS it will perform a build.
To learn more about AutoHotkey, check out my Pluralsight course: Personal Productivity & Performance Tools for Windows Developers.
SHARE:
I got bored in Visual Studio double clicking a class, copying to clipboard, then heading to browser then pasting into search box.
I wanted to be able to quickly search for something (e.g. in Google) for whatever word the cursor was currently in. Also in other applications.
I have a Microsoft keyboard that has a calculator key that normally opens the Calculator application. I’ve never ever used this and hadn’t even noticed it until now.
To map this key in AutoHotkey, “Launch_App2” can be used, so to trigger a script whenever it’s pressed: Launch_App2::
I also wanted the default behaviour to automatically go to the first result. Pressing CTRL-calckey just does a normal search and lists all the results for me to peruse.
Here’s the script – note that it’s a bit rough and ready, for example it uses the clipboard (CTRL-C) so this will overwrite anything you have in it. It also won’t work if the cursor is at start of line, etc.
Launch_App2:: ; Do an I'm Feeling Lucky Google search when calc key pressed
Clipboard :=
SendInput, ^{LEFT}^+{RIGHT}
SendInput, ^c
ClipWait, 1
if !(ErrorLevel) {
Run, % "https://www.google.com/search?hl=en&btnI=I%27m+Feeling+Lucky&&q=" Clipboard
}
return
^Launch_App2:: ; Do a normal Google search when calc key pressed
Clipboard :=
SendInput, ^{LEFT}^+{RIGHT}
SendInput, ^c
ClipWait, 1
if !(ErrorLevel) {
Run, % "https://www.google.com/search?hl=en&q=" Clipboard
}
return
Now if i have my cursor in the word “ActionResult” in Visual Studio, hitting the calculator key takes me to MSDN http://msdn.microsoft.com/en-us/library/system.web.mvc.actionresult%28v=vs.118%29.aspx as this is the first Google search result for “ActionResult”.
If you’ve never used AutoHotkey before, to get started check out my Pluralsight course.
SHARE:
AutoHotkey is a free open source tool that does all kinds of cool things, one of which is hotstrings.
Hotstrings allow us to define shorthand phrases that get expanded into full text. For things we type often, creating hotstrings can save us valuable keystrokes.
Once AutoHotkey is installed, we can edit the script and add our hotstrings.
So, if we typed “dontcodetired.com” often, we could define a hotstring like this:
::dct::dontcodetired.com
Now when we type “dct” followed by an ending key such as space or enter, the “dct” gets auto-replaced with “dontcodetired.com”.
If we want the replacement to happen as soon as the last character is typed (in this case the “t”) and not have to press an ending key we add an asterisk after the first colon:
:*:dct::dontcodetired.com
Now as soon as the “t” key is pressed the replacement happens immediately.
To find out more about hotstrings and the other cool features of AutoHotkey, check out my Pluralsight course: Personal Productivity & Performance Tools for Windows Developers
SHARE:
My new Pluralsight course Personal Productivity & Performance Tools for Windows Developers “get more done in less time” has just been released.
It covers a range of developer-focused and general productivity tools that you can mix and match to suit your way of working.
“We’re constantly under pressure to be more productive. Learn how to use these tools to improve your productivity, streamline your workflows, and get more done in less time. ”
The course consists of:
- Reduce Typing with AutoHotkey
- LINQPad – A C# / VB.NET Scratchpad
- Starting Programs and Websites with SlickRun
- Take Control of your Clipboard with ClipX
- Remember What you Did with TimeSnapper
- Making the Internet Work for You with IFTTT
- Free Image Editing with Paint.NET
You can find this course along with my other courses on the Pluralsight author page.
SHARE: