Skip to content

Instantly share code, notes, and snippets.

@grey-code
grey-code / gist:5565115
Created May 12, 2013 22:13
AutoHotkey: Obj2Str()
Obj2Str(obj) {
str := "" , array := true
for k in obj {
if (k == A_Index)
continue
array := false
break
}
for a, b in obj
str .= (array ? "" : "'" a "': ") . (IsObject(b) ? Obj2Str(b) : "'" b "'") . ", "
@grey-code
grey-code / gist:5570456
Created May 13, 2013 18:45
AutoHotkey: RemoveDuplicate()
RemoveDuplicate(str, delim:="`n", cs:=false) {
_ := cs ? ComObjCreate("Scripting.Dictionary") : []
Loop, Parse, str, % delim
alf := A_LoopField
, out .= cs ? (_.Exists(alf) ? "" : (alf . delim, _.Add(alf, 1)))
: (_[alf] ? "" : (alf . delim, _[alf] := 1))
return RTrim(out, delim)
}
@grey-code
grey-code / gist:5615665
Created May 20, 2013 21:18
AutoHotkey: VAR_get()
; http://www.autohotkey.com/board/topic/20925-listvars/#entry156570
VAR_get() {
global
static hEdit, pSFW, pSW, bkpSFW, bkpSW
local dhw, AStr, Ptr, hmod, text, v, i := 0, vars := []
if !hEdit {
dhw := A_DetectHiddenWindows
DetectHiddenWindows, On
ControlGet, hEdit, Hwnd,, Edit1, % "ahk_id " A_ScriptHwnd
@grey-code
grey-code / gist:DynaRun
Last active December 21, 2015 09:39
AutoHotkey: DynaRun()
DynaRun(script, name:="", args*) { ;// http://goo.gl/ECC6Qw
if (name == "")
name := "AHK_" . A_TickCount
;// Create named pipe(s), first one is a dummy
for each, pipe in ["__PIPE_GA_", "__PIPE_"]
%pipe% := DllCall(
(Join Q C
"CreateNamedPipe", ;// http://goo.gl/3aJQg7
"Str", "\\.\pipe\" . name, ;// lpName
"UInt", 2, ;// dwOpenMode = PIPE_ACCESS_OUTBOUND
@grey-code
grey-code / gist:7042282
Last active December 25, 2015 21:28
AutoHotkey: Download()
/*
Derived from Wicked - can't locate his thread but found this in the ff thread:
http://www.autohotkey.com/board/topic/97642-urldownloadtofile/#entry614852
*/
Download(url, dest) {
static r
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
if (!r || whr.Option(1) != url)