1. I needed to use pre-made code (snippets) to cover all the concepts in less than 50 minutes
2. To better compare the two implementations I wanted to also compare just the code snippets in another editor (sublime)
Two weeks ago me and John Sonmez did a podcast with John Papa on Get Up And Code! And he talked about his Pluralsight course on public speaking, I had watched it and he had talked about a tool called AutoHotKey – which he recommended for code snippets as it wasn’t editor specific.
THIS THING IS AMAZING
Nothing new, but the first time I actually realized how much simpler my life could be with macros. And now I want to share this with you. Let’s define some words:
Basically the same as shortcut keys, keys that when combined in a certain combination leads to a certain action. Such as Window + D gives you the desktop, and Windows + P second screen options.
Software that makes systems self-acting and/or self-regulatory.
Something that should happen
Predefined actions (scripts) that is run when you want. These are often used to simplify repetitive tasks, and benefits of macros are:
- • Reliable (same set of actions, nothing is forgotten)
- • Less manual work (time saving)
- • Fast (speed)
- • Sharable actions (macros and scripts can be shared)
A windows keyboard macro program- or as they say:
“Fast scriptable desktop automation with hotkeys”
Records your actions and saves them as a macro so you can reply those actions. Excellent for long macros.
So we have the words down now, and basically all you need to know is that:
a. You can tell your computer what to do by writing a script or several
b. Scripts for one particular action/result/goal is called a macro
c. You can call these macros by using shortcut keys, also referred to as hot keys
d. AuoHotKey is a program that allows you to create macros for Windows
e. It is VERY simple, and AWESOME
Here are the steps for your very first script (courtesy of AutoHotKey):
1. Download and install AutoHotkey.
2. Right-click an empty spot on your desktop or in a folder of your choice.
3. In the menu that appears, select New -> AutoHotkey Script. (Alternatively, select New -> Text Document.)
4. Type a name for the file, ensuring that it ends in .ahk. For example: Test.ahk
5. Right-click the file and choose Edit Script.
6. On a new blank line, type the following: #space::Run www.google.com
The documentation they have is really good, with an active forum with plenty of pre-made scripts!
I have four scripts that I’ve made and use a lot:
- A script for each my sessions that opens all the programs and files and projects I need for a session (slides, code project etc). It also sets up my environment (closes Skype and so on).It also runs a script that creates shortcuts to all my code snippets (see below) for that demo, as well as a backup so I fast can get to a working project if something gets messed up.
- .Scripts with code snippets
- Email scripts with pre-defined email replies that I can also use in any email client, or any other communication channels. The replies pastes in the recipient’s name.
- I’ve disabled my CapsLock button and you need to hold down Ctrl to enable it
Keep in mind I’ve only used this tool for a few days, and this is my first experience with Macros, so I bet I’ll come up with some more cool and complex stuff 😀 I made a simple app (it’s not done yet) for family members so they can use this tool as well even though they aren’t into programming/scripting at all 🙂 – but I bet I can get them into it 😉
Here is the script for email snippets that inserts copied text:
clipboardBefore = %clipboard%
ClipBoard = Hi %clipboardBefore%, I’m current out of office. `r`n
clipboard = %clipboardBefore%
In case you are wondering what is happening in that script:
And here is the disable Caps Lock one:
There are several cool things you can do, and here are some popular scripts from the site Softwaretalk.info. These are some very simple get started scripts, such as:
- Poor man’s SnagIt
- Make window transparent on key press
- Move window from the left monitor to the right monitor and other way around
- Middle mouse button in combination with mouse wheel scrolling activates Alt-Tab (down) andShift-Alt-Tab (up)
- Look up selected text in google
I’ll write up a longer blog post about advanced scenarios – this was more of an introduction, and I’ll make sure to publish the app somewhere on the blog.
I’ve also scheduled a blog post on AutoScriptWriter, so keep an eye on this site 😉
And please share what your best macros, bragging is very welcome,- I love hearing about cool stuff- and so does everybody reading this blog 😀