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.
Fix the Google Maps Compatibility Issue
Before getting on with the discussion of this technique for embedding ActiveX controls, you will need to make a change in your Windows Registry.
As discussed in previous blogs, the AutoHotkey ActiveX GUI control uses the built-in Internet Explorer 11 controls found in Windows. It calls the barebones browser without all the bells and whistles found in mainstream browsers. However, when first attempting to load many of today’s Web pages, you might run into a number of JavaScript errors, a warning, or even a blank window. Internet Explorer requires a Windows Registry entry for AutoHotkey.exe to fix this compatibility issue. (I found the solution at the AutoHotkey Forum.)
Added newKey AutoHotKey.exe REG_DWORD 11001 to HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
https://www.autohotkey.com/boards/viewtopic.php?p=136470#p136470
You can either make this change manually using the RegEdit program (open the Run window (+R), enter
RegEdit
, then click “OK” to open) or run the following AutoHotkey script:
RegRead,KeyValue,HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION,AutoHotkey.exe
If ErrorLevel
RegWrite, REG_DWORD,HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION,AutoHotkey.exe,11001
After making this change to the Registry, most of my errors and strange results disappeared.
Use HTML IFrame to Embed Code in ActiveX Control
Many Web sites allow other Web sites to embed images, videos, and other Web controls in special Web page HTML boxes called inline frames or iFrames. An iFrame acts as a separate Web browser inside the main Web page. You can add these special features from a source site through the use of iFrames HTML tags (<iframe>
…</iframe>
).
Before the widespread use of APIs, iFrame coding offered the commonly accepted method for sharing content between Web pages. Even though it now pushes the API, Google Maps continues to support embedding maps in your Web pages using iFrames (without needing an API key)—although with stripped-down features.
I don’t know what the future holds for iFrame embedding support but so many sites borrow this type of content for their Web pages that most providers likely feel reluctant to completely eliminate it. On the plus side, the results from embedding iFrame content appear cleaner and less busy (usually fewer headings and no pop-up ads) than directly accessing the provider’s Web page.
If you attempt to load other Web content directly into the AutoHotkey ActiveX control without using the iFrame HTML embedding format, you will often get the same look that appears on the main page—with all of the pop-ups and other annoyances. Or, you may get a message suggesting that you sign up for the API. While Google Maps continues to extend access to a stripped-down legacy version of iFrame embedding, the technique requires you to load the content into a real iFrame. That means AutoHotkey must read the HTML code into the ActiveX control—not merely access a Web URL.
Read HTML Code from a Local File
Here’s the trick! AutoHotkey doesn’t need to read the HTML code from the Web. It can access it from a file located on your Windows computer.
I added the following HTML code for embedding a map at a specific latitude and longitude to a file I named GoogleMapIframe.html:
<div style="width: 100%">[googlemaps https://maps.google.com/maps?width=100%25&height=600&hl=en&
This code creates an iFrame window in a Web browser and loads the map (shown above) from Google Maps based upon latitude and longitude (in red). Once saved to my computer, I include the file path and name (c:\AutoHotkey\GoogleMapIframe.html
) in the barebones AutoHotkey GUI browser (discussed in a previous blog):
Gui Add, Edit, w640 r1 vURL, c:\AutoHotkey\GoogleMapIframe.html
Gui Add, Button, x+6 yp w44 Default, Go
Gui Add, ActiveX, xm w840 h440 vWB VScroll Hscroll, Shell.Explorer
ComObjConnect(WB, WB_events) ; Connect WB's events to the WB_events class object.
Gui Show
; Continue on to load the initial page:
ButtonGo:
Gui Submit, NoHide
WB.Navigate(URL)
return
class WB_events
{
NavigateComplete2(wb, NewURL)
{
GuiControl,, URL, %NewURL% ; Update the URL edit control.
}
}
GuiClose:
ExitApp
Then I changed the query in the iFrame from latitude and longitude to city and state (in red) and resaved the file:
<div style="width: 100%">[googlemaps https://maps.google.com/maps?width=100%25&height=600&hl=en&
Reloading the script yields this new city, state map:
In essence, you can use any iFrame HTML code set in an ActiveX control by saving the HTML code to a local text file using the .html or .htm extension, then pull it directly (c:\AutoHotkey\GoogleMapIframe.html
) into the ActiveX control. It works pretty well.
As you surf the Web for searching for content that may enhance one of your GUI apps, look for HTML code generators for embedding content in Web pages using the <iframe>
…</iframe>
tags. You can then save that code to a local HTML file and load it into an ActiveX control by calling the filename.
I tested this technique for YouTube videos and weather maps. They both worked—and without an excess of clutter!
The next step explores the techniques needing for generating local HTML files on the fly to support changing data sources such as those found in the IPFindMap.ahk script.
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.)

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“!
[…] 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, […]
LikeLike