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.

Microsoft’s ActiveX

Introduce in 1996, “ActiveX is a deprecated software framework created by Microsoft that adapts its earlier Component Object Model (COM) and Object Linking and Embedding (OLE) technologies for content downloaded from a network, particularly from the World Wide Web.” No longer supported by Microsoft, the AutoHotkey ActiveX control uses the built-in Internet Explorer to control content from the Web.

The AutoHotkey ActiveX control activates Internet Explorer 11 by storing the component Shell.Explorer in a variable:

Gui Add, ActiveX, w980 h640 vWB, Shell.Explorer

After adding the control to a GUI window, Web browser control methods and events execute actions:

WB.Navigate("https://www.autohotkey.com/boards/")

The Navigate method loads the URL into the newly added IE browser window.

Build Your Own AutoHotkey Web Browser

The AutoHotkey online documentation includes sample scripts for demonstrating how the ActiveX control works. I modified the second script to load the ComputorEdge Free AutoHotkey Scripts page:

Gui Add, Edit, w640 r1 vURL, http://www.computoredge.com/AutoHotkey/Free_AutoHotkey_Scripts_and_Apps_for_Learning_and_Generating_Ideas.html
Gui Add, Button, x+6 yp w44 Default, Go
Gui Add, ActiveX, xm w840 h640 vWB, 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

While not intimately familiar with how everything operates, I noted that the AutoHotkey ComObjConnect() function links the IE object to the class WB_Events which calls the IE function for the NavigateComplete2 event. This merely updates the URL located in the Edit field when responding to any events—including clicked internal links.

I found that the script works in a pretty straightforward fashion—no bells or whistles with the occasional JavaScript errors. I uncovered a fix for a common Web page error which I plan to discuss next time. I need to do more exploration.

I’ve noted that some people are using the ActiveX control to play YouTube videos without all the extra fluff. I’m looking at how to embed maps into a GUI. I also have some other thoughts on how to use this ActiveX tool. I’ll report any progress.

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

2 thoughts on “Build a Barebones Web Browser Using the AutoHotkey ActiveX GUI Control

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 )

Facebook photo

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

Connecting to %s