#Requires AutoHotkey v1.1 #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #SingleInstance ignore #NoTrayIcon #Include SetBatchLines, -1 SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ; RequireAdmin ;@Ahk2Exe-UpdateManifest 1, Dart Vanya global hWlThread := 0 global UIA := new UiAccess(, true) ; calls UIA.ImpersonateSYSTEM() wl_tid := GetProcessThreads(UIA.WinlogonPid, true) hWlThread := DllCall("OpenThread", "UInt",THREAD_SUSPEND_RESUME := 2, "Int",false, "UInt",wl_tid, "Ptr") if (hWlThread) DllCall("SetHandleInformation", "Ptr",hWlThread, "UInt",0x2, "UInt",0x2) ; HANDLE_FLAG_PROTECT_FROM_CLOSE ; Black magic. UiAccess will be turned only while SendSAS is executing UIA.On(false) ; RevertToSelf ; Resume Winlogon, if script was terminated while CAD was off (yes, no need to reboot, thats cool, Riot Games, huh?) while (hWlThread && DllCall("ResumeThread", "Ptr",hWlThread, "UInt") != 0) { } OnExit("AppExit") bEnable := !hWlThread Gui, Font, s14 bold Gui, Add, Button, gCAD_Off w150 h40 section vOff Disabled%bEnable%, Disable Gui, Add, Button, gCAD_On w150 h40 ys x+10 vOn Disabled, Enable Gui, Font, s12 norm Gui, Add, Button, gMySendSAS w310 h30 xm, Try Ctrl+Alt+Delete Gui, Add, Button, gTryCSE w310 h30 y+4, Try Ctrl+Shift+Esc Gui, Font Gui, Add, StatusBar,, Welcome to advanced WinAPI hack tool SB_SetParts(200, 150) SB_SetText("Winlogon thread token: " hWlThread, 2) ; ApplyDarkModeForWindow() Gui, Show,, Disable Ctrl+Alt+Delete return GuiClose: ExitApp return GuiEscape: Gui Minimize return CAD_Off() { if (hWlThread) cnt := DllCall("SuspendThread", "Ptr",hWlThread, "UInt") GuiControl, Disable, Off GuiControl, Enable, On SB_SetText("Thread suspend count: " cnt + 1) } CAD_On() { while (hWlThread && (cnt := DllCall("ResumeThread", "Ptr",hWlThread, "UInt")) != 0) { } GuiControl, Disable, On GuiControl, Enable, Off SB_SetText("Thread suspend count: " cnt) } MySendSAS() { SendSAS(isUiAccess, AsUser, UIA) SB_SetText("SendSAS: isUiAccess = " isUiAccess ", AsUser = " AsUser) ; res := SendSasEx(, UIA) ; SB_SetText("WmsgSendMessage result: " (res = 0 ? "SUCCESS" : res)) } TryCSE() { Send, {Ctrl down}{Shift down}{Esc}{Shift up}{Ctrl up} SB_SetText("Ctrl+Shift+Esc was sent") } AppExit() { CAD_On() if (hWlThread) CloseHandle(hWlThread) } GetProcessThreads(ProcessID, bFirstOnly := false) { if !(hSnapshot := DllCall("CreateToolhelp32Snapshot", "uint", 0x4, "uint", ProcessID)) return false NumPut(VarSetCapacity(THREADENTRY32, 28, 0), THREADENTRY32, "uint") if !(DllCall("Thread32First", "ptr", hSnapshot, "ptr", &THREADENTRY32)) return false, DllCall("CloseHandle", "ptr", hSnapshot) Threads := [] while (DllCall("Thread32Next", "ptr", hSnapshot, "ptr", &THREADENTRY32)) { if (NumGet(THREADENTRY32, 12, "uint") = ProcessID) { if (bFirstOnly) return NumGet(THREADENTRY32, 8, "uint"), DllCall("CloseHandle", "ptr", hSnapshot) Threads.Push(NumGet(THREADENTRY32, 8, "uint")) } } return Threads.Count() ? Threads : false, DllCall("CloseHandle", "ptr", hSnapshot) } CloseHandle(hHandle) { return DllCall("CloseHandle", "Ptr",hHandle) } ; Source of DarkMode.ahk standard library will be available later (soonTM) ; #Include