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

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 AutoHotkey Date Formats and Timespan Calculations

AutoHotkey Date and Time Calculations Require Special Handling—Check Out This List of How-to’s for Working with Dates

Over the years, I’ve written a number of blogs and many chapters about formatting and calculating dates, but one of my AutoHotkey apps that I think most demonstrate the full range of these capabilities include the scripts HowLongYearMonthDay.ahk and DateConvert.ahk.

DateConvertSend
When combined with the HowLongYearMonthDay.ahk script, the DateStampConvert.ahk script directly converts various ambiguous date formats selected in documents or Web pages into the standard datetime stamp format for inserting into the time-span calculating GUI pop-up.

Rather than using AutoHotkey commands for converting the standard datetime stamp into one of the numerous worldwide date formats, this conversion tool does the reverse and reformats selected dates into the universal datetime stamp.

Continue reading

AutoHotkey Speed Tips

A Collection of Techniques for Speeding Up Your AutoHotkey Scripts

I recently received the follow message from an AutoHotkey user perusing my blogs:

Jack, you can’t post false statements like this:

“However, the ternary does not provide better performance than the traditional If-Then-Else statement format.”

The ternary operator is inarguably faster than if/else and I encourage you to try this yourself.

I recently switched the core logic of my JSON parser from If/Else to ternary and saw an incredible speed increase. To the point where I only use If/If Else/Else statements when absolutely necessary (Ex: If I must have a loop in the middle of a check).

You can code entire blocks using nothing but ternary as long as you use proper parentheses, commas, and function calls.

There is a very well done AHK forum post that covers script optimizations and they report that ternary performs FORTY PERCENT FASTER than if/else statements.

Not sure if hyperlinks are allowed in these comments, so instead I’ll advise googling “AHK How to optimize the speed of a script as much as possible.” The first result should be the article in question. Pages 1 and 4 have tons of script speed gold in them.

I hope you’ll consider correcting/updating this article.

Groggy Otter

Comment on “AutoHotkey Toggles and the Ternary Operator”

I wrote that blog five years ago and I don’t know that I was talking about performance speed. I think I was referring to how the two expressions operate. In any case, I used a poor choice of words and have drawn a line through the comment.

Continue reading

Finalizing an AutoHotkey Script

While No One Actually Ever Completes an AutoHotkey Script, Some People Get Much Closer Than Others

Last June I started a series of blogs on “Finishing and Polishing AutoHotkey Scripts.” (Ironically, I never finished either the script or the series of blogs.) I wrote six articles aimed at making a script more flexible and user-friendly. Once I had added a menu bar to the GUI window, my chosen menu items provided a map to the ultimate finished product. In the course of that work, I introduced a number of methods for enhancing the program.

Continue reading

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.

Continue reading

Measure Multiple Line Segments with an AutoHotkey On-Screen Ruler

Taking the MouseMeasure.ahk Script to the Next Level, We Add Multiple Calculations for Going Around Corners

The original MouseMeasure.ahk script captures a single-length in a straight line—as a crow flies. While this works great for many applications, roads and highways generally wind over travel distances. Depending upon where you’re going, this can cause a significant variation in the total calculation. To return a more accurate overall estimate, we must break the measurement line into shorter segments.

Start the measurement with the Ctrl+LButton Hotkey, then click the left mouse button for each new leg of the journey. Press the Shift key to terminate the last leg and display the total distance.

The original form of the MouseMeasure.ahk script only allows for a sole straight line. To add more legs to our journey (at different angles), we must implement AutoHotkey techniques for:

  1. Terminating one segment and starting a new one.
  2. Tracking the position of each segment, its length, and the total distance traveled.
  3. Refreshing the screen to include all past legs as well as the new leg.
  4. Sending multiple saved data items for each leg to documents and forms.
Continue reading