Skip to content

Instantly share code, notes, and snippets.

@sidola
sidola / DownloadToFile.ahk
Created May 3, 2014 17:11
AHK - Download HTML data to a file
DownloadToFile(url, filename)
{
static a := "AutoHotkey/" A_AhkVersion
if (!(o := FileOpen(filename, "w")) || !DllCall("LoadLibrary", "str", "wininet") || !(h := DllCall("wininet\InternetOpen", "str", a, "uint", 1, "ptr", 0, "ptr", 0, "uint", 0, "ptr")))
return 0
c := s := 0
if (f := DllCall("wininet\InternetOpenUrl", "ptr", h, "str", url, "ptr", 0, "uint", 0, "uint", 0x80003000, "ptr", 0, "ptr"))
{
while (DllCall("wininet\InternetQueryDataAvailable", "ptr", f, "uint*", s, "uint", 0, "ptr", 0) && s > 0)
{
@sidola
sidola / DownloadBin.ahk
Created May 3, 2014 17:11
AHK - Download HTML data to binary
DownloadBin(url, byref buf)
{
static a := "AutoHotkey/" A_AhkVersion
if (!DllCall("LoadLibrary", "str", "wininet") || !(h := DllCall("wininet\InternetOpen", "str", a, "uint", 1, "ptr", 0, "ptr", 0, "uint", 0, "ptr")))
return 0
c := s := 0
if (f := DllCall("wininet\InternetOpenUrl", "ptr", h, "str", url, "ptr", 0, "uint", 0, "uint", 0x80003000, "ptr", 0, "ptr"))
{
while (DllCall("wininet\InternetQueryDataAvailable", "ptr", f, "uint*", s, "uint", 0, "ptr", 0) && s > 0)
{
@sidola
sidola / AutoSort.ahk
Created June 24, 2014 09:04
AHK - Sort an array
AutoSort(Arr) {
t := []
for k, v in Arr
t[RegExReplace(v, "\s")] := v
for k, v in t
Arr[A_Index] := v
return Arr
}
@sidola
sidola / PIDfromAnyID
Created June 24, 2014 09:13
AHK - Gets the PID from any ID
PIDfromAnyID( anyID="" ) { ; SKAN, 10-May-2014. http://ahkscript.org/boards/viewtopic.php?p=17974#p17974
Process, Exist, %anyID%
IfGreater, ErrorLevel, 0, Return ErrorLevel
DetectHiddenWindows, % SubStr( ( ADHW := A_DetectHiddenWindows ) . "On", -1 )
SetTitleMatchMode, % SubStr( ( ATMM := A_TitleMatchMode ) . "RegEx", -4 )
WinGet, PID, PID, ahk_id %anyID%
IfEqual, PID,, WinGet, PID, PID, %anyID%
DetectHiddenWindows, %ADHW%
SetTitleMatchMode, %ATMM%
Return PID ? PID : 0
@sidola
sidola / ControlPanelItem()
Created July 3, 2014 07:52
AHK - Create a controlpanel shortcut
F1::ComObjCreate("shell.application").ControlPanelItem("Firewall.cpl")
@sidola
sidola / SetParentByTitle
Last active August 29, 2015 14:04
AHK - Sets a GUI as a child to a parent, via parent window-name
SetParentByTitle(Window_Title_Text, Gui_Number) ; F
{
WinGetTitle, Window_Title_Text_Complete, %Window_Title_Text%
Parent_Handle := DllCall( "FindWindowEx", "uint",0, "uint",0, "uint",0, "str", Window_Title_Text_Complete)
Gui, %Gui_Number%: +LastFound
Return DllCall( "SetParent", "uint", WinExist(), "uint", Parent_Handle )
}
@sidola
sidola / SetParentByClass
Last active August 29, 2015 14:04
AHK - Sets a GUI as a child to a parent, via parent class
SetParentByClass(Window_Class, Gui_Number) ; F
{
Parent_Handle := DllCall( "FindWindowEx", "uint",0, "uint",0, "str", Window_Class, "uint",0)
Gui, %Gui_Number%: +LastFound
Return DllCall( "SetParent", "uint", WinExist(), "uint", Parent_Handle )
}
@sidola
sidola / Preferences.sublime-settings
Created September 16, 2017 11:00
Personal ST3 Settings
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-Darker.tmTheme",
"font_face": "Inconsolata",
"font_size": 11,
"ignored_packages":
[
"Vintage"
],
@sidola
sidola / Material-Theme-Darker.sublime-theme
Last active September 16, 2017 13:02
Fixed Material Theme for ST3 - Changes fontsize and colors - Use this file as the "zzz A File Icon zzz" patch file for the Darker skin
[
// Material-Theme-Darker Patch
// ==========================================================================
// Sidebar Row Padding
// --------------------------------------------------------------------------
{
"class": "sidebar_tree",
},
@sidola
sidola / TimeDiff.ahk
Last active October 25, 2017 18:04
TimeDiff.ahk
/*
TimeDiff.ahk
Usage:
TimeDiff.ShowTimeDiff()
*/
class TimeDiff {
; Public API