AndyK70 Posted January 31, 2018 Posted January 31, 2018 (edited) I'm trying to fill a ListView with all normal viewable windows to act with them. First I tried with WinList: Local $aWinList = WinList("[REGEXPTITLE:(?i)(.+)]") Local $aTmp, $iID ;~ _ArrayDisplay($aWinList) For $i = $aWinList[0][0] To 1 Step -1 ; going backwards not disturbing the index while cycling through and deleting some If StringStripWS( $aWinList[$i][0], 3) == "" Or _ Not BitAND(WinGetState($aWinList[$i][1]), $WIN_STATE_VISIBLE) Or _ BitAND(WinGetState($aWinList[$i][1]), $WIN_STATE_MINIMIZED ) Then _ArrayDelete($aWinList, $i) Else ; Window has a Title and is "visible" $aTmp = WinGetPos($aWinList[$i][1]) If $aTmp[0] < -1000 Or $aTmp[1] < -1000 Then ; Window is minimized or tray icon _ArrayDelete($aWinList, $i) EndIf EndIf Next $aWinList[0][0] = UBound($aWinList)-1 ; getting actual # of windows ; Each row is now [ID]=> [Title], [hWnd] But it keeps getting Windows which are definitely not there at least not visible: Those windows "Rechner", "Einstellungen", "Netflix", "Microsoft Store", ... are not there!?! It should list only the first three windows, which are real. I even tried it with _WinAPI_ UDF: $hWnd = _WinAPI_GetForegroundWindow() ; Add items _GUICtrlListView_BeginUpdate($idListview) If $hWnd <> 0 Then $iI = 0 Do If _WinAPI_IsWindow($hWnd) And _WinAPI_IsWindowVisible Then _GUICtrlListView_AddItem($idListview, WinGetTitle($hWnd)) _GUICtrlListView_AddSubItem($idListview, $iI, $hWnd, 1) $iI += 1 $hWnd = _WinAPI_GetWindow($hWnd, $GW_HWNDNEXT) EndIf Until $hWnd = 0 EndIf But it is the same... How can i distinguish those invisible windows from normal ones? PS: I'm using Windows 10, maybe it is important to know? Edited January 31, 2018 by AndyK70 added tags
jdelaney Posted January 31, 2018 Posted January 31, 2018 WinGetState. Is visible flag. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
AndyK70 Posted January 31, 2018 Author Posted January 31, 2018 Just now, jdelaney said: WinGetState. Is visible flag. I did, please have a closer look into the example code I provided.
BrewManNH Posted January 31, 2018 Posted January 31, 2018 1 hour ago, AndyK70 said: I did, No, you didn't. WinGetState is an AutoIt function, and you don't have that anywhere in your code, you're using the _WinAPI_GetWindow function. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Developers Jos Posted January 31, 2018 Developers Posted January 31, 2018 (edited) 17 minutes ago, BrewManNH said: No, you didn't. It is used in the first piece of code in the line below the If. The second piece of code has en error in this line: If _WinAPI_IsWindow($hWnd) And _WinAPI_IsWindowVisible Then _WinAPI_IsWindowVisible should have the handle as parameter. Have you checked what the State is of these windows you don't want to see? Jos Edited January 31, 2018 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
BrewManNH Posted January 31, 2018 Posted January 31, 2018 Oh, missed that first bit of code containing it. Mea Culpa If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
jdelaney Posted February 1, 2018 Posted February 1, 2018 You can also start collecting the class names of the windows, and start filtering on those: _WinAPI_GetClassName IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
AndyK70 Posted February 1, 2018 Author Posted February 1, 2018 (edited) 16 hours ago, Jos said: The second piece of code has en error in this line: If _WinAPI_IsWindow($hWnd) And _WinAPI_IsWindowVisible Then _WinAPI_IsWindowVisible should have the handle as parameter. Oh, yes right. Changed it, but doesn't help either. Quote Have you checked what the State is of these windows you don't want to see? I did dig a littler deeper, got the PIDs and nearly all of them were the same which confused me a little bit. Process Explorer then showed me, that this specific PID was for ApplicationFrameHost.exe, the others are for tasks which are suspended: Notice the "Winstore.App.exe"(found as Microsoft Store), "SystemSettings.exe" (Einstellungen) and "Calculator.exe" (Rechner) are all those metro apps and so is the found Netflix app which is hiding behind the ApplicationFrameHost.exe. I hope these are some useful information, even if I still don't know how I could filter them out. @jdelaney I checked them and found the Class "ApplicationFrameWindow" for all of them, but this class is for all metro apps, it doesn't tell me if they are hidden or not. Edit: If you want me anything to try, to search for or use some different tool to investigate further, please tell me. Edited February 1, 2018 by AndyK70
Subz Posted February 1, 2018 Posted February 1, 2018 Maybe something like the following? You could also check for any processes with a suspended state (WIn 10). #include <Array.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Local $hWindow, $vWinStyle, $aWinNormal[1][2] Local $aWinList = WinList("[REGEXPTITLE:(?i)(.+)]") For $i = $aWinList[0][0] To 1 Step - 1 If $aWinList[$i][0] = "" Then ContinueLoop $hWindow = WinGetHandle($aWinList[$i][1], "") If Not $hWindow Then ContinueLoop $vWinStyle = _WinAPI_GetWindowLong($hWindow, $GWL_STYLE) If BitAND(WinGetState($aWinList[$i][1]), 4) = 4 _ And BitAND($vWinStyle, $WS_VISIBLE) = $WS_VISIBLE _ And BitAND($vWinStyle, $WS_MINIMIZE) <> $WS_MINIMIZE _ And BitAND($vWinStyle, $WS_MINIMIZEBOX) = $WS_MINIMIZEBOX _ And BitAND($vWinStyle, $WS_MAXIMIZEBOX) = $WS_MAXIMIZEBOX Then _ArrayAdd($aWinNormal, $aWinList[$i][0] & "|" & $aWinList[$i][1]) Next $aWinNormal[0][0] = UBound($aWinNormal) - 1 _ArrayDisplay($aWinNormal) AndyK70 1
AndyK70 Posted February 1, 2018 Author Posted February 1, 2018 5 hours ago, Subz said: You could also check for any processes with a suspended state (WIn 10). Yes, that would definitely help. Do you have a hint, where I should look for more information to check this? I was looking in the helpfile, online help and even msdn but only found sth. how to suspend and resume a process, but not how to check if a process is suspended.
Subz Posted February 1, 2018 Posted February 1, 2018 Have a look at the following WinApi function would probably be faster than WMI AndyK70 1
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