Skip to content

Instantly share code, notes, and snippets.

@TLMcode
TLMcode / DirMember.ahk
Created May 9, 2016 17:53
Save/Open directories
FolderArr := [], Folders := ""
FolderFile := A_ScriptDir "\FolderList.txt"
shObj := ComObjCreate( "shell.application" ).Windows
Gui, +AlwaysOnTop
Gui, Add, Button, section gOpen, Open Folders
Gui, Add, Text, vStat, % " "
Gui, Add, Button, gSave ys0, Save Folders
Gui, Show,, DirMember
@TLMcode
TLMcode / DomConversion.ahk
Last active June 3, 2016 04:35
Foreign Language DOM Conversion
url = http://www.archiwum.wyborcza.pl/Archiwum/1,0,8137863,20160401RP-DGW,Amerykanska_czata_w_Polsce,.html
reqObj := ComObjCreate( "WinHttp.WinHttpRequest.5.1" )
reqObj.Open( "GET", url, false ), reqObj.Send()
htmObj := ComObjCreate( "HTMLfile" ), htmObj.Write( reqObj.ResponseText )
Elements := RegExReplace( htmObj.getElementById( "arM" ).innerHTML, "i)(</|<).*?>", "$1div>" )
htmObj.Close()
@TLMcode
TLMcode / ClickCoords().ahk
Created April 26, 2016 07:42
ClickCoords() full click sequence
ClickCoords( x, y, wT, ctrl = "", btn := "left" )
{
For Each, Msg in ( btn = "left" ? ( l := [ 1, 0, 2 ] ) : btn = "right" ? [ 4, 0, 5 ] : l )
PostMessage, % 0x20 Msg, 0x1, % x|y<<16, % ctrl, % wT
}
@TLMcode
TLMcode / Rand()
Created April 23, 2016 22:33
Rand() wrapper for AHk
rand( min = 0, max = 10000 ) {
random, rand, % min, % max
return rand
}
@TLMcode
TLMcode / WatchWindow.ahk
Created April 21, 2016 14:26
Pseudo Watch Window Event Handler. Embeds an instructional AHk GUI into a parent window using Win32 API SetParent() function.
SetTimer, WatchWindow, 100
xOfs := 189, yOfs := 30, GuiCnt := 0
WatchWindow:
ControlGet, PlgHwnd, Hwnd,, eXTVSTiwin1, ahk_class TPluginForm
if ( WinExist( "ahk_id " PlgHwnd ) && GuiCnt = 0 )
{
Gui Font, s7 CA0E6E6
@TLMcode
TLMcode / GetSamples.ahk
Created April 7, 2016 10:40
GetSamples() ; delta-time to samples converter
GetSamples( bin, ppq, tmpo, srate = 44.1, debug = 0 )
{
; credit: just me >> https://autohotkey.com/boards/viewtopic.php?f=5&t=15637
Loop
r := ( (!r?r!!:r) << 7 ) + ( ( h := "0x" . SubStr( bin, ( a_index * 2) - 1, 2 ) ) & 0x7F )
Until ( h <= 0x80 )
Return debug ? r : Round( r * ( 60000 / ( ( 60000000 / tmpo ) * ppq ) ) * srate )
}
@TLMcode
TLMcode / RunChrome.ahk
Created April 1, 2016 11:18
RunChrome() waits for page to load then moves the chrome window to the coordinate array.
new RunChrome( "https://autohotkey.com", [ 0, 0, 1000, 500 ] )
return
Esc::ExitApp
class RunChrome
{
__New( url, coords )
{
this.arr := this.EnumWindows(), this.ShellHookWindow( 1 )
@TLMcode
TLMcode / eval.ahk
Last active March 24, 2016 01:01
Single line maths Eval() function using a HTMLFile object and COM for ahk http://p.ahkscript.org/?p=f33c5102 🤓👍✨ (debugged)
msgbox % eval("2*4*23") " <> " (2*4*23) "`n" eval("Math.pow(3,7)") " <> " (3**7) "`n" eval( "5*9*poo" )
eval( exp )
{
return InStr([(o:=ComObjCreate("HTMLfile")).Write(".<script>document.body.innerHTML=eval('" exp "')</script>"),r:=o.body.innerHTML][2],"<")?"Error":r
}
@TLMcode
TLMcode / TileWindows()
Last active March 19, 2016 19:04
TileWindows()
; API call https://msdn.microsoft.com/en-us/library/windows/desktop/ms633554(v=vs.85).aspx
Window_Tile(Monitor=""){
; Required constants: MDITILE_VERTICAL
; SM_CMONITORS
; WS_CAPTION
; WS_MAXIMIZEBOX
; WS_MINIMIZE
; WS_VISIBLE
; WS_EX_TOOLWINDOW
wHow:=MDITILE_VERTICAL
@TLMcode
TLMcode / ShortGitURL.ahk
Last active March 1, 2016 03:19
ShortGitURL() shorten GitHub url's using git.io in AutoHotkey
msgbox % ShortGitURL( "https://github.com/blog/category/ship" ) ; example long git url
ShortGitURL( gitURL )
{
hReq := ComObjCreate("Microsoft.XMLHTTP")
hReq.Open("GET", "https://git.io", False), hReq.Send("url=" gitURL)
Return hReq.getResponseHeader("Location")
}