AutoHotkey Tips of the Week: The ComObjCreate() Function for Web Page Downloads, E-Mail, and Text Audio

While AutoHotkey Directly Supports Most Windows Features, the Flexibility of the ComObjCreate() Function Adds More Useful Capabilities—Especially for Capturing Web Data, Sending E-mail, and Reading Text Out-Loud

A number of my scripts use the ComObjCreate() function in various forms. Most of them I copied from the AutoHotkey Forums and modified for my own purposes. In this blog, I highlight the ComObjCreate() applications I use most, then offer a list of other forms of the function you may find useful.

How I Use ComObjCreate()

Synonym Page
The SynonymLookup.ahk script pulls replacement terms for the highlighted word “Page” from the Web.

While AutoHotkey supports many of these features in one form or another, directly accessing the COM (Component Object Model) might provide a solution you can get by no other method. I use the ComObjCreate() function in three ways:

  1. Collect data from Web pages (ComObjCreate(“WinHttp.WinHttpRequest.5.1”)).
  2. Send e-mail directly from an AutoHotkey script (ComObjCreate(“CDO.Message”))—no mail program required.
  3. Use the computer voice to read text (ComObjCreate(“SAPI.SpVoice”)).

While I haven’t found much additional information about the ComObjCreate() function posted on the new AutoHotkey forum, the old forum contains a useful COM Object reference list. You don’t need to know how they work—just how to use them. Continue reading

Using Regular Expressions to Convert Most Formatted Dates into DateTime Stamps (AutoHotkey Tool)

AutoHotkey Offers Many Techniques for Converting the DateTime Stamp (yyyymmdd) into Formatted Dates, But What About Going in the Other Direction? Use RegEx to Identify Date Formats!

DateStampThe HowLongYearsMonthsDays.ahk function calculates the difference in years, months, and days between any two dates. To manually set the two dates, the script employs two DateTime GUI controls—input dates saved in the DateTime Stamp format (i.e. yyyymmdd) and the output in years, months and days. But wouldn’t you find it easier if you could highlight the dates in any document or Web page regardless of format, then use AutoHotkey to convert and copy the DateTime Stamps directly into the DateTime GUI controls? Continue reading

Waiting for a Web Page to Load into a Browser (AutoHotkey Tips)

A Look at Techniques for Ensuring a Web Page Fully Loads Before Continuing an AutoHotkey Script

When writing an AutoHotkey script which uses the Web, I rarely open a browser anymore. I either download the source code to a file (URLDownLoadToFile command) or a variable (Example: Download text to a variable technique). That means I don’t need to wait for a Web page to load into a browser—although as expressed earlier similar issues exist.

Web Page Load MsgBoxOne of the most common reasons for requiring a fully loaded Web page involves AutoHotkey auto-logon scripts which insert usernames and passwords before continuing. If the page download hesitates, the script outruns the Web process and sends the data to an empty browser window. Most of the Web download problems brought to my attention by AutoHotkey users relate to auto-login scripts. Continue reading

Checking Your Internet Connection, Plus a Twist on a Secret Windows Feature (AutoHotkey Quick Tips)

If Your AutoHotkey Script Depends Upon Internet Access, Check for an Active Connection Before Continuing, Plus a Surprising Trick for Accessing Hidden Windows Features

Seven Book AutoHotkey AutoHotkey Library Deal!I’ve written a number of scripts which access the Internet for data: IPFind.ahk for locating where in the world an IP address resides; RhymeMenu.ahk for popping up a list of rhymes for any selected word; SynonymLookup for replacing boring words (the impetus for this blog); AutoHotkey Quick Reference, both the now-defunct AutoHotkey reference tool and the new AutoHotkey reference tool currently under development require the Internet; and (not by me) the GooglePhraseFix script posted on the AutoHotkey forum by aaston86; plus, any script which attempts to launch a Web page. All of these apps require an Internet connection to work. Continue reading