VAN0 Posted April 27, 2014 Share Posted April 27, 2014 Hello.Is there a way check if an opened window is actually visible on screen and not behind other window?WinGetState always returns 7 (Window is visible)Any tricks available for this? For example a way get z-index (css definition) of all opened windows or something in that nature?Thank you. Link to comment Share on other sites More sharing options...
jguinch Posted April 27, 2014 Share Posted April 27, 2014 The array returned by WinList is sorted by z-index. An example >here Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Starstar Posted April 27, 2014 Share Posted April 27, 2014 Look at WinActive(Checks to see if a specified window exists and is currently active)in help......... #include <MsgBoxConstants.au3> If WinActive("[CLASS:Notepad]") Then ; Check if Notepad is currently active. MsgBox($MB_SYSTEMMODAL, "", "WinActive" & @CRLF & "Notepad is active.") Else MsgBox($MB_SYSTEMMODAL, "", "WinActive" & @CRLF & "Notepad is not active.") EndIf Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
VAN0 Posted April 27, 2014 Author Share Posted April 27, 2014 Thank you.z-index of WinList didn't work because top-most window are always first.WinActive won't work in my case, because I didn't mention how I'm gonna use it:I need change option name in tray content menu.So when you right click on tray menu taskbar become active at that moment.So far I managed to make it work by using WM_SHELLHOOKexpandcollapse popupOpt("TrayOnEventMode", 1) Opt("TrayMenuMode", 8 + 4 + 2 + 1) #include<WinAPIEx.au3> #include<TrayConstants.au3> #include <GUIConstantsEx.au3> Global $hGUI = GUICreate("test") Global $gFocusedHwnd = $hGUI, $gFocusedPrevHwnd = $hGUI $tToggle = TrayCreateItem("Show") TrayItemSetOnEvent(-1, "ShowHide") TrayCreateItem("") $tExit = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "ExitScript") TraySetClick(16) TraySetState($TRAY_ICONSTATE_SHOW) TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "ShowHide") TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN, "TrayMenu") GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), 'WM_SHELLHOOK') ; Define a window message and assign to the WM_SHELLHOOK function. _WinAPI_RegisterShellHookWindow($hGUI) ; Register the shell hook message to our GUI. GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitScript() EndSwitch WEnd Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam) If $wParam = $HSHELL_WINDOWACTIVATED Or $wParam = $HSHELL_RUDEAPPACTIVATED Then If $gFocusedHwnd <> $lParam Then If $gFocusedPrevHwnd <> $gFocusedHwnd Then $gFocusedPrevHwnd = $gFocusedHwnd $gFocusedHwnd = $lParam EndIf EndIf EndFunc ;==>WM_SHELLHOOK Func TrayMenu() If $hGUI = $gFocusedPrevHwnd And BitAND(WinGetState($hGUI), 2) Then TrayItemSetText($tToggle, "Hide") Else TrayItemSetText($tToggle, "Show") EndIf EndFunc Func ShowHide() If $hGUI = $gFocusedPrevHwnd And BitAND(WinGetState($hGUI), 2) Then GUISetState(@SW_HIDE, $hGUI) $gFocusedPrevHwnd = 0 Else GUISetState(@SW_SHOWNORMAL, $hGUI) WinActivate($hGUI) $gFocusedPrevHwnd = $hGUI EndIf EndFunc Func ExitScript() _WinAPI_DeregisterShellHookWindow($hGUI) Exit EndFunc Link to comment Share on other sites More sharing options...
Starstar Posted April 28, 2014 Share Posted April 28, 2014 good Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." 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