Create Instant Windows Gadgets Using AutoHotkey Graphical User Pop-ups (GUIs)

One of the Easiest and Quickest Means for Building a Short, Useful PC App Takes Advantage of AutoHotkey GUI Controls—A Review for the Novice Scriptwriter

Many of my sample scripts available at the Free ComputorEdge AutoHotkey Scripts page use the built-in Graphical User Interface (GUI) tools available in the Windows operating system. Taking advantage of these Windows mechanisms demonstrate only one of the many reasons why the free AutoHotkey scripting language affords so much power. With a few lines of code, you can build Windows gizmos for an innumerable variety of applications. The GUI pop-up acts as the primary core for many AutoHotkey scripts. Easy-to-use and only requiring a minimum amount of programming, the GUI makes possible Windows gadgets for almost any use.

While almost all of my books discuss how to use GUIs in a number of different ways, the book AutoHotkey Applications: Ideas and Tips for Writing Practical AutoHotkey Scripts spends a great deal of time discussing various AutoHotkey Graphical User Interface (GUI) pop-ups with example scripts.

AHKcoursead1

Note: Joe Glines recently released a new AutoHotkey course targeting AutoHotkey GUIs. Here’s a link to the course “How to make a Graphical User Interface / GUI with AutoHotkey.”

AutoHotkey GUI Controls

An AutoHotkey GUI pop-up consists of a window containing one or more controls. Each GUI control offers a specific type of graphic which you can add to the GUI window with one line of code. You can mix-and-match the GUI controls in any manner to create Windows widgets or supplement key aspects of your AutoHotkey applications. When you add a GUI control to your script, AutoHotkey automatically creates the window. Add more controls to tailor the purpose of your GUI pop-up.

The following overview of the many GUI controls demonstrates the possibilities and may stimulate ideas for your next script.

The GUI Text Control and Edit Control

The GUI Text control and Edit control offer the basic functions required in most windows—explanatory text and editing fields. As shown in the “Scale Calibration” window in the MouseMeasure.ahk script, the Text controls describe each Edit field for setting the scale for the on-screen image.

The GUI UpDown Control and Progress Control

The UpDown control adds numeric incremental action to any Edit control by attaching the increase/decrease arrows to the end of each. After clicking the “Start” button, the Progress control (blue bar) in the EggTimer.ahk script (shown at right) travels across the GUI as the minutes and seconds countdown.

The GUI Picture and Button Controls

In the LaunchWindow.ahk script, the Picture controls add the digital images sitting alongside the Button controls which launch the individual applications. You can activate the Picture controls to work like the Buttons by adding the same action subroutine as an option.

The GUI Checkbox Control and Adding the Traditional MenuBar

The Checkbox controls allows the selection of individual items on a list. Although not listed as a GUI control, the Gui, Menu command adds a traditional menubar to the top of a GUI window as shown in the ToDoListReg.ahk script:

The GUI Radio Control

Radio buttons provide the user a selection list of a number of mutually exclusive options. The Radio button control only allows the selection of one option.

Create the window at right using the following code:

Gui, Add, Radio, vMyRadioGroup, Wait for all items to be in stock before shipping.
Gui, Add, Radio, , Ship away!
Gui, Show

The GUI DropDownList Control

The DropDownList control offers a method for adding a pop-up menu to a GUI window without taking up too much space. Click on the control to open the menu as shown in the InstantHotstring.ahk script.

InstantHotstringBarebones

The GUI ComboBox Control

The ComboBox control combines a menu similar to the DropDownList with an Edit field for adding new items. The following code creates a ComboBox control:

Gui, Add, ComboBox, vColorPick, Red|Green|Blue|Black|White

The GUI ListBox Control

As an alternative to the DropDownList and ComboBox controls, the ListBox control confines the menu to a fixed-size box. If the number of items go beyond the box limits, AutoHotkey adds scrollbars to the right side of the control. This control prevents long menus from covering the entire screen.

Gui, Add, ListBox, h80 multi vColorChoice, Red|Green|Blue|Black|White<br>Gui, Show<br>Return

The GUI ListView Control

One of the more powerful GUI controls, ListView creates a table of entries suitable for a variety of applications. ListView includes a number of specialized functions for managing the entries.

The AddressBook.ahk script, a personal address and data book which uses AutoHotkey ListView to display entries, maintains a database of names and addresses. It initiates e-mail, inserts addresses into documents, and calculates ages.

Right-click on an entry to send e-mail, insert the address in any document, or calculate ages.

Found in the Legal Terms free scripts listing, LegalListView.ahk uses the ListView GUI control to display and edit the LegalInput.ini file.

The GUI TreeView Control

Similar to the Window File Explorer folder format, the TreeView control creates hierarchical structures. I wrote the RecipeTree.ahk script to demonstrate a practical use for TreeView which did not involve Windows folders.

Similar to the ListView control, TreeView includes a number of advanced functions for manipulating the tree structure. The AutoHotkey RecipeTree.ahk script uses an interesting technique for attaching TreeView branches to GUI Edit control data fields by saving variable names within controlling variables.

The GUI Hotkey Control

When used in conjunction with the Hotkey command, the Hotkey GUI control limits input to valid Hotkey combinations (excluding the Windows key ). In the InstantHotkey.ahk script, the Hotkey control creates temporary Hotkeys for inserting text.

The GUI MonthCal Control

The MonthCal control offers one of the best gadgets for quick-and-dirty scripts. One line of code creates a pop-up calendar with selectable days, months, and years. The AddDate.ahk script uses MonthCal as almost a standalone app.

The GUI DateTime Control

Using two DateTime controls, the HowLongYearsMonthsDays.ahk script calculates the number of years, months, and days between two dates. Click the little down arrow on the right to open a monthly calendar similar to the MonthCal control. Unlike the MonthCal control, you can extend the DateTime control to input the current (or other) time.

The GUI Slider and StatusBar Controls

The ScreenDimmer.ahk script demonstrates the AutoHotkey Slider control as a computer screen dimming GUI. The circled section adds a GUI Statusbar control for displaying brightness level and one-click reset.

The GUI Tab and Link Controls

As a demonstration of how to cull links from a Web page, then add a Link control for each to a GUI pop-up, the WebLinkFindURL.ahk script uses multiple Tab controls to contain the many links in the confined GUI window space.

WebPageLinks
The GUI contains 10 tabs—most with 20 hot links each scraped from the ComputorEdge Free AutoHotkey Scripts page.

The GUI GroupBox and Tab Controls

The “Food Information” GroupBox control in the CalorieCount.ahk script primarily provides cosmetic placement properties to the series of Text and Edit controls. The second Tab control hides the “Food List” accumulated through daily calorie counting.

Next time, I hope to start on series of blogs about the problem of automating Web pages with AutoHotkey.

Click the Follow button at the top of the sidebar on the right of this page for e-mail notification of new blogs. (If you’re reading this on a tablet or your phone, then you must scroll all the way to the end of the blog—pass any comments—to find the Follow button.)

jack

This post was proofread by Grammarly
(Any other mistakes are all mine.)

(Full disclosure: If you sign up for a free Grammarly account, I get 20¢. I use the spelling/grammar checking service all the time, but, then again, I write a lot more than most people. I recommend Grammarly because it works and it’s free.)

Find my AutoHotkey books at ComputorEdge E-Books!

Find quick-start AutoHotkey classes at “Robotic Desktop Automation with AutoHotkey“!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s