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

AutoHotkey Webinar 10/2021: Creating and Using AutoHotkey Functions

AutoHotkey webinar AutoHotkey functionsHour 1: Intro to Functions

Hour 2: Q&A Styles and helping Attendees

Script Highlight:  Times around the world by jeeswg

The Automators’ Podcast 

#113: 7 reasons to talk to others about your programming
#114: 5 tips how to reduce the amount of personal support you provide
#115: What is an idea worth? How much $ should you pay the “idea person”?

Resources presented in Webinar

What is a Function?

  • A function is similar to a subroutine (Gosub) except that it can accept parameters (inputs) from its caller.
  • In addition, a function may optionally return a value/values to its caller.

66 Built-in AHK Functions https://www.autohotkey.com/docs/Functions.htm#BuiltIn

  • Polythene’s Command functions https://github.com/Paris/AutoHotkey-Scripts/blob/master/Functions.ahk
  • jeeswg commands as functions (AHK v2 functions for v1) https://www.autohotkey.com/boards/viewtopic.php?f=37&t=29689

Some main benefits of Functions

  • They can be used without storing value
  • You can have multiple on one line / nest
  • Scope is limited (both a blessing and a curse)
  • You create functions to “wrap” complex code which greatly simplifies it’s usage
  • Via a DLL call you can leverage TONS of functions outside AutoHotkey!
  • Variadic functions take a “variable” number of parameters

Built-in AutoHotkey functions

  • Using built-in Functions (here are a couple examples)
  • SubStr(String, StartingPos [, Length])
  • Round(Number[,N])
  • Trim()
  • StrSplit(String , [Delimiters, OmitChars, MaxParts])

Highlights:

  • Positional parameters (the order matters they’re not named parameters)
  • Required parameters
  • Optional parameters

Creating your own Functions in AutoHotkey

  • Why you want to create them
  • Defining a Function verse Calling a function
  • Working with SCOPE
  • Global
  • Static
  • byRef

What we’ll cover:

  • Accessing variables outside your AutoHotkey function
  • Passing parameters
  • Setting default values for your parameters
  • Returning value
  • Returning more than 1 value (byRef & Objects/Arrays)
  • Using the #Includes directive and Function Libraries

Biggest things that will trip you up!

  • Scope seems like a design flaw however it is a great benefit. Most noobs (and even seasoned programmers) will sometimes forget they are inside a function and try and access a variable outside the function
  • Forgetting you returned an object and trying to access it as a variable
  • Making something Global and then reusing the variable in something else

Skins & Styles – Dimitri  (I’ll work on a working example to include here)

Dimitri Geertz joined the webinar and demonstrated his work using the skinsUSkin.dll.

You can learn more about it here in the forum post

or this post from CodeProject

I made this video which shows how simple it can be.  You can download the script below

Work with images but not have image files- Base64 encoding rocks!

How to Work with images but not have image files

Sometimes you want to have images in your scripts but don’t want to confuse people by having a lot of files.  In this tutorial I work through Base64 Encoding and provide some great tools that will allow you to encode images as text as well as pull the text out and display the images without saving files!

Here is the video where I show How to Work with images but not have image files

Fixing the Windows 10 clipboard manager

Fixing the Windows 10 clipboard managerThe built-in Windows 10 clipboard manage is better than nothing however I really didn’t like activating it by hitting the space bar.  I wrote this simple AutoHotkey script to change the hotkey to be the enter key.  You can bring up the Windows 10 clipboard manager by hitting the Windows key +V

Tutorial for Fixing the Windows 10 clipboard manager

Get the AutoHotkey code for Fixing the Windows 10 clipboard manager

How to use HellBent Button theme creator class to create multiple buttons

HellBent asked if I’d join him for  a video where we walk through his “button maker”.   This tool is really awesome!  While it does have the ability to save a created image as a PNG, that’s not it’s goal.  In my opinion the tool is better described as a “Button theme creator”.  You can use his GUI editor tool to create a “template” for images.   Then re-use your look (or borrow someone else’s) and “draw” your buttons.    You see, when you use this class, instead of saving images of buttons, you’re actually drawing the buttons on the screen.  You can get the files I created from the tutorial here.  The AutoHotkey Forum link to all the files is here

Drawing your buttons instead of using files, has several advantages

  1. It’s badass cool!
  2. You don’t have to worry about how your screen displays the images (stretching them for resolutions ,etc.)
  3. You don’t have to save the image files (which helps a lot when sharing your scripts)
  4. It’s much easier to deal with DPI issues (we cover this at the end of the video)

Walkthrough of HellBent Button theme creator class

 

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