Set a window AlwaysOnTop when RegisterCallback("OnWinActiveChange")

Get help with using AutoHotkey and its commands and hotkeys
Sam Bo
Posts: 2
Joined: 30 Jan 2014, 12:20

Set a window AlwaysOnTop when RegisterCallback("OnWinActiveChange")

20 Aug 2019, 19:03

I would like to put a splashimage or other kind of window, in front of specific active windows (in a list or group).
Thanks to all !

Code: Select all

GroupAdd, WHITE_WINS,     ahk_class ShImgVw:CPreviewWnd
GroupAdd, WHITE_WINS,     ahk_class #32770
; How can a list be done (instead of GroupAdd)?  I guess  this way... 
; SetTitleMatchMode, REGEX
; RegexMatch:="(Title1 ahk_class CabinetWClass|Title2 ahk_class Notepad)" ; ◄FAIL ¿Why?
; RegexMatch:="ahk_class (?:CabinetWClass|Notepad)"  ; ◄WORK
; WinGet, wList, List, %RegexMatch%
; Tootltip, %wList%


;based on:  Simple File Explorer Fix   https://autohotkey.com/boards/viewtopic.php?f=5&t=48911
OnWinActiveChange(hWinEventHook, vEvent, hWnd)   
{   static _ := DllCall("user32\SetWinEventHook", UInt,0x3, UInt,0x3, Ptr,0, Ptr,RegisterCallback("OnWinActiveChange"), UInt,0, UInt,0, UInt,0, Ptr) ;EVENT_SYSTEM_FOREGROUND := 0x3
	 ; DetectHiddenWindows, On
	 ; WinGetClass, vWinClass, % "ahk_id " hWnd

IfWinActive, ahk_group WHITE_WINS
    {    WinSet, AlwaysOnTop, on,   ahk_class WordPadClass  ; ◄FAIL ¿Why?
         WinSet, Top,,   ahk_class WordPadClass  ; ◄FAIL ¿Why?
         ; I don't want to use winshow, because i believe there's a bug in my app when I using it.
    }
  else 
    {   WinSet, AlwaysOnTop, off,    ahk_class WordPadClass
         WinSet, Bottom,,    ahk_class WordPadClass  ; ◄WORK
     }

}

Return to “Ask For Help”

Who is online

Users browsing this forum: garman666, Google [Bot], TheMainEvent, tsm21993 and 62 guests