Skip to content

Instantly share code, notes, and snippets.

@G33kDude
G33kDude / Rogue.ahk
Last active August 29, 2015 14:06
A roguelike for /r/dailyprogrammer
Width := 20, Height := 20
KeyMap := {"up": "up", "left": "left", "down": "down", "right": "right"}
Map := [], BlankSquares := []
Loop, % Width
{
x := A_Index
Loop, % Height
{
y := A_Index
@G33kDude
G33kDude / Fish.ahk
Last active August 29, 2015 14:06
/r/DailyProgrammer
Title := "}{FISH}"
Stats := {"Hunger": 50, "Drowsy": 80, "Health": 75, "Bowels": 10, "Thirst": 0}
Sleeping := False
Gui, Add, Text, r6 w75 -VScroll +ReadOnly vScreen
GoSub, UpdateStats
Gui, Add, Button, vButton1 gFeed ys x+5 w100, Feed
Gui, Add, Button, vButton2 gSleep w100, Put to bed
Gui, Add, Button, vButton3 gKill w100, Put to sleep
Gui, Add, Text, xm w175 Center vTicker, Your fish
@G33kDude
G33kDude / BubbleSort.ahk
Last active August 29, 2015 14:06
/r/DailyProgrammer
Size := 100
PixSize := 5
GuiSize := Size * PixSize
Stack := []
Loop, % Size
Stack.Insert(Rand(0.0, 1.0))
Gui, +hWndhWnd -Caption
@G33kDude
G33kDude / QuickSort.ahk
Last active August 29, 2015 14:06
Quicksort fo /r/DailyProgrammer
Size := 600
PixSize := 1
GuiSize := Size * PixSize
List := []
Loop, % Size
List.Insert(Rand(0.0, 1.0))
Gui, +hWndhWnd -Caption
Ascii =
(
; Necessary newline
+----+
| |
+-------------------------+-----+----+
| | | |
| +-------------------+-----+ |
| | | | |
| | | | |
#NoEnv
SetBatchLines, -1
Conversion := {"mph": 0.44704, "km/s": 0.277778}
MsgBox, Put the input on the clipboard then hit OK
Data := ParseInput(Clipboard)
Data.Cameras.Remove(1) ; This is a redundant camera for my purposes
Pens := [], Brushes := [], Fonts := []
GuiSize := 600
Gui, +hWndhWnd -Caption
hDC := DllCall("GetDC", "UPtr", hWnd, "UPtr")
hMemDC := DllCall("CreateCompatibleDC", "UPtr", hDC, "UPtr")
hBitmap := DllCall("CreateCompatibleBitmap", "UPtr", hDC, "Int", GuiSize, "Int", GuiSize, "UPtr")
hOriginalBitmap := DllCall("SelectObject", "UPtr", hMemDC, "UPtr", hBitmap)
OnExit, ExitSub
OnMessage(0xF, "WM_PAINT")
Gui, Color, Black
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
; Start gdi+
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
This [strike]"tutorial"[/strike]/explanation requires the knowledge of how objects (aka arrays) work in AutoHotkey. If I got something wrong, please point it out.
[hr][/hr]
[center][b]What is a class?[/b][/center]
[quote="wiktionary"]class /klɑːs/
n. A group, collection, category or set sharing characteristics or attributes.[/quote]
In the case of AutHotkey, most commonly an object. In this post, we will be talking about the syntax of making custom object classes that have methods, and how it works.
^d::
Code := Clipboard ;"<div style='overflow:scroll; width: 100%; height: 100%; margin: none;'>" Clipboard "</div>"
Code := RegExReplace(Code, "s)\[list\](.*?)\[/list\]", "<ul>$1</ul>")
Code := RegExReplace(Code, "\[\*\](.*)", "<li>$1</li>")
Code := RegExReplace(Code, "\[quote(?:=""([^""]*)"")?\]", "<div class='author'>&nbsp;$1</div><div class='quote'>")
Code := RegExReplace(Code, "\[/quote\]", "</div>")
Code := RegExReplace(Code, "s)\[code[^\]]*\](.*?)\[/code\]", "<pre>$1</pre>")
Code := RegExReplace(Code, "\[c\](.*?)\[/c\]", "<code>$1</code>")
Code := RegExReplace(Code, "\[([^\]]*)\]", "<$1>")
Code := RegExReplace(Code, "\R", "<br/>")