Home > database >  AHK Always on Top not working for Windows File Explorer and other Windows system windows?
AHK Always on Top not working for Windows File Explorer and other Windows system windows?

Time:12-20

I've been using an Alwaysontop AHK script to keep my windows on top of other windows.

Here's the code in question:

^SPACE:: Winset, Alwaysontop, , A ; ctrl   space
Return
~#!x::Suspend

It works perfectly for practically every window I use except Windows-based windows - things like File Explorer, Task Manager, etc...

How can I go about getting these windows to also work with the script?

I've used WinSpy to get information on specific Windows things before, but I'm not exactly sure what to look for here, or if there is a simpler solution that can force Windows-based windows to function with the script.

Any ideas?

CodePudding user response:

AHK won't intercept the key presses in a program running with elevated privileges, unless the script itself is running this way:

#UseHook

; If the script is not elevated, relaunch as administrator and kill current instance:

full_command_line := DllCall("GetCommandLine", "str")

if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
    try ; leads to having the script re-launching itself as administrator
    {
        if A_IsCompiled
            Run *RunAs "%A_ScriptFullPath%" /restart
        else
            Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
    }
    ExitApp
}

            RETURN   ; === end of auto-execute section ===

; ctrl   space:
^SPACE:: Winset, Alwaysontop, , A

~#!x::Suspend

For more details read https://autohotkey.com/docs/commands/Run.htm#RunAs.

  • Related