AutoHotkey Webinar- Using Controls with AHK

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

Script Highlight: WinSpy from Alguimist.  Forum version here

SimpleSpy version here

Also, check out all the other tutorials on Controls with AutoHotkey here

Here are the scripts we walked through during the webinar Continue reading

AutoHotkey Webinar-Protecting your Intellectual Property: Trademarks, Copyrights, Patents, Trade Secrets

AutoHotkey WebinarScript Highlight: Multi-Rename Script from Majkinetor.

Here’s a link to the forum post and GitHub.

Here’s my version which has an updated .ahk file (done by Maestrith author of AHK Studio) that will actually run. Continue reading

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

When, 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


  • 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


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


  • 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

;********************Input box***********************************
If (0){
	InputBox,Var,Name gathering,Enter your name,,,,,,,6
	if (ErrorLevel=1)
		MsgBox,,InputBox Example, % "error Level:"  ErrorLevel ": Cancel was hit",13
	if (ErrorLevel=2)
		MsgBox,,InputBox Example, % "error Level:"  ErrorLevel ": Timed out",13

;**********Jean Lalonde Tip: Save Errorlevel 1st as something else can quickly overwrite it!***********************
If (0){
	InputBox,Var,Jean Tip: Name gathering,Enter your name,,,,,,,3
	Err := ErrorLevel
	if (Err=1)
		MsgBox,,Jean Tip Example, % "error Level:"  Err ": Cancel was hit",3
	if (Err=2)
		MsgBox,,Jean Tip Example, % "error Level:"  Err ": Timed out",3

If (0){
	ClipWait,1 ;Wait 1 second for Clipboard to have data
	if (ErrorLevel=1){
		MsgBox  ,, ClipWait example, % "error Level:" ErrorLevel "  : Nothing entered",3

;******On Error ***********
If (1){
	OnError("LogError") ;Put name of function here in quotes.  The function is given the exception OBJECT as a parameter
	%cause% := error
	MsgBox Hello world ;Note, because of error, this is not reached

;********************LogError function***********************************
LogError(exception) {
	FileAppend % "Error on line " exception.Line ": " exception.Message "`n", errorlog.txt
	Sleep, 100
	FileRead, Error_Log,errorlog.txt
	DebugWindow(Error_Log,1) ;Shove into Debug window below
	return true

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.
;**********Example 1****************************
If (0){
	try {  ; Attempts to execute code.
	}catch e { ; Handles the first error/exception raised by the block above.
		MsgBox, An exception was thrown!`nSpecifically: %e%
HelloWorld()  { ; Always succeeds.
	MsgBox, Hello, world!

MakeToast()  { ; Always fails.
	throw A_ThisFunc " is not implemented, sorry"  ; Jump immediately to the try block's error handler:

If (0){
		obj := ComObjCreate("ScriptControl")
		obj.ExecuteStatement("MsgBox ""This is embedded VBScript""")
		;~ obj.InvalidMethod() ; This line produces a runtime error.
	} catch e {
		MsgBox, 16,, % "Exception thrown!`n`nwhat: " e.what ;Note the e is an object
			. "`nfile: " e.file
			. "`nline: " e.line
			. "`nmessage: " e.message
			. "`nextra: " e.extra ; For more detail about the object that e contains, see Exception().

If (0){
	try	SomeFunction()
	catch e
		MsgBox % "Error in " e.What ", which was called at line " e.Line " and message " e.message
	SomeFunction() {
		throw Exception("this really sucked", -1)

;********************Example_4* Disregarding Errors**********************************
If (0){
	ComObjError(1) ;This is optional but not recommended


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

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&A

Script Highlight: EntryForm() by Coco


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 scriptdemonstrated during the webinar.





Resources for Neural Networks

AutoHotkey Forum post-