Always On Top Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
roysubs
Posts: 428
Joined: 29 Sep 2018, 16:37

Always On Top

21 Oct 2021, 02:49

I use the below to control always on top. Someone on this forum showed me the #If NotDeskPins() and that's great (I additionally use F8 for Chrome windows as this is where I use it the most, I install 'Enhancer for YouTube' into Chrome, then hit 'Pop-up player' to pop out a video window, then F8 to always on top while I am working on other things fullscreen), but I was wondering:

• How can I show the changing status in the TrayTip, i.e. instead of saying "has switched", to properly say "is now 'Always On Top'" or "the 'Always On Top' setting has been turned off"

• Can I capture the name of the Window to which I am applying the Always On Top so that the TrayTip can say what is being acted upon. e.g. "The selected Windows Explorer window is now set to 'Always On Top'" / "The selected Chrome window has had its Always On Top flag turned off"?

Code: Select all

; If DeskPins is installed, use that for Ctrl-F12, otherwise, use AutoHotkey method
#If NotDeskPins()
^F12::
    WinSet, AlwaysOnTop, , A
    TrayTip, Current Window has switched Always on top, Press again to switch setting 
    SoundBeep, 500, 5
return
#If

#ifWinActive ahk_exe chrome.exe   ; Only allow if Chrome is the active window
F8::
    WinSet, AlwaysOnTop, , A
    TrayTip, Current Window has switched Always on top, Press again to switch setting 
    SoundBeep, 500, 5
return
#If

NotDeskPins() {
	process,exist,deskpins.exe
	return !errorlevel
}
Last edited by roysubs on 21 Oct 2021, 06:07, edited 1 time in total.
User avatar
mikeyww
Posts: 26939
Joined: 09 Sep 2014, 18:38

Re: Always On Top  Topic is solved

21 Oct 2021, 05:50

Code: Select all

#IfWinActive ahk_exe chrome.exe
F8::
#If !procExist("deskpins")
^F12::ontopToggle("A")
#If

ontopToggle(winTitle) {
 If !WinExist(winTitle) {
  MsgBox, 48, Error, Window not found.`n`n%winTitle%
  Return
 } Else WinSet, AlwaysOnTop
 WinGetTitle, winTitleText
 WinGet, ExStyle, ExStyle
 TrayTip, % (ExStyle & WS_EX_TOPMOST := 8) ? "ON TOP:" : "NOT ON TOP:"
  , %winTitleText%`n`nPress again to switch setting.
 SoundBeep, 1500
}

procExist(pname) {
 Process, Exist, %pname%.exe
 Return ErrorLevel
}
Last edited by mikeyww on 21 Oct 2021, 06:10, edited 1 time in total.
roysubs
Posts: 428
Joined: 29 Sep 2018, 16:37

Re: Always On Top

21 Oct 2021, 06:09

Thanks Mikey. Amazing (as always!). I will enjoy going through this in detail and learning from it. 🙂👍

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 282 guests