• Intro to AutoHotkey Intermediate AutoHotkey Intermediate Objects GUIs are Easy w/AutoHotkey Painlessly switch from V1 to V2

AutoHotkey Webinar-When, Why and How to use Error Checking on Runtime Errors

webnar 300x200When, Why and How to use Error Checking on Runtime Errors

Video Hour 1: High-level overview: Hour 1
Video Hour 2: Q&A: Hour 2

Script Highlight: Detecting Carrier type, location, company from a phone number.

When / Why to use Error Checking

For general troubleshooting of your own code use:

  1. Msgbox
  2. Debug in SciTE , AHK Studio or Notepad++
  3. Watch this Webinar on Debugging & Troubleshooting

Runtime Errors– An error that occurs during the execution of a program

  1. Use Error Handling to diagnose Runtime Errors for scripts distributed to clients
  2. Allows you to adapt the reported error as something meaningful to non-coders
  3. Frequently provides information you cannot get elsewhere
  4. Easy to Log the error with additional information so we can have context of what is frequently going wrong  (Users are typically terrible are providing enough information)
  5. Can prevent the script from “locking up” / throwing an Error that is confusing to the client
  6. Build-into your Class / Library to help others utilizing your code

ErrorLevel and OnError

ErrorLevel

  • Built-in variable which indicates success/failure of many (84) commands
  • A value of Zero means success. Most commands return a 1 for failure but some have values higher than 1

OnError

  • Specifies a function to run automatically when an unhandled error occurs.

OnExit

  • A Built-in Function name/Object to call when your script is exiting
  • It can help understand why/when your script exited

There are 84 Built-in Command/Functions with Error Level

Try / Catch / Throw / Finally / Exception

  • Try– Will “try” to execute a given line(s) of code
  • Catch– Specifies the code to execute if an exception is raised during execution of a Try statement.
  • Throw– Signals the existence of an error allowing a Try/Catch command to display info about this error. This object allows you to personalize the message / information available
  • Finally– Used in conjunction with Try or Catch. Ensures that one or more statements (commands or expressions) are always executed after the execution of a try statement
  • Exception()- An Object with properties to be accessed from Catch’s OutputVar
  • Message:An error message or ErrorLevelvalue.
  • What:The name of the command, function or label which was executing or about to execute when the error occurred.
  • Extra:Additional information about the error, if available.
  • File:Set automatically to the full path of the script file which contains the line at which the error occurred.
  • Line:Set automatically to the line number at which the error occurred.

 

Best Practices / Tips & Tricks

  1. Remember –in Try / Catch  the Exception thrown is an object.
  2. Not all programs accurately report ErrorLevel when run from RunWait
    1. –If this is the case, think of other ways to determine if your script finished correctly
  3. Unless you truly have a need, don’t worry about Throw or Finally.  Most developers do not use them
  4. While typically used as pairs, Try can be used without Catch
    1. — in this case, it is used only to bypass the error message
  5. ComObjError()–  can be set to 0 to disable COM errors (but isn’t recommended)
  6. Copy the ErrorLevel value to your own variable immediately  after the command that  caused the error (before its content is changed after executing another command)

AutoHotkey webinar: Getting text from programs with AutoHotkey

webnar 300x200

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)Squishy Ball 2
  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

AutoHotkey Bottle 3

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- Intro to Neural Networks

webnar 300x200

Video Hour 1:  High Level: Intro to Neural Networks

Our guest presenter, Giordanno (Gio) Sperotto did an amazing job covering an intro to Neural Networks.

  1. Present some current uses for neural networks (examples to light up curiosity in the subject)
  2. Introduction to the algorithms (Using a simple excel sheet and Paint.NET file, the aim is to provide an overview of a very (VERY) simplified step-by-step process)
  3. Discuss the example in the tutorial (going through the problem and the .ahk code)
  4. Discuss AutoHotkey as a possible tool and also some other possible tools (Python, TensorFlow, etc)
  5. Brief Talk about some existing online courses and content (Udacity, Udemy, Youtube Channels, etc)
  6. Brief Talk about Jobs and entrepreneurial opportunities
  7. Discuss other advanced concepts (Bias, Activation Functions, Learning Rate, Cost-Function, Multiple Layers, BackPropagation, Convolutional NN, Recursive NN, Supervised and Unsupervised Learning, etc)

Video Hour 2: Coding and Q&ASquishy Ball 2

Script Highlight: EntryForm() by Coco

entryForm

 

Easy / quick way to create GUIs to capture user input with AutoHotkey.  Data captured is dumped into an AHK object.

Here is a link to EntryForm Example and script demonstrated during the webinar.

 

 

 

 

Resources for Neural Networks

AutoHotkey Forum post-

Articles

YouTube

AutoHotkey Bottle 3

AutoHotkey webinar: Deep-Dive into File Encoding

AutoHotkey Bottle 3In 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

barchart

(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?