I spent the last week showing everyone I could how slick Jordan's AutoHotKey script for OneNote is. Thanks again, Jordan!
Oh, and Ani has already patched the routine to start a new SideNote automatically in case you don't have OneNote running beforehand. It's just gets easier and easier to send data to OneNote. You can get those changes from his comments here.
A few comments showed up after I posted the article from users who could not get the script working, though. One person said he could not get AHK (AutoHotKey) working on Windows 7, and another was having problems with Vista. I thought this would be a good time to create a simple test matrix for this "addin." Here's what I did.
First, I looked at the functionality of the script. It mimics typing "CTRL+C" in whatever application has focus, then finds the OneNote window, then mimics typing "CTRL+V" to paste into OneNote. Then it restores focus back to the application where you started. Overall, this is pretty simple.
Since CTRL+C and CTRL+V are supported on every version of Windows, there is not a need to differentiate different editions of Windows. We can "equivalence class" Windows Vista 32 bit with 64 bit Windows 2008 server - this functionality is exactly the same. So far, so good. I always look for equivalence classes since they reduce the testing workload I have in front of me.
The focus switching is a little trickier. I'm always leery of depending on the UI for automation, and this automation script is no exception. A simple pop up alert from any application that fires at an inopportune time can steal focus from the application that had it a split second ago. In this case, the "CTRL+V" keys could be sent to a random dialog that opens from any other application that happens to open one and would cause the script to fail. Also, I'm not 100% sure I can get away with treating the way Windows XP deals with focus the same way Windows 7 beta 1 does. To be safe, I decided to test this on Windows XP, Vista and Windows 7 Beta 1.
The last test I wanted to run had to do with the title of the OneNote window. Jordan's code searches for " - Microsoft Office OneNote". I could not remember what the frame of the Home and Student Edition of OneNote had in it, nor could I remember what the trial edition used. I also need to test the non-trial, non-H&S edition. Three more cases.
Here's my first tentative matrix.
At this point, I had three operating systems with three different "types" of OneNote. I can simplify this matrix by realizing the title of the OneNote window does not change from OS to OS. So I decided to test the Home and Student Edition on Windows XP, the trial on Vista and the Enterprise setup on Windows 2008.
This assumption, that the title of the Windows frame does not change, is not 100% accurate. The H&S edition has some text appended to it and reads " - Microsoft Office OneNote non-commercial edition." Since AHK looks for titles that INCLUDE " - Microsoft Office OneNote" instead of titles that are exactly equal to " - Microsoft Office OneNote" , I can get away with this shortcut.
So my final test matrix looked like this:
Then it was just a question of rolling out some HyperV virtual machines for Vista and Windows 2008 and testing. I have a physical machine set up with the Home and Student Edition already. It is a bare bones machine - a slow Celeron process, 512MB of Ram, a 4200 RPM hard drive, low end integrated video, etc… I think the entire thing cost less than $200, and that was the source of my comment that on a slow machine, the copy and paste took a noticeable amount of time. I tested manually copying and pasting from a few different applications on that machine, and in all my tests, the pasting of HTML took a few seconds. On more modern hardware this pasting was much faster. And in all cases, the speed of the AHK was the same as pasting manually, so I'm not too worried about the overhead of this tool causing problems. Other than that performance issue, all tests went fine.
There was some related testing I did to ensure the CTRL+C copy worked with a few different applications – notepad, Internet Explorer, Firefox and Word. They all passed, and this was only a quick check since this test is another example of equivalence classing.
The only caveat I could see that may cause problems was the need to restart AHK after modifying the default file to use WINDOWS+Z to send the currently selected data to OneNote.
I hope those folks who had problems got this working, because it really is useful.
Questions, comments, concerns and criticisms always welcome,
John