MasterFocus' AHK Code Catalog

This is where I intend to keep track of all my AutoHotkey scripts and code snippets.
This page is not designed to be beautiful. Just functional. ;)

Last update: 23/may/2014
[ checking my current webpages and updating hyperlinks ]

# License

Unless differently specified, all my code is usually licensed under GNU AGPL v3.0
Please make sure you refer to this page and/or one of my webpages when reproducing any code.
Although it's not really necessary, I'd appreciate if you contact me when using my code.

# Compatibility

All my code is intended to be compatible with AutoHotkey v1.0.* by default.
Usually, it means my code may also work on v1.1.* and other brands.
I will try to create a detailed "compatibility table" for each piece of code in the future.

# Contact / Links

To contact me, send me a Private Message on http://www.autohotkey.com/board/ or http://ahkscript.org/boards/
I'm currently more active on http://ahkscript.org/ which is a "community-driven" initiative.
Sometimes (rarely), you may find me on Freenode's IRC at channels #ahk and #ahkscript (nickname: MasterFocus)

Homepage (ahk4.net): http://masterfocus.ahk4.net
Homepage (GitHub):    https://masterfocus.github.io/
GitHub profile:            https://github.com/MasterFocus/
Homepage (ahk.net):  http://u.ahk.me/MasterFocus

------------------------------------

# Libraries

General Proxy-Dll Functions a.k.a. GPF
      Overlay DirectX8/9 applications with multiple texts and one image. Also takes screenshots and shows FPS.
                FORUM TOPIC --- DOCUMENTATION

Type Functions
      A group of functions to check, retireve and compare AHK variable types.
                FORUM TOPIC --- Featured in ahkstdlib

------------------------------------

# Functions

WaitPixelColor
      Waits for a pixel to be of a certain color. Features optional timeout.
                FORUM TOPIC --- Featured in ahkstdlib

GetControlsInfo
      Retrieves name, handle, position and size of all controls from a matching window.
                FORUM TOPIC

WRandom
      Weighted random. Specify a weight for each field: the returned value is the number of the randomized field.

RandomVar
      Creates any kind of random content for a variable. Options include type (AHK variable type), length and ASCII range.
                FORUM TOPIC --- Reproduced here: {1}

GetDriveByLabel
      Retrieves the letter of the first drive that matches the given label.
                FORUM TOPIC

ClearArray
      Clears the specified consecutive elements of an array without accidentally creating new elements/variables.
        [ probably obsolete as AHK v1.1.* supports real arrays (objects) ]
                GitHub folder

GetFromList
      Retrieves a certain number of random items or all items containing a substring with optional matching position.
        [ currently outdated - I will upload a new version later ]
                FORUM POST

RegExSort
      Returns a sorted version of an input list based on a RegEx needle and a precedence order for any subpatters.
                FORUM POST

Dec2Roman + Roman2Dec
      A pair of functions created to perform convertions between decimal and roman numbers.
                FORUM POST

ImageSearchList
      Finds multiple instances of a specified image on screen and returns a list of matching coordinates.
        [ the current implementation is WRONG! I will discontinue this function and upload a replacement later ]
                FORUM POST

GetTuples + Combine
      A useful pair of functions for arrangements, tuples, combinations, permutations...
        [ related work by other users can be found within the topic ]
                FORUM TOPIC

Cycle
      Automatically cycle through a list of elements with ease. No need to declare a bunch of variables.
                FORUM TOPIC --- Mentioned in camerb's AHK repository

GetRandom
      Simple short function which makes a random choice out of a given set.
                FORUM TOPIC

MouseMove_Ellipse
      Moves mouse from one point to another using an ellipse instead of a straight line. Based on previous work by Wicked.
                FORUM POST

WinMoveSpecial
      Allows moving a target window to specific place on the screen, like TOPLEFT, BOTTOM or CENTER.
                FORUM POST

RandomBezier
      Moves the mouse using a random trajectory, which is in fact a random Bézier curve.
                FORUM TOPIC

InputBox
      Yet another wrapper for the InputBox command.
                FORUM TOPIC

------------------------------------

# Templates

Checkboxes
      Use a simple GUI with checkboxes to work with selectable items.
                AHK FILE (outdated!) --- Modified example

WinTrigger (former OnOpen/OnClose)
      Perform actions upon (de)activation or (un)existance of certain windows/programs.
                FORUM TOPIC --- Reproduced here: {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8} --- Old version

Grid Template
      This template is useful for finding the best way to visually distribute elements into a grid shape.
                FORUM POST

Benchmarking Template
      Specially designed to compare two routines and show detailed results of the bechmark, possibly electing a winner.
        [ licensed under CC BY-SA 3.0 ]
                FORUM POST

------------------------------------

# My contributions to RosettaCode
All code submitted to RosettaCode becomes available under GNU FDL 1.2 by default.

You can find an up-to-date detailed list here: http://rosettacode.org/wiki/Special:Contributions/MasterFocus

Hailstone Sequence
      Calculates the Hailstone sequence (and its length) for a provided initial number.
                SUBMITTED CODE --- AHK FILE

Price Fraction
      A specialised rounding function to work according to a certain table.

Number Reversal Game
      A game where you get a jumbled list of numbers (1-9) and must attain the ascending order by only reversing them from the left side.

String Repetition
      An example showing the simplest way to repeat a string in AutoHotkey.

Dot Product
      A simple function which computes the dot product (aka scalar product) of two vectors.

The N-Queens Problem
      A function that uses a few global variables and solves the N-Queens Problem.

Missing Permutations
      Function designed to find one or more missing permutations of a given set.

HQ9+ Interpreter
      A small simple function which executes a HQ9+ code.
                FORUM POST --- AHK FILE

------------------------------------

# Other scripts and code snippets

Bejeweled Autoplay
      A framework developed to autoplay a free Flash version of Bejeweled 2.
        [ the game webpage has already been redesigned, possibly affecting automation ]
                FORUM TOPIC

Drawing a spirograph + CoordSpirograph()
      Helper script for drawing a customizable spirograph.
                FORUM TOPIC

WinLimit a.k.a. XPSnap / XP Snap
      "A script that mimics Windows 7 Aero Snap", as stated in DataLife's original post.
        [ however, it doesn't change the size of the window (on WinXP) ]
                FORUM POST

VK() a.k.a. Hotkey2Virtual Key
      A function to convert a hotkey into its virtual key code. Created in conjunction with other users.
                FORUM TOPIC

==========================================

Reminders to myself:
 
[1] add GetWindowsByStyle()
    http://www.autohotkey.com/board/topic/50899-resolvedhow-to-get-all-visible-windows/#entry318484
[2] add Gdip_ImageSearch()
[3] add CenterControl()
    http://www.autohotkey.com/board/topic/59071-function-centercontrol/
[4] add the "mantain GUI aspect ratio" script
    http://www.autohotkey.com/board/topic/92581-how-to-maintain-guis-aspect-ratio-when-resizing/
 
[5] add all the following references to my stuff:
    * http://www.rossgoodman.com/2012/10/18/stay-focussed-stay-out-of-outlook/
    * http://forums.eagle.ru/showthread.php?p=1308590
    * http://www.hiasm.com/xf/topic.php?p=219670
    * http://forum.lockon.ru/showthread.php?p=1308010&langid=2
    * http://forum.script-coding.com/viewtopic.php?id=5469
    * http://ahk8.com/thread-2168.html
    * http://ahk8.com/thread-2566.html?highlight=masterfocus
    * http://bbs.themex.net/showpost.php?p=1260623&postcount=18