Skip to content

Instantly share code, notes, and snippets.

SaveSetColours(set := False, liteSet := True)
{
; Sys colours saving adapted from an approach found in Bertrand Deo's code
; The rest is from Michael Maltsev: https://github.com/RaMMicHaeL/Windows-10-Color-Control
static DWMCOLORIZATIONPARAMS, IMMERSIVE_COLOR_PREFERENCE
,DwmGetColorizationParameters := DllCall("GetProcAddress", "Ptr", DllCall("GetModuleHandleW", "WStr", "dwmapi.dll", "Ptr"), "Ptr", 127, "Ptr")
,DwmSetColorizationParameters := DllCall("GetProcAddress", "Ptr", DllCall("GetModuleHandleW", "WStr", "dwmapi.dll", "Ptr"), "Ptr", 131, "Ptr")
,GetUserColorPreference := DllCall("GetProcAddress", "Ptr", DllCall("GetModuleHandleW", "WStr", "uxtheme.dll", "Ptr"), "AStr", "GetUserColorPreference", "Ptr")
,SetUserColorPreference := DllCall("GetProcAddress", "Ptr", DllCall("GetModuleHandleW", "WStr", "uxtheme.dll", "Ptr"), "Ptr", 122, "Ptr")
,WM_SYSCOLORCHANGE := 0x0015, sys_colours, sav_colours, colourCount := 31, GetSysColor := DllCall("GetProcAddress", "Ptr", DllCall("GetModule
@qwerty12
qwerty12 / TermWait.ahk
Last active November 2, 2021 09:07
Slightly modified version of cyruz' and SKAN's TermWait for LogonDesktop
; ----------------------------------------------------------------------------------------------------------------------
; Name .........: TermWait library
; Description ..: Implement the RegisterWaitForSingleObject Windows API.
; AHK Version ..: AHK_L 1.1.13.01 x32/64 Unicode
; Author .......: Cyruz (http://ciroprincipe.info) & SKAN (http://goo.gl/EpCq0Z)
; License ......: WTFPL - http://www.wtfpl.net/txt/copying/
; Changelog ....: Sep. 15, 2012 - v0.1 - First revision.
; ..............: Jan. 02, 2014 - v0.2 - AHK_L Unicode and x64 version.
; ----------------------------------------------------------------------------------------------------------------------
@qwerty12
qwerty12 / LogonDesktop.ahk
Last active February 13, 2024 19:48
Bunch of functions to help facilitate running AutoHotkey on the Winlogon desktop - https://autohotkey.com/boards/viewtopic.php?f=6&t=27709
; LogonDesktop - run scripts on the Winlogon desktop
; 26/02/17 - qwerty12
; Modified version of RunAsTask() by SKAN: https://autohotkey.com/boards/viewtopic.php?t=4334
LogonDesktop_AddTask(runNow, runOnStartup)
{
local TaskName, XML, TaskSchd, TaskRoot, RunAsTask
local TASK_CREATE := 0x2, TASK_LOGON_SERVICE_ACCOUNT := 5, scriptDir := A_ScriptDir
try
@qwerty12
qwerty12 / AHKLogonMediaKeys.ahk
Last active December 3, 2021 01:30
Sample script for LogonDesktop. Enables media keys on the lockscreen
#NoTrayIcon
#Persistent
#NoEnv
#Include *i %A_ScriptDir%\Lib\FastDefaults.ahk
SetKeyDelay, -1, -1
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Off ; This same script is launched multiple times
#UseHook Off ; Remove if you need complex hotkeys. WM_HOTKEY suits me fine; I don't want a low-level keyboard/mouse hook installed on WinSta0\Winlogon
#Include %A_ScriptDir%\Lib\LogonDesktop.ahk ; Naturally, this one is needed
@qwerty12
qwerty12 / BrightnessSetter.ahk
Last active July 25, 2023 13:06
BrightnessSetter: set laptop brightness and show Windows 10's native brightness OSD (https://github.com/qwerty12/AutoHotkeyScripts/tree/master/LaptopBrightnessSetter)
class BrightnessSetter {
; qwerty12 - 27/05/17
; https://github.com/qwerty12/AutoHotkeyScripts/tree/master/LaptopBrightnessSetter
static _WM_POWERBROADCAST := 0x218, _osdHwnd := 0, hPowrprofMod := DllCall("LoadLibrary", "Str", "powrprof.dll", "Ptr")
__New() {
if (BrightnessSetter.IsOnAc(AC))
this._AC := AC
if ((this.pwrAcNotifyHandle := DllCall("RegisterPowerSettingNotification", "Ptr", A_ScriptHwnd, "Ptr", BrightnessSetter._GUID_ACDC_POWER_SOURCE(), "UInt", DEVICE_NOTIFY_WINDOW_HANDLE := 0x00000000, "Ptr"))) ; Sadly the callback passed to *PowerSettingRegister*Notification runs on a new threadl
OnMessage(this._WM_POWERBROADCAST, ((this.pwrBroadcastFunc := ObjBindMethod(this, "_On_WM_POWERBROADCAST"))))
#include <sdkddkver.h>
#include <windows.h>
#include <Shellapi.h>
#include <Shlobj.h>
#include <strsafe.h>
#include "extlib\MinHook.h"
#define WM_SHELLNOTIFY WM_USER+5
#define WM_TRAYCMD 0x800A
@qwerty12
qwerty12 / VistaSwitcherFixer.c
Created November 7, 2016 06:16
Stop VS from keeping the US layout loaded and only intercept Alt+`
#include "avrf.h"
typedef HKL(WINAPI *P_LOADKEYBOARDLAYOUTW)(LPCWSTR, UINT);
HKL WINAPI LoadKeyboardLayoutWHook(LPCWSTR, UINT);
//typedef BOOL(WINAPI *P_REGISTERHOTKEY)(HWND, INT, UINT, UINT);
BOOL WINAPI RegisterHotKeyHook(HWND, INT, UINT, UINT);
typedef UINT(WINAPI *P_MAPVIRTUALKEYEXW)(UINT, UINT, HKL);
UINT WINAPI MapVirtualKeyExWHook(UINT, UINT, HKL);
##!/bin/sh
# Use Ubuntu because they have their heads screwed on straight and patch GRUB to STFU when starting
mkdir /mnt/win
mount -t ntfs-3g -o windows_filenames /dev/sda1 /mnt/win
grub-install --no-floppy --modules=ntfs --root-directory=/mnt/win --boot-directory=/mnt/win/Boot /dev/sda
@qwerty12
qwerty12 / atheros-fw.py
Created September 1, 2013 00:41
Script to create a C header with the contents of the AR3011 firmware for ioath3kfirmware
#!/usr/bin/env python
#atheros-fw.py > OS-X-Atheros-3k-Firmware/IOath3kfrmwr/ath3k-1fw.h
import sys
import binascii
with open("AtherosBT.bin", "rb") as f:
bytes = f.read()
size = len(bytes)
sys.stdout.write("\n/* ath3k-1-linux-git.h begin binary data: */\n")
@qwerty12
qwerty12 / install_zsh.sh
Last active December 21, 2015 11:49
Set up zsh on OS X with my preferred configuration (this will remove any pre-existing .zshrc!)
#!/bin/sh
# Install my favourite coreutils: GNU's. Sorry, BSD...
brew rm coreutils >/dev/null 2>&1
brew update
# Add progress bar patch
patch -p0 << "EOF"
--- /usr/local/Library/Formula/coreutils.rb.orig 2013-09-06 15:23:52.000000000 +0100
+++ /usr/local/Library/Formula/coreutils.rb 2013-09-06 15:33:35.000000000 +0100