john_2019 Posted March 31, 2020 Posted March 31, 2020 (edited) 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 March 31, 2020 by john_2019
Aelc Posted March 31, 2020 Posted March 31, 2020 _ispressed() Did you tried ? why do i get garbage when i buy garbage bags?
Aelc Posted March 31, 2020 Posted March 31, 2020 (edited) #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 March 31, 2020 by Aelc why do i get garbage when i buy garbage bags?
john_2019 Posted March 31, 2020 Author Posted March 31, 2020 Thank you a lot, Aelc. So you think that deactivating default Win+T behavior is a bad idea? I will try 🙂
Exit Posted March 31, 2020 Posted March 31, 2020 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()
Aelc Posted April 1, 2020 Posted April 1, 2020 @Exit im using win7 and still it's hotkey for windows why do i get garbage when i buy garbage bags?
Exit Posted April 1, 2020 Posted April 1, 2020 11 hours ago, Exit said: Win-T was still free in Win7 Then Win-t was probably introduced earlier. 😎 App: Au3toCmd UDF: _SingleScript()
Nine Posted April 1, 2020 Posted April 1, 2020 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). “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
john_2019 Posted April 1, 2020 Author Posted April 1, 2020 (edited) @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 April 1, 2020 by john_2019
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now