supersonic Posted February 9, 2015 Share Posted February 9, 2015 (edited) Hi - I'm trying to put a window (= AutoIt GUI) permanently to background. Is there an extended style like "$WS_EX_DOWNMOST"? Or do I have to set other windows to foreground? Edited February 9, 2015 by supersonic Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 9, 2015 Moderators Share Posted February 9, 2015 Might have a go at _WinAPI_SetWindowPos and HWND_BOTTOM flag. Or set it as a child to the desktop. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
supersonic Posted February 9, 2015 Author Share Posted February 9, 2015 Sounds good - I'll give it a try... Link to comment Share on other sites More sharing options...
TheSaint Posted February 9, 2015 Share Posted February 9, 2015 Perhaps you need to explain what you mean by background? If you just want your GUI to not be minimized, just remove that and don't set the TOPMOST flag. That way, it will always be there until closed ... like a background ... though other things may appear behind it if active first. What you are probably talking about is Window order. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
supersonic Posted February 9, 2015 Author Share Posted February 9, 2015 TheSaint, You are right, I'm talking about window order. My GUI is transparent (will be temp. shown for status information) - I think _WinAPI_SetWindowPos/HWND_BOTTOM should fit my need... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 9, 2015 Moderators Share Posted February 9, 2015 make sure you make use of swp_nozorder too Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
supersonic Posted February 9, 2015 Author Share Posted February 9, 2015 (edited) No luck yet - I'm using the example from help file: #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hWnd = WinGetHandle("[CLASS:Notepad]") If @error Then MsgBox($MB_SYSTEMMODAL, "", "Notepad window not found.") Return False EndIf Local $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) $iStyle = BitXOR($iStyle, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX) _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iStyle) _WinAPI_SetWindowPos($hWnd, $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOZORDER, $SWP_NOMOVE, $SWP_NOSIZE)) EndFunc ;==>Example The window title boxes are removed/added but - if Notepad window is positioned between other windows - it will not be put to "background" (~ last in window order). What did I wrong? Edited February 9, 2015 by supersonic Link to comment Share on other sites More sharing options...
mikell Posted February 9, 2015 Share Posted February 9, 2015 Did you try the 2nd solution from SM in post #2 ? #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Example() Func Example() ; Assign a Local variable the handle of the NotePad window Local $hWnd = WinGetHandle("[CLASS:notepad]") ; If the window does not exists, display a message and return False. If @error Then MsgBox($MB_SYSTEMMODAL, "", "Notepad window not found.") Return False EndIf ; Assign a Local variable the style of the Notepad window. Local $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) ; Remove from the window style the MAXIMIZEBOX, MINIMIZEBOX and SIZEBOX styles. $iStyle = BitXOR($iStyle, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX) ; Set the style of the window. _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iStyle) ; Attach window to the desktop (always on bottom) Local $hParent = WinGetHandle('[CLASS:Progman;TITLE:Program Manager]') _WinAPI_SetParent($hWnd, $hParent) EndFunc ;==>Example Link to comment Share on other sites More sharing options...
supersonic Posted February 9, 2015 Author Share Posted February 9, 2015 (edited) I should have mentioned that my script/GUI is part of a logoff script - my fault, sorry. In this state there seems to be no "[CLASS:Progman;TITLE:Program Manager]". Can a window be placed "behind" an other window by specifying window handles (= just change the "visible" order)? Edited February 9, 2015 by supersonic Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 10, 2015 Moderators Share Posted February 10, 2015 (edited) expandcollapse popup#include <WinAPI.au3> #include <WinAPIProc.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> Global $ghNP = WinGetHandle("[CLASS:Notepad]") WinActivate($ghNP) Sleep(3000) _WinSetZOrderPos($ghNP, Default, True, True, True) ConsoleWrite(@error & @CRLF) Func _WinSetZOrderPos($hWnd, $hWndAfter = 0, $bRemoveMaximize = 0, _ $bRemoveMinimize = 0, $bRemoveSizeBox = 0) $hWndAfter = ((IsKeyword($hWnd) Or $hWndAfter < 1) ? 0 : $hWndAfter) Local $ahWnds If Not $hWndAfter Then $ahWnds = _WinAPI_EnumDesktopWindows(_WinAPI_GetThreadDesktop( _ _WinAPI_GetCurrentThreadId())) If @error Or Not IsArray($ahWnds) Then Return SetError(1, 0, 0) EndIf If $ahWnds[0][0] > 1 Then $hWndAfter = $ahWnds[$ahWnds[0][0]][0] EndIf EndIf Local $iStyle If $bRemoveMaximize Or $bRemoveMinimize Or $bRemoveSizeBox Then $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) If $bRemoveMaximize Then $iStyle = BitXOR($iStyle, $WS_MAXIMIZEBOX) If $bRemoveMinimize Then $iStyle = BitXOR($iStyle, $WS_MINIMIZEBOX) If $bRemoveSizeBox Then $iStyle = BitXOR($iStyle, $WS_SIZEBOX) _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iStyle) EndIf Local $bRet = _WinAPI_SetWindowPos($hWnd, $hWndAfter, 0, 0, 0, 0, _ BitOR($SWP_FRAMECHANGED, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOACTIVATE)) If @error Or Not $bRet Then Return SetError(2, 0, 0) EndIf Return $bRet EndFunc Edit: Oops, left the remove tray icon variables in there, I didn't get to that part! Edited February 10, 2015 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
supersonic Posted February 10, 2015 Author Share Posted February 10, 2015 SmOke_N, nice approach. I'll give it a try... 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