Autohotkey Week: Day 4 – Launching Apps and GUI
Friday 21 August 2009 - Filed under Code
So last session we looked at using the clipboard. Today we’ll explore using Autohotkey to launch applications and build a very simple GUI.
I’m always amazed at the effort people go through to launch applications. Desktops full of icons, long Start menus, quick launch bars full of icons. All those take an amazing amount of time to process through, find your app and click.
With Autohotkey we can reduce all that searching down to one simple keystroke. I start CFBuilder many times throughout the day by simply clicking F6:
;F6------------------------------ SC040:: Run C:\eclipse-bolt\eclipse.exe -vm "C:\Program Files\Java\jre6\bin\javaw" vmargs -Xms512m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m return
This is really straightforward – SC040:: translates to the F6 key on my Microsoft Natural keyboard. I then simply execute a standard Run command and point it to the Eclipse executable with the appropriate startup flags appended.
Now I click F6 and CFBuilder starts. No hunting, searching, digging through menus, etc. I have a series of 3-4 programs I use very frequently all assigned to hot keys for easy startup.
Autohotkey is far more than text replacement and application shortcuts. You can also build complete GUIs with Autohotkey. I’ll direct you to the documentation online if you want to pursue this but I will show you a very simple example.
At work I’ve been trying to keep better track of my time throughout the day and stumbled across this Autohotkey script to ask for user input every XX minutes and write it out to a text file:
SetTimer, #a,900000 #a:: ; Show the Input Box to the user. inputbox, text, Diary,,,300,100 ; Format the time-stamp. FormatTime, CurrentDateTime,, MM/dd/yyyy h:mmtt ; It will look like 9/1/2005 3:53 PM ; Write this data to the diary.txt file. fileappend %CurrentDateTime% | %text%`n, c:\diary.txt return
Here we’re assigning our script to WIN+A, and using the SetTimer function to click that every 900000 milliseconds. When you click WIN+A (or the timer clicks it) an input dialog will be displayed where you can enter text. I’m also writing a time/date string to include as well. This data is then appended to a defined text file – in this case diary.txt.
So I end up with a .txt file containing a list of things I do throughout day:
08/20/2009 2:05PM | Complete weekly report
08/20/2009 2:21PM | Surf Reddit
08/20/2009 2:35PM | Get Diet Coke
08/20/2009 2:50PM | Work on Bug-123
The Autohotkey site has some much more complex GUI examples I’d encourage you to check out if this interests you.
Next post we’ll wrap this up, and I will provide some links to similar tools and other resources that will help you get started with Autohotkey.
2009-08-21 » Jim Priest
7 September 2009 @ 11:11 pm
Thank you, your example helped me a lot. I couldn’t figure out the relation of FileAppend and Gui, Submit. Again, thank you very much. Also, more than just some HTML is OK lol jk.
15 June 2010 @ 4:11 pm
Fantastic post which I have only just discovered after Googling for Autohotkey stuff. I really like the timer diary script- awesome!