Even if you are not going scan any photos, if you use a windows PC regularly, you need to know about AutoHotkey. Make any work easier. This is an awesome piece of software. I don't know how I missed it (and and the idea behind it) all my life. What it does is, it can execute a series of keystrokes and mouse clicks with the press of a single key of your choosing. Meaning, we can make the computer do all the repetitive menu navigation and entering of sequential filenames using AutoHotkey. It involves writing a bit of "code", but its easy kid level stuff, nothing like the word implies. Any one can learn to use it but if you are a system admin, this is a must-have. Set up some hotkeys for the other staff and your value will shoot through the roof.
I found AutoHotKey when I had to use Photoshop at work and Photoshop did not allow me to set keyboard shortcuts on the Numpad like how I use Gimp and I had to find a way to remap the Numpad keys to trigger Photoshop default hotkeys. Then I started to map entire sequence of Photoshop hotkeys to single keys. Soon enough, I was using it for all repetitive works. AutoHotKey is Free Open Source Software but it is available only for Windows.
I will show you how to use AutoHotKey in a photo scanning workflow where it has really helped me get work done without hassle.
So, you want to scan and convert your old family photo albums to Google Photo albums? What's the big deal? Just scan them, crop them, upload them right? Well...
- You got to take out all the photos from the albums.
- Lay down upto four photos each time on the scanner.
- Scan the photos.
- Crop the photos into individual pictures and save them.
- Take the photos off the scanner and put in the next four photos.
- After finishing put all the photos back in the album.
- Upload scanned photos to drive or photos.
There are no shortcuts for steps 1, 2, 5, 6 other than keeping the scanner on a stool or something next to you so that you can access the scan-bed while sitting down at your computer. For 3 and 4 we have AutoHotKey!
AutoHotKey (AHK)
Getting started
Get AHK from here. Go through the tutorials. Once installed you can start creating AHK scripts by right-clicking anywhere on the windows desktop or in any folder and selecting New>AutoHotkey Script. Name your script and then right-click on the script file and click Edit Script. The file will open in notepad. There will be some text in the header, ignore those and start writing your code below. When done save, exit notepad, right-click on the script file and click Run Script. An Icon with "H" will appear at the right end of your taskbar, meaning the script is running and your hotkeys are ready for use.Making MS paint scan using a single key.
First I need to find out how to make MS Paint scan using my keyboard alone and then note down the sequence of keys I need to press. For MS Paint it is File menu (Alt+f) just like most windows applications. Then Import image from scanner (m). Now my scanner's software dialog comes up and here I have to press down arrow three times to reach my preferred setting and then "Enter" to scan. Here is how to tell AHK how to do it.
s::
Send !f
Sleep 60
Send m
Sleep 400
Send {Down}
Sleep 100
Send {Down}
Sleep 100
Send {Down}
Sleep 100
Send {Enter}
Return
Send !f
Sleep 60
Send m
Sleep 400
Send {Down}
Sleep 100
Send {Down}
Sleep 100
Send {Down}
Sleep 100
Send {Enter}
Return
The key before the :: is the key that will trigger our sequence of commands. I have chosen "s" to be the hotkey. Send !f means send the keystroke equivalent of "Alt+f". ! means "Alt" and f is "f". Sleep 60 means wait 60 milliseconds before executing the next command. Without "Sleep", AHK will execute the commands in rapid succession without waiting for processes to complete or dialog boxes to open/close etc and the hotkey will fail. {Down} is "Down arrow key" and {Enter} is the "Enter" key. The Return at the end means that the commands for the Hotkey "s" are over. Its that easy with AHK. I am not a coder but I got the hang of it by day one. There are other alternatives to AHK like AutoIt and windows shell scripting which I heard are not so simple.
So type in the code like above in the new AHK script, save it and then run it. Now in MS Paint I hit "s". AHK speeds through the menus and dialogs and the scanner begins to scan and I get this.
I just need to rotate the picture to the right by 90 degrees before I start cropping.
Together this is what the entire script looks like.
You'll see there are a few extras here. The bunch of text in the begining is the header part which I mentioned earlier. Then #IfWinActive, ahk_class MSPaintApp, which makes the following hotkey work only when MS Paint is the active window. Then there is another hotkey "t" which is the same as "e" but stops right before hitting "Enter". I only need to use "t" when I need to select the folder before hitting save so that all the files saved later using "e" will go to that folder.
That's it! We did not need any photoshop or some other image processing software. Just MS Paint and some cheating using AHK. So get AHK, read their documentation, Spend some time to learn it.
Head this quote?
So type in the code like above in the new AHK script, save it and then run it. Now in MS Paint I hit "s". AHK speeds through the menus and dialogs and the scanner begins to scan and I get this.
I just need to rotate the picture to the right by 90 degrees before I start cropping.
Cropping, Saving and Un-Cropping
Using paint's select tool drag select one of the four photos, crop to selection(Ctrl+Shift+x), File menu (Alt+f), Save as menu (v), Save as Jpeg (j), Enter a unique filename, Save (Enter), Undo (Ctrl+z) to get back the other three photos lost while cropping.
e::
Send ^+x
Sleep 500
Send !f
Sleep 200
Send v
Sleep 200
Send j
Sleep 200
Send %A_Now%
Sleep 200
Send {Enter}
Sleep 500
Send ^z
Return
Now "e" will be our hotkey for cropping, saving and un-cropping. ^+x is Ctrl+Shift+x to crop to selection, then there is a long sleep of 500 milliseconds (half a second) for the cropping operation to complete. Everything is straight forward like the earlier code till we reach %A_Now%. This is the AHK code to enter the current time(YYYYMMDDHHMMSS). This will become the filename entered in the "Save as" dialog box. Timecode will give us a unique filename so that no previous files in the folder gets over-written and the files are in the same order as you scan and crop. Then it is {Enter} to save, a half second sleep for the save to complete then a ^z which is Ctrl+z to undo the crop so you can continue with cropping the other photos.Send ^+x
Sleep 500
Send !f
Sleep 200
Send v
Sleep 200
Send j
Sleep 200
Send %A_Now%
Sleep 200
Send {Enter}
Sleep 500
Send ^z
Return
Together this is what the entire script looks like.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive, ahk_class MSPaintApp
s::
Send !f
Sleep 60
Send m
Sleep 400
Send {Down}
Sleep 100
Send {Down}
Sleep 100
Send {Down}
Sleep 100
Send {Enter}
Return
#IfWinActive, ahk_class MSPaintApp
e::
Send ^+x
Sleep 500
Send !f
Sleep 200
Send v
Sleep 200
Send j
Sleep 200
Send %A_Now%
Sleep 200
Send {Enter}
Sleep 500
Send ^z
Return
#IfWinActive, ahk_class MSPaintApp
t::
Send ^+x
Sleep 500
Send !f
Sleep 200
Send v
Sleep 200
Send j
Sleep 200
Send %A_Now%
Return
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive, ahk_class MSPaintApp
s::
Send !f
Sleep 60
Send m
Sleep 400
Send {Down}
Sleep 100
Send {Down}
Sleep 100
Send {Down}
Sleep 100
Send {Enter}
Return
#IfWinActive, ahk_class MSPaintApp
e::
Send ^+x
Sleep 500
Send !f
Sleep 200
Send v
Sleep 200
Send j
Sleep 200
Send %A_Now%
Sleep 200
Send {Enter}
Sleep 500
Send ^z
Return
#IfWinActive, ahk_class MSPaintApp
t::
Send ^+x
Sleep 500
Send !f
Sleep 200
Send v
Sleep 200
Send j
Sleep 200
Send %A_Now%
Return
You'll see there are a few extras here. The bunch of text in the begining is the header part which I mentioned earlier. Then #IfWinActive, ahk_class MSPaintApp, which makes the following hotkey work only when MS Paint is the active window. Then there is another hotkey "t" which is the same as "e" but stops right before hitting "Enter". I only need to use "t" when I need to select the folder before hitting save so that all the files saved later using "e" will go to that folder.
That's it! We did not need any photoshop or some other image processing software. Just MS Paint and some cheating using AHK. So get AHK, read their documentation, Spend some time to learn it.
Head this quote?
"Whenever there is a hard job to be done I assign it to a lazy man; he is sure to find an easy way of doing it."That lazy man is you, with AutoHotKey.