• Intro to AutoHotkey HotStrings with AutoHotkey Intermediate AutoHotkey GUIs are Easy with AutoHotkey Intro to DOS & AutoHotkey AutoHotkey FAQ AutoHotkey FAQ

AutoHotkey GitHub Webinar: Become an amazing AHK Programmer in 2020

AutoHotkey Github WebinarWe had an awesome webinar today! Jean Lalonde, author of Quick Access Popup, lead us on a great webinar today regarding how to use GitHub to with our AutoHotkey scripts & programs.  BTW we streamed the webinar live to this AutoHotkey Facebook group.

AutoHotkey Podcasts Highlighted

Ways to make money with around AutoHotkey  

Selling Software Group Discussion   

  • Jackie Sztuk
  • Ryan Wells
  • Jean Lalonde
  • Raptor X
  • Charlie Simmons / Tank
  • Joe Glines

Do people see what needs Automation?

Script Highlight

taskManager by fenchai23

TaskManager

AutoHotkey GitHub Webinar

Video Hour 1: High-level overview
Video Hour 2: Finishing up on GitHub

Here’s the deck shared by Jean Lalonde during the webinar

 

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)

Use AutoHotkey to push clipboard to the Internet for rapid sharing

clipboard to the InternetAutoHotkey Merchandise-White Stress ballI work with people around the planet on a daily basis.  🙂  Being able to quickly share my code with my collaborators is super-easy with this AutoHotkey script that allows me to push my clipboard to the Internet.

Here is a short video demonstrating the script

AutoHotkey Bottle 3Code showing how I push my clipboard to the Internet

#SingleInstance, Force
;***********clipbin / ahkbin on ahkscript.org *******************
#c:: ;Windows C will copy selected content, paste to ahkPasteBin and leave URL on your clipboard
	SendPlay, ^c ;copy selected text to clipboard
	ClipWait, 1 ;wait for clipboard to be populated
	If ErrorLevel ;If nothing was copied to clipboard after 1 second
	{
	MsgBox, No text was sent to clipboard ;let user know nothing was copied to clipboard
	Return
}
Clipboard:=mepaste(clipboard,"Your Name") ;Add your Name or just leave blank
ToolTip, The clipboard now has the following URL: %clipboard% ;show tooltip acknowledging URL is on clipboard
SetTimer, RemoveToolTip, 5000 ;hide tooltip after 5 seconds (this is better than "sleep").  Easy to change
;~ run %clipboard% ;Uncomment if you want to have it pop-open in your default browser
return

;****************Function for pasting to ahkscript.org pastebin****************
MePaste(Content,Name:=""){
	Pbin:=ComObjCreate("WinHttp.WinHttpRequest.5.1") ;create object
	Pbin.Open("POST", "http://p.ahkscript.org/", False) ;set-up POST request
	Pbin.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") ;set header for API call
	Pbin.Send("code=" UriEncode(Content) . "&name=" UriEncode(Name) . "&announce=on&channel=#ahkscript") ;send payload / Envelope
	if pbin.Status()!=200 { ;if doesn't return 200 then there was a problem
		MsgBox Something went wrong ;let user know something went wrong
		return
}
	return Pbin.Option(1) ;return url to user
}
;*********************URI Encode data*****clipboard to the Internet************
UriEncode(Uri, RE="[0-9A-Za-z]"){
	VarSetCapacity(Var,StrPut(Uri,"UTF-8"),0),StrPut(Uri,&Var,"UTF-8")
	While Code:=NumGet(Var,A_Index-1,"UChar")
		Res.=(Chr:=Chr(Code))~=RE?Chr:Format("%{:02X}",Code)
	Return,Res
}
;**************Timer to remove tooltip
RemoveToolTip:
SetTimer, RemoveToolTip, Off ;disable the timer
ToolTip ;clear the tooltip
return