Skip to content

Instantly share code, notes, and snippets.

@grey-code
grey-code / ahkexec.py
Last active December 12, 2015 06:19
Python: Run/build AHK code [ST2 Plugin]
import sublime, sublime_plugin
import subprocess
import re
from ctypes import *
class ahkexec(sublime_plugin.TextCommand):
# SET YOUR SETTINGS HERE
# Specify a 'key'(name it whatever you want) and assign it
# a 'value'(string) containing the path to the AHK executable.
@grey-code
grey-code / gist:4728561
Created February 7, 2013 04:33
AutoHotkey: SetButtonF [Single]
/*
_________________________________________________________________________________________
FUNCTION: SetButtonF
DESCRIPTION: Set a button control to call a function instead of a label subroutine
PARAMETER(s):
hButton := Button control's handle
FunctionName := Name of fucntion to associate with button
USAGE:
Setting a button:
@grey-code
grey-code / gist:4728599
Created February 7, 2013 04:38
AutoHotkey: inObj
inObj(obj, ss, cs:=false, bv:=true) {
r := false
if (!cs && !bv)
return ObjHasKey(obj, ss)
for a, b in obj
if (r := !r ? (cs ? (ss == (bv ? b : a)) : (ss = b)) : r)
break ; stop loop if found
return r ? a : r
}
@grey-code
grey-code / gist:5065483
Created March 1, 2013 15:43
AutoHotkey: LV_MoveRow()
LV_MoveRow(up=true) {
if (up && LV_GetNext() == 1)
|| (!up && LV_GetNext() == LV_GetCount())
|| (LV_GetNext() == 0)
return
pos := LV_GetNext()
, xpos := up ? pos-1 : pos+1
Loop,% LV_GetCount("Col") {
@grey-code
grey-code / gist:5070286
Created March 2, 2013 09:27
AutoHotkey: SC_CutWindow
; I added a feather field instead of a new func.
Gui, Show, w500 h500
; By: Sjc1000
; http://www.autohotkey.com/board/topic/90132-class-sc-cutwindow-easily-cut-windows-into-shapes/
Class SC_CutWindow
{
Square( Window_Name, X1, Y1, X2, Y2, Feather, Invert)
{ If ( X1 > X2 || Y1 > Y2 )
Return 1
@grey-code
grey-code / gist:5286786
Created April 1, 2013 18:41
AutoHotkey: StrDiff()
/*
By Toralf:
Forum thread: http://www.autohotkey.com/forum/topic59407.html
Basic idea for SIFT3 code by Siderite Zackwehdex
http://siderite.blogspot.com/2007/04/super-fast-and-accurate-string-distance.html
Took idea to normalize it to longest string from Brad Wood
http://www.bradwood.com/string_compare/
@grey-code
grey-code / gist:5304819
Created April 3, 2013 20:16
AutoHotkey: WM_SETCURSOR()
; Prevent "sizing arrow" cursor when hovering over window border
WM_SETCURSOR(wParam, lParam) { ; WM_SETCURSOR := 0x0020
; standard arrow cursor
static HARROW := DllCall("LoadCursor", "Ptr", 0, "Ptr", 32512, "UPtr")
HTCODE := lParam & 0xFFFF
if (HTCODE > 9) && (HTCODE < 19) { ; cursor is on a border
DllCall("SetCursor", "Ptr", HARROW) ; show arrow cursor
return true ; prevent further processing
}
@grey-code
grey-code / gist:5322888
Last active December 15, 2015 20:59
AutoHotkey: range()
range(stop, start:=0, step:=1) {
r := []
Loop
v := start+step*(A_Index-1)
, r[v] := v
until (stop<0 ? v<=stop-step : v>=stop-step)
return r
}
@grey-code
grey-code / gist:5323228
Created April 5, 2013 22:34
AutoHotkey: Titan/polyethene's Anchor()
/*
Function: Anchor
Defines how controls should be automatically positioned relative to the new dimensions of a window when resized.
Parameters:
cl - a control HWND, associated variable name or ClassNN to operate on
a - (optional) one or more of the anchors: 'x', 'y', 'w' (width) and 'h' (height),
optionally followed by a relative factor, e.g. "x h0.5"
r - (optional) true to redraw controls, recommended for GroupBox and Button types
@grey-code
grey-code / gist:5563674
Created May 12, 2013 14:00
AutoHotkey: JSON_parse()
/*
derived from Getfree's parseJson function
http://www.autohotkey.com/board/topic/93300-what-format-to-store-settings-in/#entry588268
credits to Getfree
*/
JSON_parse(jsonStr) {
SC := ComObjCreate("ScriptControl")
SC.Language := "JScript"
ComObjError(false)
jsCode =