Skip to content

Instantly share code, notes, and snippets.

@Chunjee
Forked from G33kDude/autohotkey_formatting.md
Last active July 29, 2022 14:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chunjee/59ae547bf59e6c9aa765fd5164287a6e to your computer and use it in GitHub Desktop.
Save Chunjee/59ae547bf59e6c9aa765fd5164287a6e to your computer and use it in GitHub Desktop.

AutoHotkey Style Guide() {

A mostly reasonable approach to AutoHotkey

Variables:

  • All variables should be camelCase or snake_case
  • Constants should be in ALLCAPS

Functions and Methods:

  • Should be camelCase

if statements:

  • Should be on own line
  • Should be proceeded by a space
  • Should be mostly enclosed in parenthesis: 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:

Should be used whenever possible.

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

; Good!
if (condition)
	MsgBox, yes

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

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 ---
	externalUseMethod() {
		return 1
	}
	_internal_UseMethod() {
		return 1
	}
	
	
	; --- Nested Classes ---
	class nested1 {

	}
	
	class nested2 {

	}
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment