AutoHotkey webinar: Getting text from programs with AutoHotkey

Blue keyboard key labeled Webinar on a white keyboard, next to Ctrl and Menu keys

Video Hour 1:  High Level: Getting text from programs

General ways (there are more) to get text & the order to try them:

  1. Using COM to extract text from programs like: Excel, Word, PowerPoint, Outlook, IE
  2. Getting Text from PDFs
  3. Using Active Accessibility Viewer & UI Automation
  4. ControlGet
  5. Copy / Paste (when all else fails or when just need a quick solution)A white stress ball with the green AutoHotkey logo being held in a hand, with a laptop keyboard blurred in the background
  6. OCR – Optical Character Recognition

Video Hour 2: Coding and Q&A

Script Highlight: Chrome.ahk by GeekDude

  • Automate Chrome without Selenium
  • Not as robust as COM w/IE but a great start at basic automation
  • Connect to running Chrome (running in Debug mode)
  • Page navigation
  • Get / Set elements & JavaScript Injection
  • Print pages to PDF
  • Capture to Screenshot
  • Some tutorial videos

Resources for getting text from programs

COM– Microsoft’s Component Object Model

Extracting from PDFs

Active Accessibility Viewer & UI Automation

Active Accessibility & UI Automation are built-in Microsoft architecture that can allow you to, programmatically, get text from programs

Let’s see a few examples using:

  • UI Automation via Jethrow
  • Screen Reader – UI Automation by nepter

Two women in an office smiling at a computer screen, one pointing at it while the other sits beside a green bottle on a desk.

ControlGet

On standard Windows controls, you can access them with ControlGet

  • Some things like listboxes, listviews, etc. have some pretty cool capabilities
  • Often newer programs do not use the standard window controls :(

OCR – Optical Character Recognition

 

AutoHotkey webinar: Deep-Dive into File Encoding

Two women smiling and looking at a computer screen together in a bright office, one pointing at the monitor.In this AutoHotkey Webinar took a deep-dive into File Encoding by our guest speaker Jean Lalonde (author of Quick Access Popup)

Video Hour 1:  High Level:

  • Why File encoding matters
  • Pros/Cons of each type of encoding
  • Tools like the File Encoding Lab to help determine a file’s encoding
  • How to set File Encoding in AutoHotkey

Video Hour 2: Coding and Q&A

Script Highlight: BarChart by Learning One

Bar chart with yellow bars showing Jackie 24, Jean 22, Joe 27 and LearningOne 23 as a sample of the BarChart script

(Here is a link to BarChart scripts demonstrated during the webinar)


1) File Enconding in AutoHotkey

(Here is a link to all of Jean Lalonde’s files)
  • Edit and run the AHK script “FileRead.ahk”
  • Load “Demo-UTF-16.txt” with default encoding
  • Load “Demo-UTF-16-No_BOM.txt” with default encoding  -> problem!
  • Load “Demo-UTF-16-No_BOM.txt” with UTF-16-RAW encoding  -> OK!
  • Try the other file enconding available in AHK

2) File Encoding in DOS (code pages)

  • Run the batch file “Type Box.bat” in DOS console (under “Tutorial“ folder)
  • See this ASCII/ANSI file displayed with code pages 1252 (default ASCI/ANSI) and 437

3) Load the File Encoding Lab

  • Run the AHK script “File Encoding Lab.ahk”
  • Loaded bu default “ASCII.txt” (detected CP1252, 7-bit chars)
  • File Encoding Lab tour
    • Binary display on the left side / Normal AHK display on the right
    • Click on the file name to see with Notepad
    • Encoded detected and use the dropdown list to reload with another encoding
  • Load “ANSI.txt” (detected CP1252, 8-bit chars)
  • Load “Box-CP437.txt” (detected CP1252, 8-bit chars)
    • Which encoding will display a box?
  • Load “UTF-8.txt” (detected UTF-8)
    • see BOM (“byte ordre mark” or header) on left side: two first bytes
    • See one byte for “!”
    • See two bytes each for “é”  and “É«
    • See three bytes for “用”

AutoHotkey Merchandise-White Stress ball

4) File Encoding Lab Cheat Sheet

  • ASCII and ANSI
  • Unicode 8-16-32 bits
  • Unicode with/without BOM
  • Unicode Little or Big Endian

5) Real life files

  • QAP Spanish translation
  • QAP Chinese translation
  • Other examples?

Find and click image / Send text to it

** Updated 05/2020** 

While FindText is still a great tool, I recommend you check out the tool I’ve created Automate my Task .  It has many more built-in features as well as allowing you to record multi-step processes, send text, use control clicks & more.

 

Find and click image with FindText()

I recently played with this great AutoHotkey function FindText().  The program is similar to AutoHotkey’s built-in ImageSearch functionality however it works more reliably and does not need a local file/copy of the image.  The name of the function is a bit misleading in that it really just helps you find and click images.

My first video below demonstrates most of the basic functionality of the tool.  The second video shows the usage of the functions that I wrote to help clicking, sending text, etc.

Here is my version of the FindText function which includes the functions I demonstrate in the second video.  If you’d like the hotstrings I used they are below also (mine are in my main AutoHotkey.ahk file)

 

Demonstration of custom AutoHotkey functions to find image and click it.