Jack’s AutoHotkey Blog

Download AutoHotkey Tricks You Ought To Do With Windows (Sixth Edition) PDF File

This AutoHotkey Tricks Book Includes “Table of Contents” and “Indexes” from Jack’s AutoHotkey Books!
(For other e-book formats click here!)

Get Free AutoHotkey Scripts!

ComputorEdge Free AutoHotkey Scripts Page

The Best Type of Brain Food!
Get Started with AutoHotkey with These Books!

autohotkeybooks670x83

*          *          *

March 5, 2023

I have recently learned the ISP supporting the shopping cart I use for my ComputorEdgeBooks.com AutoHotkey books will drop the product after May of this year. That means the site that will no longer be available for sale of the books. For those who have purchased through the site (or plan to before June), don’t worry. I have downloaded all of the order information and will continue to support the availability of the books in your orders. Just contact me through this blog. If necessary, I will email copies of the books upon request to those who need additional access due to computer crashes or other unusual events.

All the books currently on the site are up-to-date and I currently have no plans for further updates. The books primarily address AutoHotkey version 1.1 with some references and examples of version 2.0. I do not plan to rework the books to address version 2.0 programming. I’m not ready to start such a massive undertaking. My life has taken a different direction.

You may ask if the release of AutoHotkey version 2.0 makes my books obsolete. If you plan to pursue only version 2.0, then, with the exception of Hotkeys, Hotstrings, and scripting techniques, I would have to say yes (at least for 75% of your coding). While the logic in the many 1.1 apps and examples remain useful and the information about Hotkeys and Hotstrings is virtually identical in version 2.0, you would need to convert the commands in the books into version 2.0 functions. This does not present a problem for short examples but can get quite involved for some of the longer scripts. If your primary goal involves implementing Hotkeys and Hotstrings, then you may find my books valuable for some time to come. (I continue to use my many version 1.1 apps, such as QuickLinks and numerous Hotstrings on a daily basis.) Some topics such as Regular Expressions (RegEx) already use functions, making the information in the books 99% compatible with version 2.0.

If you plan to stick with AutoHotkey version 1.1, you may find my books very helpful. Version 1.1 is virtually bulletproof and you will be able to use it for some time to come. Be aware that, in general, AutoHotkey will no longer support version 1.1—not that it needs much support.

You’ll find a great deal of AutoHotkey information in the blogs posted here. They reflect the type of support found in the books. I plan to support this site by paying for its continuation for some time to come. If you find the articles useful, then you can contribute through the “Buy Jack a Cappuccino!” link at the right. (There’s no limit on the number of cups you can buy.) If you decide to buy my books before June 2023, then rest assured that I will find a way to keep them available to you after that date—regardless of any computer catastrophes that may happen to you.

January 31, 2022

I see that AutoHotkey version 2.0 has now moved into beta testing. That means the official release may occur in the not-too-far-off future. It’s important to remember that versions 1.1 and 2.0 are not compatible and use a significantly different syntax. If starting now, I may have used version 2.0, but you don’t have to.

The most recent update to version 1.1 occurred last August. That means future efforts likely will apply only to version 2.0. When I start up my blogging again, I will probably confine my efforts to the new version and how to convert 1.1 scripts to 2.0.

After all these years, version 1.1 offers a pretty solid platform and should continue to do the job for many years to come. (I also think that newcomers will find the current v1.1 a little easier to understand.)

If you want to learn more about the differences between the two versions, see A Peek at the Coming AutoHotkey V2.0.

January 5, 2022

I’ve reintroduced the deep savings for my AutoHotkey Library Bundles.

December 17, 2021

I just updated to Windows 11. For those worried about AutoHotkey compatibility, my most used apps work fine.

October 16, 2021

ComputorEdge.com is now a secure site. Which—since I don’t collect any user information—doesn’t mean very much. When you access the site, you should no longer get warnings and the little lock icon should appear at the beginning of the URL/search field in your browser. If not, refreshing the page should load the secure version.

October 14, 2021

Library Benefits

I see that my provider has ported over ComputorEdge.com to a secure site. I need to do a number of things to update the site—especially the Free Apps page. I’m currently looking into it.

September 19, 2021

I’ve dropped the domain computoredgesoftwareshowcase.com as a blog site. I don’t have the time to invest in keeping it up anymore. For those interested in reviewing the content for historical purposes, I believe it may still be accessible at the original free site URL: https://computoredgesoftwareshowcase.wordpress.com/

Beginning on June 1, something changed in my bit of the AutoHotkey world. I’m not sure whether its just easier to pirate my books or the world is losing interest in AutoHotkey. In any case, a statistically improbable sharp drop-off in the number people purchasing my books forces me to evaluate my efforts.

I thank those many people who have recognized the value of my work and officially made them part of their AutoHotkey resources. I will continue to attempt to answer specific questions raised in the books and this blog. I plan to offer the books at the ComputorEdgeBooks.com (and this blog) until it is no longer economically feasible to maintain the shopping cart.

August 18, 2021

Using the FileSelectFolder command, “Using FileSelectFolder for Windows File Explorer AutoHotkey Menus.”

July 23, 2021

As difficult as I tried to make it, it turned out simple, “Adding Folders and Files from Windows to AutoHotkey Menus.”

July 12, 2021

Basic QuickLinks: “Barebones AutoHotkey QuickLinks App.”

June 21, 2021

Remove computer code from text “Strip HTML Tags from Text (AutoHotkey Quick Tip).”

June 8, 2021

Alternative Web Page HTML Download Techniques (AutoHotkey Tip)

May 31, 2021

Problem solved with OpenStreetMap.org: “Switched IPFind.ahk to OpenStreetMap.org for Reliable AutoHotkey GUI Map Embedding

May 26, 2021

Quite a coincidence, but Google has completely disabled iFrame embedding of its maps just after I published my last blog. Not a problem. I merely returned to using OpenStreetMap.org in my IPFindMap.ahk script. The iFrame technique should continued to work for other non-Google sites which offer iFrame content embedding.

May 24, 2021

Now, the next step, “Embedding Google Maps in the IPFind.ahk GUI (AutoHotkey Web Trick).”

May 17, 2021

Embed Google Maps in an AutoHotkey GUI (No API Required!).”

May 10, 2021

Add a map to your GUIs,”Use ActiveX Control to Embed World Maps in AutoHotkey GUI.”

May 4, 2021

The start of a new exploration, “Build a Barebones Web Browser Using the AutoHotkey ActiveX GUI Control.”

April 26, 2021

GUI Web links plus a couple of other tricks, “Adding Web Links to the AutoHotkey IPFind.ahk Script.”

April 19, 2021

More examples of how to calculate traditional measurement systems, “Working with Classic Units of Measurements (AutoHotkey Tricks).”

April 12, 2021

Here’s a neat AutoHotkey trick worth exploring, “Fake Math Tricks Using the Floor() and Mod() Functions (AutoHotkey Tips).”

April 5, 2021

Determine and future or past day on the calendar with “Calculating Dates in AutoHotkey by Adding Years, Months, and/or Days.”

March 29, 2021

A variation of the HowLongYearsMonthsDays.ahk script eliminating the GUI and multiple selections, “Using Parts to Build a New AutoHotkey Script (HowLongInstant.ahk).”

March 22, 2021

Another useful Regular Expressions (RegEx) technique, “Extracting Multiple Dates from Text Using AutoHotkey RegEx.”

March 15, 2021

Visit past blogs, “Working with AutoHotkey Date Formats and Timespan Calculations.”

March 8, 2021

Script running slow? Check out these AutoHotkey Speed Tips.

March 1, 2021

I’ve added a new menu item to the “Topics and Series” menu bar category located at the top right of this page (“Sending E-Mail and AutoHotkey“).

February 22, 2021

The astrology page for horoscopes change. I fixed it with “Adapting Web Scraping Routines to Changing Web Pages (AutoHotkey Tip).”

AutoHotkey_Tricks_150

February 15, 2021

Posted another series page. This time “Finalizing an AutoHotkey Script.”

February 8, 2021

I’ve started putting together pages listing blogs with a common thread, “Finding Tips at Jack’s AutoHotkey Blogs.”

February 1, 2021

Turn Web Addresses into Hotlinks for the AHK File Peek Window (AutoHotkey Tip).”

January 25, 2021

A Trick for Creating a New Hotkey from a Subroutine (AutoHotkey Quick Tip).”

AHKcoursead1

January 18, 2021

Regular Expressions (RegEx) for Mining Text in Files (AutoHotkey Startup Control).”

January 11, 2021

Peeking at Notes Inside Auto-Startup AHK Script Files (AutoHotkey Startup Control).”

January 4, 2021

Add Submenus to the Auto-Startup Menu to Increase Options (AutoHotkey Startup Control).”

December 28, 2020

Build an icon right-click menu, “Adding Startup Folder Shortcuts to a System Tray Menu (AutoHotkey Startup Control).”

December 21, 2020

Reading the Startup folder, “Collecting File Information from Windows Folders Using 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.)

Continue reading

Using FileSelectFolder for Windows File Explorer AutoHotkey Menus

For Precise Selection of Windows Folders When Loading Files into a Launching Menu, Use the AutoHotkey FileSelectFolder Command

Last time, I mentioned the possibility of using the FileSelectFile command to pick the top-level folder when adding files to an AutoHotkey action menu using the barebones FileMenuLoad.ahk script. Upon further consideration, I realized that the FileSelectFolder command offered a more appropriate solution. Accidentally picking a file rather than a folder for the top-level—although workable—only introduces more complications. The FileSelectFolder command precludes the inadvertent selection of a file.

Continue reading

Adding Folders and Files from Windows to AutoHotkey Menus

After a Little Pondering, I Found Adding Windows File Explorer Structures to an Action Menu Simple

I was wrong when I contemplated using the BoundFunc Object to insert folder and file names into an AutoHotkey action menu. At the time, I thought that the AutoHotkey Menu command did not offer enough flexibility to handle the task on its own. Those concerns included:

  1. The limited number of built-in menu variables severely constrained the information available when clicking a menu item.
  2. Duplicate folder names found in any other folder or subfolder would cause a conflict.

Both of these problems have solutions, but I was afraid that I would need to resort to some complicated gymnastics.

Sometimes, we know too much for our own good. With a toolbox full of tricks, we often devise methods which—although they work—make the coding more complex. Then, rather than rethinking the problem, we dig a deeper hole. That’s how I started out with the rewrite of the barebones QuickLinks script. Rather than stripping the question down to the basics, I started looking for solutions to problems that don’t actually exist.

AHK_user dealt with the menu name problem in “QuickLinks (Menu by folder)” by deriving menu names from the full directory path. This ensured no duplicates for any of the submenus. I surmised that I would need to do something similar.

The script loads folders and subfolders into menus and submenus.

Then, it occurred to me, “Why not just use the folder full path as the menu name?” If it worked, I would not need any Regular Expression manipulation of the folder path and name, plus, I would avoid menu name duplication. I realized that I could also drop the BoundFunc Object for passing data. It all seemed too easy.

Continue reading

Barebones AutoHotkey QuickLinks App

After Many Years, It’s Time to Take Another Look at the QuickLink.ahk Script

Since its early beginnings, the QuickLinks.ahk script (originally introduced as a replacement for the missing Windows 8 Start Menu in January 2013) has evolved both through this blog and others working through the AutoHotkey forum. It has grown in complexity which can make it a little difficult to modify for personal use. Recently, I took a closer look at the core of my version of QuickLinks.ahk and decided that the time has come for a rewrite—at least of the central code.

During the intervening years, I’ve learned a few things and feel I can build a cleaner more universal basic program—at least for the main routine. The same may apply to many of the added features. (Sometimes starting over makes the most sense.)

Continue reading

How to Neutralize Errant Hotstrings (AutoHotkey Trick)

Take Advantage of Hotstring Precedence to Deactivate Unwanted Hotstrings Firing

Sometimes AutoHotkey Hotstrings fire at the wrong time. For example, whenever I put the word AutoHotkey into a document I prefer the full word rather than an abbreviation (AHK). I use “ahk” as the Hotstring—replacing it with “AutoHotkey” in almost all cases.

However, when I started adding the same extension to my scripts, I would get “IPFind.AutoHotkey” rather than the “IPFind.ahk” that I needed. This was exacerbated by the fact that the preceding dot ( . ) caused a Hotstring reset making some of the usual fixes unavailable. I needed to disable “.ahk” as a Hotstring.

The two requirements for neutralizing an errant Hotstring include:

  1. The new Hotstring must appear in the script before the primary Hotstring. The first form of a Hotstring found in the script takes precedence over any following Hotstrings using the same trigger.

    Note: Hotstring precedence only applies to Hotstrings loaded from the same script. The most recently loaded identical Hotstrings from another script takes precedence over any previously activated Hotstrings.

  2. Reset the Hotstring trigger without any replacement.

The following set of Hotstrings disable auto-replacement whenever preceding the activation term “ahk” with a dot ( . ) while continuing to replace all other lower-case forms of “ahk” with “AutoHotkey”:

:B0C?:.ahk::
:C:ahk::AutoHotkey

When activated, the B0 option prevents backspacing, the C option ensures an all lowercase trigger, and the ? option causes immediate execution. Effectively, the activation makes nothing happen—except resetting the Hotstring trigger. AutoHotkey recognizes “.ahk” and does not replace it. Any other form of all lowercase “ahk” triggers “AutoHotkey” as its replacement.

You’ll find other, more complex methods for dealing with special Hotstring situations but sometimes all you want a Hotstring to do is nothing.

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“!

Strip HTML Tags from Text (AutoHotkey Quick Tip)

Use This AutoHotkey Trick to Remove HTML Code from Any Text

Last time in “Alternative Web Page HTML Download Techniques (AutoHotkey Tip),” I mentioned how I updated the GooglePhraseFix.ahk script by aaston86 to get it working again and make it a little more robust. The script uses a Google search page to autocorrect common expressions and people’s names. (It only works if Google thinks you may have made an error.)

For example, if you type “Ralph Nadal” the Spanish tennis player, selecting the name and using the CTRL+ALT+G Hotkey combination changes “Ralph Nadal” to “Rafael Nadal.” It only works for obvious possibilities, but may come in handy for correcting hard to remember spellings (i.e. “Jocavic” turns into “Djokovic”).

I added the phrase “Showing results for ” to the script as a search key in the Google results page. Google includes the phrase when it senses that you may have made a mistake. The original script used the StringReplace command to remove some HTML code and correct any apostrophes ('):

   StringReplace, clipboard, match2, <b><i>,, All
   StringReplace, clipboard, clipboard, </i></b>,, All
   StringReplace, clipboard, clipboard, ',', All

The StringReplace command can work for unchanging HTML tags but you need to add the command for each tag (or set of tags). By using the RegExReplace() function, you can remove all HTML code with one command.

HTML Tag Stripping Regular Expressions (RegEx) Using the RegExReplace() Function

The selected section of the Google page now includes a lot more HTML code than merely italics <i> and bold <b>. Using the following expression removes it all:

   var := RegExReplace(var,"<.+?>")

You don’t need to know anything about AutoHotkey Regular Expressions (RegEx) to use the above RegExReplace() function. The command removes all text found in var bounded by the arrow brackets (< … >).

Suppose you want to copy all the text from a Web page to a file. You could use the URLDownloadToFile command to copy the page source code, then execute the above RegExReplace() function to remove all of the HTML code. Only the plain text remains.

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“!

Alternative Web Page HTML Download Techniques (AutoHotkey Tip)

When One Method for Downloading HTML Code Breaks, Try the Alternative AutoHotkey Command

After noticing that, although I could quickly get the latitude and longitude for any location with a Google search in a browser, when I attempted to download that page using the GetWebPage() function code taken from the AutoHotkey documentation (shown below in the first script), Google stopped me. The Google server denied the download attempt of the coordinates for San Diego with the following statement:

403. That’s an error.

Your client does not have permission to get URL /search?q=latitude+longitude+san+diego+decimal&rlz=1C1GEWG_enUS953US953 from this server.

Thwarted by Google again (see my “Switched IPFind.ahk to OpenStreetMap.org for Reliable AutoHotkey GUI Map Embedding” blog), I wanted to find an alternative source for the same information.

I searched for an unblocked Web page providing the latitude and longitude. I didn’t have to look very far. (The site name appears in the AutoHotkey snippet below.) I wrote the following test code for proof of function:

Continue reading

Switched IPFind.ahk to OpenStreetMap.org for Reliable AutoHotkey GUI Map Embedding

Forget Google Maps for Embedding Simple Maps in an AutoHotkey Graphical User Interface (GUI)—OpenStreetMap Supports iFrame Embedding…and It’s Free!

If you only want a simple reference map for your AutoHotkey GUI, then Google has just made that impossible. Google Maps no longer supports embedding maps in an HTML iFrame. (I wish Google had taken this action before I wrote my last two blogs.) Now, to do anything with Google Maps you must get the API (credit card number required) for even the simplest of things. For many professionals needing the extra features, the API may be worth it. (Google credits $200 each month to low quantity users…at least for now.) But why even bother when OpenStreetMap.org, a public source, offers map embedding free under an open license. Plus, it’s likely to remain free forever.

Last week, I wrote about how to embed a Google map into an AutoHotkey GUI, “Embedding Google Maps in the IPFind.ahk GUI.” Within a day or two, Google blocked all iFrame HTML embedding. (Go figure! I don’t think I’m the only one who might be a little disappointed.) However, that action prompted me to take a closer look at OpenStreetMap.org.

To my delight, I discovered that in my earlier perusal I had overlooked the same type of HTML iFrame embedding that Google once offered (only a week ago)—plus, I found other features that eliminated all of my earlier misgivings about OpenStreetMap.org. Since I had already written the code for adding maps to the IPFind.ahk script using Google, I quickly modified it to use the alternate resource.

While the IPFindGoogleMap.ahk script won’t load any maps, the techniques I introduced in my blogs remain valid. (I plan to leave those blogs intact for future reference.) In this blog, I talk about how to alter the Google Maps IPFind.ahk script to support OpenStreetMap.org.

Continue reading

Embedding Google Maps in the IPFind.ahk GUI (AutoHotkey Web Trick)

Write a Local File to Load HTML iFrame Embedding Code into the ActiveX Control

May 26, 2021, Alert: Wow! That was fast! Google has already disabled this iFrame map embedding technique…at least for Google Maps. Oh, well, I’ve already reverted to using the original IPFindMap.ahk script using OpenStreetMap.org (“Use ActiveX Control to Embed World Maps in AutoHotkey GUI” May 10, 2021). The technique remains valid. I’ll offer another iFrame embedding application soon—this time probably with a weather forecast.

Last time “Embed Google Maps in an AutoHotkey GUI (No API Required!)” I discussed how you can bypass much of the clutter on Web pages by embedding the map, video, or image in an HTML iFrame read directly into the AutoHotkey ActiveX GUI control from a local file. Sites offering this service often supply HTML code generators for copying the appropriate link. Sometimes, as in the case of Google Maps, you will only find the legacy code by searching the Web. (Google wants you to signup for the API.)

I don’t know how long this Google Map feature will work, but for now, it provides a reasonable solution for AutoHotkey users wanting to embed a simple map into an application.

This time, I modified the IPFindMap.ahk script to write the HTML iFrame code to a separate .html file, then use that filename as the destination URL for the AutoHotkey ActiveX GUI control. This allows AutoHotkey to load an interactive Google map for each IP address found in the selected text.

I appreciate this solution because the embedded Google map looks cleaner than the previous OpenStreetMap.org map and displays the foreign map names in English.

Continue reading

Embed Google Maps in an AutoHotkey GUI (No API Required!)

While Not Commonly Advertised, You Can Add a Google Map (YouTube Video or Weather Forecast) to a GUI Without Using an API

May 26, 2021, Alert: Wow! That was fast! Google has already disabled this iFrame map embedding technique…at least for Google Maps. Oh, well, I’ve already reverted to using the original IPFindMap.ahk script using OpenStreetMap.org (“Use ActiveX Control to Embed World Maps in AutoHotkey GUI” May 10, 2021). The technique remains valid. I’ll offer another iFrame embedding application soon—this time probably with a weather forecast.

In my blog “Build a Barebones Web Browser Using the AutoHotkey ActiveX GUI Control,” I discuss a method for viewing Web pages using an ActiveX GUI control. It works fine for my Free AutoHotkey Scripts page, but as soon as I started viewing other common pages such as Google Maps, I ran into problems. If you want to embed a map in your AutoHotkey GUI, then Google wants you to sign up for an Application Programming Interface (API) using a valid credit card. When you register Google effectively gives you the API key free since it offers a $200 monthly credit for each account. Google wants the credit card number just in case…

As part of this initiative, Google has advised that from 16th July 2018, websites using Google Maps are now required to have a valid API key and a linked Google Cloud Platform Account with enabled credit card billing.

Changes to Google Maps API and Google’s New Billing Structure

You can access an extensive amount of information when using APIs and, for many people, that’s the way to go. Although I’ve never ventured into using APIs with AutoHotkey, Joe Glines has published an extensive amount of information—including the tutorial “Connecting to API / Web services.” I’ve considered digging into the topic and may do so in the future.

For now, I plan to demonstrate a trick for displaying a Google Map in an AutoHotkey GUI without signing up for an API. The trick may prove useful in other apps such as playing YouTube videos or embedding weather forecasts in AutoHotkey GUIs without all the extra clutter.

Continue reading

Use ActiveX Control to Embed World Maps in AutoHotkey GUI

By Directly Loading a Map from OpenStreetMap.org into Your AutoHotkey Graphical User Interface (GUI) Pop-up Window, You Can Add Interactive Geographic Locations to All Your Apps

I have some good news and some bad news about using AutoHotkey tools to directly access Web data through the Internet. First the bad news. Since the AutoHotkey tools for downloading and reading Web pages use Internet Explore (built into Windows but no longer supported by Microsoft), Web providers can effectively block access by identifying that user browser. For the good news, you rarely need to use those sites blocking simple little personal apps such as my IPFind.ahk script. So many other sites support location data for IP addresses that I don’t have a problem keeping the script up and running.

For a quick glance at the geographic location of an IP address, insert an OpenStreetMap.org Web window into an AutoHotkey GUI. Hold the mouse cursor over a map and scroll in or out to zoom in or out.

Previously, I had repaired other issues caused by changes in the source Web page and converted the IPFind.ahk script to use a GUI window rather than a MsgBox command. This upgrade facilitated adding links to the app, see “Adding Web Links to the AutoHotkey IPFind.ahk Script,” as well as making the current insertion of interactive maps using the ActiveX GUI control possible. I fixed the IPFind.ahk script problems by switching to another source Web page and added an interactive map from OpenStreetMap.com.

Continue reading