RSS

Tag Archives: automation programs

Windows Automation / Macros with ALT+TAB (it’s a problem, apparently)

In hopes of keeping my inevitable carpal tunnel at bay, I set out in search of a way to automate some of my tasks. Being, unfortunately for this purpose, not on a mac with access to the famous Automator program, I had to find something similar.

All I wanted was to click a few buttons, hit record and be done. So I found just any old automation program, downloaded it and thought I was done.

NOPE.. automation programs in Windows HATE using ALT+TAB .. they freeze up! (The way that worked for me to get out of the freeze is to hit CTRL+ALT+DELETE, and that will stop most automation programs from recording).

Since my desired macro (which is quite fun to do manually, btw) looked like this:

Ctrl+C, Alt+Tab, Ctrl+V, Alt+Tab, Tab, Ctrl+C, Alt+Tab, Tab, Ctrl+V, Tab, Alt+Tab, Tab, Repeat

I had to find another way….

As soon as I let go of the idea that finding and integrating an automation solution was going to be a 2 minute job, I opened my mind up a little to the idea of writing a script, and found AutoHotKey.

AutoHotKey is fairly simple to use once you get over the script-jitters. Here are what I found to be the most helpful pages on the site:

Quick Start Tutorial | Send Keys & Clicks |

And specifically, all I needed to know was the following information:

  • Make a new script by creating a new text document with an extension of .ahk
  • Designate a hotkey (how to write the key names are on this page) by typing it first in the document, and follow it by 2 colons.
  • To have more than one command executed by a hotkey, put the first line beneath the hotkey definition and make the last line a return (just type return on the last line).
  • Typing an exclamation point means the Alt key (while putting an exclamation point in brackets, like so {!} means an actual, literal, exclamation point) and ^ means the Ctrl key.
  • Save the file, and double-click on your .ahk file to load it into an instance of AutoHotKey (you can have multiple instances running for multiple scripts).
  • If you edit your .ahk file, you have to reload it. To do so, find AutoHotKey in your windows taskbar, right-click and choose Reload This Script from the menu that pops up.

They have tons of options, but for a simple macro like mine here’s what I did.

I started out by writing out my script as instructed on the site.

#space::
Send ^c
Send !{tab}
Send ^v
Send !{tab}
Send {tab}
Send ^c
Send !{tab}
Send {tab}
Send ^v
Send {tab}
Send !{tab}
Send {tab}
return

However, that does not work. And here’s why…

AutoHotKey is awesome in that it will do those keystrokes so instantaneously that you can press your hot key, be done, and not even realize that it actually happened. While Alt+Tabbing, Windows brings up its gui for switching programs, and although it can disappear fast, it’s still there while AutoHotKey is pressing these keys for you like a little cyber madman. To counter this, we have to input some delays, like so:

#space::
Send ^c
Sleep 500
Send !{tab}
Sleep 500
Send ^v
Sleep 500
Send !{tab}
Sleep 800
Send {tab}
Send ^c
Send !{tab}
Sleep 800
Send {tab}
Send ^v
Sleep 200
Send {tab}
Sleep 500
Send !{tab}
Sleep 500
Send {tab}
return

And that’s it. ALL done. I ended up padding it with a lot delays through trial and error.

Advertisements
 
Leave a comment

Posted by on February 26, 2012 in Windows 7

 

Tags: , , ,

 
%d bloggers like this: