I just tried the script and pressing Alt+F4 to bring up the Shut Down Windows dialog box worked as it is for me, without needing to manually focus anything. Anyway, you can try adding one of the following at the end:Thouldre wrote:After closing all windows I first have to klick on the desktop before I can use Alt+F4 to shutdown Windows. Can you auto focus the desktop after closing all windows?
- WinActivate % "ahk_id " . DllCall("GetShellWindow", "Ptr") - focuses the desktop window, which accepts Alt+F4
- ComObjCreate("Shell.Application").ShutdownWindows - shows the Shut Down Windows dialog box automatically