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

*          *          *

Library Benefits

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

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

Build a Barebones Web Browser Using the AutoHotkey ActiveX GUI Control

Want to Add a Web Page to a Graphical User Interface (GUI) Window? Use the ActiveX GUI Control!

I’ve often seen the ActiveX GUI control sitting in the AutoHotkey online documentation without investigating it. Only recently when I contemplated adding maps to my IPFind.ahk GUI did my curiosity reactivate my interest. The ActiveX control adds a stripped-down version of an Internet Explorer window to your GUI pop-ups.

The ComputorEdgeScript.ahk Graphical User Interface (GUI) demonstrates a barebones AutoHotkey Web browser without all of the features of today’s bloated software.
Continue reading

Adding Web Links to the AutoHotkey IPFind.ahk Script

While Fixing the IPFind.ahk Script for Listing the Geographic Location of an IP Address, I Added Links for the IP Identification Site and OpenStreetMap

Occasionally, Web page scraping apps fail (or display strange results) due to changes in source page data formats. It usually only takes a few minutes to review the code and make the necessary RegEx adjustments to restore acceptable results. This time while repairing the IPFind.ahk script, I noticed that the Web page source code also offered IP longitude and latitude. I thought, “Why not add a map link to the display window for anyone curious about its geographic position?” The IP site (which I also added as a link) includes a map, but I wanted one with greater detail.

An IP address site can provide a great deal of information—including approximate longitude and latitude.

Note: I recently discussed the Link GUI control in “Turn Web Addresses into Hotlinks for the AHK File Peek Window.”

Continue reading

Working with Classic Units of Measurements (AutoHotkey Tricks)

Figuring Odd or Even, Working with Fractions, and Calculating Quarts, Pints, and Cups

Last time in “Fake Math Tricks Using the Floor() and Mod() Functions (AutoHotkey Tips),” I introduced math techniques based upon the Floor() and Mod() functions. Although making basic calculations more complicated, many age-old units of measurement (e.g. yards, feet, and inches with fractions or gallons, quarts, pints, and cups with fractions) persist in common use among everyday endeavors. By obtaining the results from old-fashion division arithmetic showing quotients and remainders, we can write AutoHotkey routines for calculations in these varied types of units.

In order to provide more insight into how to use the Floor() function (quotient without remainder) and Mod() function (remainder or modulo), I offer a few examples of how to build calculators for these types of classic measurements.

Odd or Even?

Depending upon your line of work, you may or may not need to determine the parity (odd or even) of an integer. As humans, we instantly recognize odd or even with a glance at the last digit (1, 3, 5, 7, 9 odd or 0, 2, 4, 6, 8 even). Computers must make a calculation—the easiest in AutoHotkey divides the number by 2 and looks at the remainder using the Mod() function:

test := 35
MsgBox % Mod(test, 2)=1 ? test " is odd!" : test " is even!"
Continue reading

Fake Math Tricks Using the Floor() and Mod() Functions (AutoHotkey Tips)

Although Not Really Fake Math, These Two AutoHotkey Functions Can Solve Eclectic, Yet Practical, Everyday Problems!

The Irish philosopher George Berkeley proved that mathematics does not exist in reality. It turns out nobody cares! Even though math resides only in our heads, we continue to use it anyway.

Berkeley did not doubt that calculus produced real-world truth; simple physics experiments could verify that Newton’s method did what it claimed to do. “The cause of Fluxions cannot be defended by reason”,[48] but the results could be defended by empirical observation, Berkeley’s preferred method of acquiring knowledge at any rate. Berkeley, however, found it paradoxical that “Mathematicians should deduce true Propositions from false Principles, be right in Conclusion, and yet err in the Premises.” In The Analyst, he endeavoured to show “how Error may bring forth Truth, though it cannot bring forth Science”.[49] Newton’s science, therefore, could not on purely scientific grounds justify its conclusions, and the mechanical, deistic model of the universe could not be rationally justified.[50]

https://en.wikipedia.org/wiki/George_Berkeley#Philosophy_of_mathematics

Fortunately, we don’t need to agree with (or even understand) the above citation to take advantage of the results from mental calculation. Scientists may show concern about the theoretical but engineers only care about what works.

Continue reading

Calculating Dates in AutoHotkey by Adding Years, Months, and/or Days

The HowLongYearsMonthsDays.ahk Script Calculates Time Spans—This New DateCalc() Function Yields New Dates Based on Adding or Subtracting Years, Months, or Days

Allan recently inspired me to write (and helped me debug) an AutoHotkey function for calculating new dates based on entering years, months, and/or days. While not long or involved, the function includes a couple of interesting techniques.

Note: I have no doubt that many others have written similar date-calculating functions in AutoHotkey. This merely represents my stab at it.

The lack of consistency in days between 12-month years (leap years) and the varying numbers of days in months underlies the basic date calculating problem. While AutoHotkey includes a special tool (EnvAdd) for determining new dates based upon adding days, hours, minutes, or seconds to any valid date-time stamp format, writing a more complete date finding function requires accounting for the year and month variables separately.

Continue reading