Jump to content

Is it possible to remap Win+t?


Recommended Posts

Here is my script to pin the active window above other ones. Works fine on Windows 7.

HotKeySet("#q", "AlwaysOnTop")

While 1
    Sleep(100)
WEnd

Func AlwaysOnTop()
    Local $sTitle = WinGetTitle ( "[ACTIVE]" )
    Local $hWnd = WinGetHandle ( "[ACTIVE]" )

    If BitAND(_WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE), $WS_EX_TOPMOST) Then
        WinSetOnTop ( $hWnd, "", $WINDOWS_NOONTOP )
        WinSetTitle ( $hWnd, "", StringRegExpReplace ( $sTitle, " - On top$", "" ) )
    Else
        WinSetOnTop ( $hWnd, "", $WINDOWS_ONTOP )
        WinSetTitle ( $hWnd, "", $sTitle & " - On top" )
    EndIf
EndFunc

However, it doesn't work with "#t" which is reserved by Windows. Is it possible to workaround it?

Edited by john_2019
Link to comment
Share on other sites

#include <WinAPISysWin.au3>
#include <misc.au3>
#include <windowsconstants.au3>
Global $sTitle
While 1
    If WinGetTitle("[ACTIVE]") <> "" Then $sTitle = WinGetTitle("[ACTIVE]")
    If _IsPressed("5B") = True And _IsPressed("54") = True Then
        AlwaysOnTop()
        Do
            Sleep(50)
        Until _IsPressed("5B") <> True Or _IsPressed("54") <> True
    EndIf
    Sleep(100)
WEnd

Func AlwaysOnTop()
    Local $hWnd = WinGetHandle($sTitle)
    If BitAND(_WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE), $WS_EX_TOPMOST) Then
        WinSetOnTop($hWnd, "", $WINDOWS_NOONTOP)
        WinSetTitle($hWnd, "", StringRegExpReplace($sTitle, " - On top$", ""))
    Else
        WinSetOnTop($hWnd, "", $WINDOWS_ONTOP)
        WinSetTitle($hWnd, "", $sTitle & " - On top")
    EndIf
EndFunc   ;==>AlwaysOnTop

for me this works

 

EDIT: problem was the WIN+T switch the instances of tasks so the title wouldn't be get and the script can't find the window

i would add an winactivate after because WIN+T still switch the instances

a solution for deactivate windows hotkeys aren't in my mind, so there could be a problem when you set a multi instance window on top. x) But you can adjust the script for it i guess. I didnt try it yet

Edited by Aelc

why do i get garbage when i buy garbage bags? <_<

Link to comment
Share on other sites

It is bad practice to use Win-Keys as hotkeys. They are reserved for Windows. Win-T was still free in Win7 times, but is reserved for cycling through the taskbar icons in Win10.
You cannot deactivate these hotkeys either.
See my hotkey tester here:

_HotKey("{ESC}")
_HotKey("#t")
Func _HotKey($hotkey = "")
;       ! ALT  + SHIFT  ^ CONTROL  # WinKey
    Switch @HotKeyPressed
        Case "{ESC}"
            Exit 0*MsgBox(64 + 262144, Default, "Exit", 1)
        Case "#t"
            Beep()
        Case Else
            If Not IsDeclared("hotkey") Then Return MsgBox(16 + 262144, Default, "No CASE statement defined for hotkey " & @HotKeyPressed,15)
            If HotKeySet($hotkey, "_Hotkey") = 0 Then Return MsgBox(16 + 262144, Default, "Hotkey " & $hotkey & " invalid or set by another application.",15)
    EndSwitch
EndFunc   ;==>_HotKey

While Sleep(100)     ; here should be your application.
WEnd                 ; meanwhile, here is a dummy loop.

 

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

One other possibility is to disable the Win key at once using registry, and use AutoIt to remap certain key combinations to other keys.  But remember that once disable, the Win key becomes useless (until you reenable it again ofc).

Link to comment
Share on other sites

@Nine Thank you for this idea. Currently I use AutoHotkey for it:

; alwaysontop.ahk
#SingleInstance, Force
SetWorkingDir, % A_ScriptDir
#t::Run, alwaysontop.au3
; alwaysontop.au3
#NoTrayIcon
#include <WinApi.au3>
#include <WindowsConstants.au3>

Func Example()
    Local $sTitle = WinGetTitle ( "[ACTIVE]" )
    Local $hWindow = WinGetHandle ( "[ACTIVE]" )

    If BitAND(_WinAPI_GetWindowLong($hWindow, $GWL_EXSTYLE), $WS_EX_TOPMOST) Then
        WinSetOnTop ( $hWindow, "", $WINDOWS_NOONTOP )
    Else
        WinSetOnTop ( $hWindow, "", $WINDOWS_ONTOP )
    EndIf
EndFunc

Example()

 

Edited by john_2019
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...