Adapting Web Scraping Routines to Changing Web Pages (AutoHotkey Tip)

When the Horoscope Web Page I Use for E-mails Altered Its Format, I Quickly Adjusted the Script

Last year, I wrote a script that e-mails a daily horoscope to my wife, “E-mail the Daily Horoscope to Yourself (AutoHotkey Trick).” Every morning she receives on her tablet an e-mail containing her daily horoscope. (I don’t send it to myself because I don’t want to know that much about my future—and I don’t listen to advice.) Recently, she pointed out that the e-mail started coming up blank. I immediately realized that the target Web site had changed its source code. (I’ve experienced the same problem with the SynonymLookup.ahk script.) I knew I could repair the Regular Expression (RegEx) in the broken script fairly quickly by following some basic steps:

  1. Access the source code for the target Web page and locate the key text.
  2. Copy the critical portion of the source code, including any unique HTML tags surrounding the target text, then paste the selection into Ryan’s RegEx Tester.
  3. Adjust the RegEx to include key unique tags surrounding the text—then extracting the paragraph.
  4. In the script, replace the old RegEx found in the RegExMatch() function with the new one from Ryan’s RegEx Tester.
  5. Make any necessary adjustments to the RegEx—primarily escaping double quotation marks.

The new horoscope e-mail script now includes more details and a link to the site.
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

Finding Tips at Jack’s AutoHotkey Blogs

With Over 300 Blogs, You Might Find It Difficult to Dig Out the One You Need

I launched Jack’s AutoHotkey Blog in 2015. At that time, I had already published a number of AutoHotkey books but I wanted a way to stay in touch with new users and changes in AutoHotkey.

On the right of the Main Menu bar, you’ll find the “AutoHotkey Topics and Series” menu.

Previously, I had published AutoHotkey articles on the old ComputorEdge Magazine site. However, circumstances and expense forced me to take down the database-driven site. Hundreds of my AutoHotkey tips disappeared from the Web. I didn’t want to do it, but times change. (You can find many of those lost tips in the AutoHotkey books available at ComputorEdge E-Books and even more no-longer-published tips—as well as many more recent ideas—in the book A Motley Assortment of AutoHotkey Tips. The major advantage to using the e-books lies in their organization and searchable indexes.)

When I wrote the new articles for Jack’s AutoHotkey Blog, I avoided duplicating the techniques in previously published articles. While a few important techniques rear their heads on multiple occasions (e.g. the Standard AutoHotkey Windows Clipboard Routine), I concentrate on creating practical applications not previously discussed. My biggest fault lies in the fact that I never finish anything.

Continue reading

Turn Web Addresses into Hotlinks for the AHK File Peek Window (AutoHotkey Tip)

Using the AutoHotkey GUI Link Control to Display AHK File Notes Allows You to Turn Web Links Hot

While perusing the notes in various .ahk scripts using the subroutine ReadNotes—which I had added to the AutoStartupControl.ahk script and discussed in my blog “Peeking at Notes Inside Auto-Startup AHK Script Files (AutoHotkey Startup Control)“—I noticed that many scripts included URLs to reference sites. A common practice used by scriptwriters when giving credit to another script or offering additional information about the source, these sites can offer valuable insight or resources. Usually, a Web address appears as a complete URL including the HTTP(S)://. I wondered, “Wouldn’t it be great to just click a link in the Notes window to load the page?”

Since we write AutoHotkey scripts in plain text, attempting to provide hotlinks inside the file using HTML code (or other techniques) doesn’t make much sense. I can open the file and copy the Web address—pasting it into my browser, but a hotlink in the Notes window would save a lot of time. I immediately switched from using the Text GUI control to the Link GUI control. By inserting the Link control into the AutoStartupControl Notes GUI window, I can turn any URL into a hotlink—as long as I use a Regular Expressions (RegEx).

The Link GUI control in the Notes window can turn any fully formed Web address into a hotlink for immediate access.

Using the Link GUI control comes with a couple of foibles, but, for the most part, it behaves in a manner very similar to the Text GUI control.

Continue reading