Search the Community
Showing results for tags 'z-order'.
-
I'm creating an alternative to Windows' alt-tab menu, and I'm encountering issues with WinList as it DOES NOT provide the correct order of recently opened or activated windows. While WinList normally respects the z-order, this is not the case when topmost windows are present (mentioned here). Here is an example showing what I mean: #include <WinAPI.au3> #include <WindowsConstants.au3> Run('notepad.exe') Run('calc.exe') Local $sNotepadTitle = 'Untitled - Notepad' Local $sCalculatorTitle = 'Calculator' WinWait($sNotepadTitle) WinWait($sCalculatorTitle) WinSetOnTop($sCalculatorTitle, '', $WINDOWS_ONTOP) WinActivate($sNotepadTitle) ConsoleWrite('Active window: ' & WinGetTitle('[ACTIVE]') & @CRLF) ConsoleWrite('First visible window from WinList: ' & getTopWindow() & @CRLF) Func getTopWindow() Local $aList = WinList() For $i = 1 To $aList[0][0] $iExStyle = _WinAPI_GetWindowLong($aList[$i][1], $GWL_EXSTYLE) ; get the extended style of each Window If Not BitAND($iExStyle, $WS_EX_TOOLWINDOW) And _ ; Search for windows without $WS_EX_TOOLWINDOW extended style BitAND(WinGetState($aList[$i][1]), $WIN_STATE_VISIBLE) Then ; And only visible windows Return $aList[$i][0] EndIf Next EndFunc Explain: Activating Notepad should precede Calculator in WinList. However, due to $WS_EX_TOPMOST, Calculator takes precedence over any non-$WS_EX_TOPMOST windows in the WinList array. I've tried _WinAPI_EnumWindows, _WinAPI_EnumWindowsTop, both yield the same result as WinList. Are there any other APIs or methods to retrieve a list of recently activated windows, regardless of topmost windows (similar to Windows' alt-tab menu)?
-
Hi All, I'd like to move a window to the top of the stack without it being active. I think it's called z-order in programming? I've tried these 2 options (commenting out 1 at a time obviously), but the 1st doesn't seem to do anything, and the 2nd prevents it from being moved behind the other programs even after clicking on it and then clicking on another window behind it: Local $hWnd = WinGetHandle("[CLASS:MSPaintApp]") _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE)) _WinAPI_SetWindowPos($hWnd, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE)) What can I do to move something to the top of the z-order while allowing it to be manually moved back in the z-order? Thanks!
-
Hello, How come in this example, when I click on label 2, I get the notification for Label 1? I have 2 controls overlapping, and I cannot disable them. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Global $GUI, $LABEL1, $LABEL2 $GUI = GUICreate("Test", 800, 600) $LABEL1 = GUICtrlCreateLabel("Label 1", 40, 40, 700, 520) GUICtrlSetBkColor(-1, 0xFF0000) $LABEL2 = GUICtrlCreateLabel("Label 2", 100, 100, 600, 400) GUICtrlSetBkColor(-1, 0x00FF00) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch Sleep(50) WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word Switch $hWndFrom Case GUICtrlGetHandle($LABEL1) MsgBox(0, "Click received", "Label 1 was clicked") Case GUICtrlGetHandle($LABEL2) MsgBox(0, "Click received", "Label 2 was clicked") EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Thanks in advance for your help.