Zohar Posted March 6, 2012 Share Posted March 6, 2012 (edited) HiTo change a window's AlwaysOnTop property, we can use the WinSetOnTop() function.But If I need to Check a window's AlwaysOnTop property, I did not find a WinGetOnTop() function.How can I write such one?Or if anyone wrote on and can post it, it can help.Thank you Edited March 6, 2012 by Zohar Link to comment Share on other sites More sharing options...
KaFu Posted March 6, 2012 Share Posted March 6, 2012 (edited) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> $hGUI = GUICreate("My GUI") GUISetState(@SW_SHOW) ConsoleWrite(BitAND(_WinAPI_GetWindowLong($hGUI, $GWL_EXSTYLE), $WS_EX_TOPMOST) & @CRLF) WinSetOnTop($hGUI, "", 1) ConsoleWrite(BitAND(_WinAPI_GetWindowLong($hGUI, $GWL_EXSTYLE), $WS_EX_TOPMOST) & @CRLF) WinSetOnTop($hGUI, "", 0) ConsoleWrite(BitAND(_WinAPI_GetWindowLong($hGUI, $GWL_EXSTYLE), $WS_EX_TOPMOST) & @CRLF) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() Edit: Or as a separate function: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> $hGUI = GUICreate("My GUI") GUISetState(@SW_SHOW) ConsoleWrite(_WinGetOnTop($hGUI) & @CRLF) WinSetOnTop($hGUI, "", 1) ConsoleWrite(_WinGetOnTop($hGUI) & @CRLF) WinSetOnTop($hGUI, "", 0) ConsoleWrite(_WinGetOnTop($hGUI) & @CRLF) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() Func _WinGetOnTop($hWnd) If BitAND(_WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE), $WS_EX_TOPMOST) Then Return 1 Return 0 EndFunc ;==>_WinGetOnTop Edited March 6, 2012 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
KaFu Posted March 6, 2012 Share Posted March 6, 2012 (edited) afaik it should work fine... Edit: For the record, I'm not talking to myself (yet) ... the post before this (asking if this works for none Autoit windows too) was deleted by the OP... Edited March 6, 2012 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Zohar Posted March 6, 2012 Author Share Posted March 6, 2012 hehe Sorry I deleted it by mistake. And regarding your function, it works amazing!! Thank you very much for it (: Link to comment Share on other sites More sharing options...
UEZ Posted March 6, 2012 Share Posted March 6, 2012 (edited) Here my version: #include <constants.au3> #include <windowsconstants.au3> #include <winapi.au3> HotKeySet("{ESC}", "_Exit") Do $aRet = DllCall("user32.dll", "int", "WindowFromPoint", "long", MouseGetPos(0), "long", MouseGetPos(1)) $state = _WinAPI_GetWinTopmostState(HWnd($aRet[0])) ToolTip(_WinAPI_GetWindowText(_WinAPI_GetAncestor(HWnd($aRet[0]), $GA_ROOT)) & " = " & $state, MouseGetPos(0) + 30, MouseGetPos(1) + 20, "Is on top", 1, 4) Until Not Sleep(50) Func _Exit() Exit EndFunc Func _WinAPI_GetWinTopmostState($hWnd) Local $hWnd_Root = _WinAPI_GetAncestor($hWnd, $GA_ROOT) Return BitAND(_WinAPI_GetWindowLong($hWnd_Root, $GWL_EXSTYLE), $WS_EX_TOPMOST) = True EndFunc Br, UEZ Edited March 6, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Zohar Posted March 7, 2012 Author Share Posted March 7, 2012 Very nice Thank you UEZ Link to comment Share on other sites More sharing options...
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