Web Scraping with AutoHotkey 109a- Triggering an EventListener on a page


You ever plugging along on web scraping a page and have a problem with an element (drop down, edit field, radio button, etc) not updating?  Chances are the page has an EventListener watching that element for a specific Event type.  We used to be able to reliably “click” an element or send .fireEvent(“onchange”) / .fireEvent(“onclick”) howe

ver more and more pages are using this newer approach where they build an Event Listener and monitor for events on a given element.

If you’re a non-coder like me, this was very problematic to deal with as the EventListener is located in a different place in the DOM.  In the below video I walk through how to spot the problem and offer up a couple of solutions (like Visual Event) that should greatly help. The second video below demonstrates using my updated AutoHotkey syntax writer.

Triggering an EventListener on a page

Web Scraping with AutoHotkey 109a- Triggering an EventListener on a page

Updated AutoHotkey Syntax Writer

Here I demonstrate using my updated AutoHotkey Syntax writer to provide the needed information for the Events.

Web Scraping with AutoHotkey 109b- AHK syntax writer dealing with Events

Title: AutoHotkey Webinar- Automating MS Outlook and COM

In our first hour of today’s  AutoHotkey webinar we talked about various ways you can automate MS Outlook.  We covered the below scripts:

  1. Creating an HTML email (Also see this video)
  2. Performing mail-merge on the above HTML email
  3. Integrating a mail-merge from an active Excel file  (Also see this video)
  4. Looping over emails in a folder
  5. Creating appointments in Outlook
  6. Creating an address book from looping over emails in Outlook

The second hour dove a bit deeper into using Outlook and Excel.  We also talked through a few user’s questions.

Below is the information that was reviewed in the PowerPoint deck we reviewed:

Script Highlight:

Sift by FanaticGuru uses Regular Expressions and nGrams* to fuzzy match strings

*n-gram is a contiguous sequence of n items

COMComponent Object Model

  • What is COM?
  • Some of the programs COM integrates with:

Creating an HTML email in Outlook with AutoHotkey

  1. Connect to Outlook or Create a new one (but may not deploy right then)
  2. Create a New Mail Item object
  3. Provide values for properties
    1. Specify Account Sending from
    2. Type of email (HTML, RTF, Text)  (Search here for Outlook Constants)
    3. Identify Recipients: To, CC, BBC
    4. Subject line
    5. HTML Body
    6. Attachments
    7. Delivery time (Fuse)
    8. Request Delivery Reciept
    9. Importance
    10. Display / Send
  4. Convert above email to mail-merge with names & email addresses

Resources

AHK Forum:

MSDN resources:

Outlook examples on the-Automator

Stack Overflow

AutoHotkey webinar on COM & Excel

Use Variables/Parameters to pass Methods or Properties in COM w/AutoHotkey

pass Methods or Properties in COMI had wanted to be able to make a function where I pass Methods or Properties in COM.  (this makes it much more flexible and eases updating / maintaining of code.)  Unfortunately it was not as straight-forward as I’d hoped.

Thankfully maestrith, Author of AutoHotkey Studio, had already solved this problem and shared the solution with me!  The code which shows how to pass Methods or Properties in COM is listed below.  While in the video I demonstrate connecting to IE and perform web scraping, the solution is equally applicable to any COM object like Excel, etc.

 

Demonstration Video to pass Methods or Properties in COM

Passing methods or properties as a variable in a COM object

AutoHotkey and Excel Worksheet functions: Mean/Average, Median & Mode

Excel worksheet functionsTypically I like to use AutoHotkey to insert the formula into Excel.  This allows for the user to make changes (or have it update if the  data changes).   Sometimes I just want a given value based on the data at-hand.  This is when it is awesome to be able to call the Excel worksheet functions.  In the below code and video I demonstrate how to call three Summary variables of central tendency: Mean (Average), Median and Mode.   For normally distributed data these will be the same however, in the real world, data is often skewed / non-bell shaped (has kurtosis).  Make sure you review the data to decide which best “summarizes” the data.

In the video I show how I initially planned to create three separate functions (one each summary variable) however with some help from Maestrith (author of AHK Studio) I was able to write one function and pass the method as a parameter.  🙂

Here is the script for Excel worksheet functions

And here is the video where I walk through Excel worksheet functions

Excel & AutoHotkey-Worksheet functions: Mead, Median & Mode