Skip to content

Instantly share code, notes, and snippets.

@G33kDude
Last active April 17, 2021 19:15
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save G33kDude/cbfbf66a08f54927d8b902de4836f28a to your computer and use it in GitHub Desktop.
Save G33kDude/cbfbf66a08f54927d8b902de4836f28a to your computer and use it in GitHub Desktop.

AutoHotkey Formatting Guidelines

Global Variables:

  • Should be constants, in ALL_CAPS
  • Or variables prefixed with _underscore

Constant values should be in ALL_CAPS other variables should be snake_case or camelCase

Functions and Methods should be PascalCase

if statements should follow these formats: if var if func() if !var if !func() if (var == 1) if (var != 1) if (var == 1 || var == 2) if !(var == 1 || var == 2)

Braces must be placed according to allman's styling. One-True-Brace is not acceptable.

No-brace if statements are allowed, often preferred, as long as the content is actually one line long:

; Good!
if (condition)
	MsgBox, yes

; Bad!
if (condition1)
	if (condition2)
		MsgBox, no

; Good!
if (condition1)
{
	if (condition2)
		MsgBox, yes
}

Classes should follow this template:

class Name
{
	; --- Static Variables ---
	
	static CONSTANT := 1
	
	
	; --- Instance Variables ---
	
	external_use := 1
	_internal_use := 1
	
	
	; --- Properties ---
	
	external[]
	{
		get
		{
			return this._internal_use
		}
	}
	
	
	; --- Static Methods ---
	
	Method()
	{
		return 1
	}
	
	
	; --- Constructor, Destructor, Meta-Functions ---
	
	__New()
	{
	}
	
	__Delete()
	{
	}
	
	
	; --- Instance Methods ---
	
	_Internal_Use_Method()
	{
		return 1
	}
	
	External_Use_Method()
	{
		return 1
	}
	
	
	; --- Nested Classes ---
	
	class Nested1
	{
		; Contents
	}
	
	class Nested2
	{
		; Contents
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment