Jump to content

Recommended Posts

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:

YGbAlxu4Tlyr8Oy6u8rJOQ.png

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 by AndyK70
added tags
Link to post
Share on other sites
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 Gude
How 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

Link to post
Share on other sites
  • Developers
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 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.
  :)

Link to post
Share on other sites

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 Gude
How 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

Link to post
Share on other sites
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 :o 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. :blink:
Process Explorer then showed me, that this specific PID was for ApplicationFrameHost.exe, the others are for tasks which are suspended:

Ukgv5tSaTeeeFZFxIoxKDg.png

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 by AndyK70
Link to post
Share on other sites

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)

 

Link to post
Share on other sites
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.

 

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By WilliamasKumeliukas
      Hello everyone,
      I started this project alone in May 2020 as project in my spare time at work, I'm working for a IT company that started opening their services to residential customers few months ago and now my position in the company kind of drifted in the doom and gloom world of repetitive tasks like: Reinstallation + Configuration of Windows 10.
      The procedure is very repetitive and I started feeling like being a robot which is the main reason I started this project.
       
       
      ==============================FAQ==================================
      1. Q: Do you want this project to be accomplished with the usage of AutoIt ONLY or 3rd party tools / Scripts (BATCH / POWERSHELL / VB) ? A: No, if I cannot find a way using AutoIt to accomplish a task I will move to my Plan B which consist of automating an 3rd party tool to accomplish the affected task until a solution is found. 2. Q: What do I get from helping/collaborating in this project? A: I will personally take the responsibility to mention you in the credits of this project. 3. Q: If I have more questions, can I ask? A: Certainly! feel free to ask any questions related to this project! 4. Q: What is the main goal of this project? A: Automating Windows 10 configuration without user interaction needed (as much as possible) ______________________________________________________________________________________________________________________________
      Current progression of the project (more will be added in future)
      « Blue = Info || Yellow = Unfinished/Untested || Purple = Could be better || Green = Done ||Red = Not Yet Started »
      ***Very early Stage ***
      Connect Network Attached Storage(NAS) (Work but missing configuration in GUI - AutoIt only)
      Download & Install up to 600+ softwares (Tested & Working - using 3rd party tool + 50/50 Powershell/AutoIt)
       Auto prediction of Apps name of text typed inside input (Tested & Working - AutoIt Only)
      Change OEM Informations (Tested & Working -  AutoIt)
      Disable hibernation (Tested & Working - AutoIt only)
      Change Computer Name (Work but require testing - AutoIt only) 
      Show Computer Information and Smart status on GUI (Tested & Working - AutoIt Only)
      Change .pdf / .pdfxml from Edge to Adobe Reader DC (Tested & Working - using 3rd party tool)
      Change Edge to Google Chrome as Default Browser (Tested & Working - using 3rd party tool)
      Windows Updater (Seems to work but require further testing - AutoIt only)
      Install Office 365 / 2013 + Activation (To Do)
      Add L2TP VPN Configuration for Windows Built-in VPN (To Do)
      Save / Load tasks configuration profile in (.ini file) to avoid repeating same configuration twice (In progress - AutoIt Only)
      (EXPERIMENTAL) Install Apps from Microsoft Store with UIAutomation UDF made by @junkew(Work if you know what your doing)
         P.S: Installing Apps from Microsoft Store will require usage of  UIA spy tool made by @LarsJ which you can download & learn how to use it on UIA Spy Tool thread.
      ***  If this project interest you, Reply here This will greatly help me to see if you'd like this project to become real  ***
      ______________________________________________________________________________________________________________________________
      Best Regards,
      ~WilliamasKumeliukas
    • By XGamerGuide
      I'm trying to call WinList() with a handle. That should be possible:
      But I only get back an 2d array that looks like this:
      ---------
      0 |
      (That means no window was found.)
      It's not the window or the handle. When I call other functions like WinExists() or WinGetHandle() it works.
      Is it because of me, the description in the reference or because of Autoit who makes a mistake?
      No, because of the rest of my program I don't want to use WinGetTitle() because the format of WinList() has to be kept. Alternatively, I could create a 2d array myself, but it should also work with WinList() ... I hope.
    • By beautifulsoup
      Hi All,
      I'm not sure if its possible that I'm trying to achieve, I've looked into https://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/AutoIt3Wrapper.html and such resources for help, but I cant really find the answer to my question.
      So upon compiling the script in SciTE, the exe file is given a Description under file Properties>Details. I understand, that  one can enter info manually there and it can even implement the version automatically with each compilation.
       
      What I'm trying to achieve is to somehow include the "@ScriptName" in the Details>File Description Field. But as I see no variable can be taken after "#" in this case.
       
      Do You think its achievable? (Win 10)
       
      Much obliged for taking time on reading this.
       
      Kind Regards,
      Brave


    • By IndianSage
      Hi,
      I have a specific situation:
      Is it possible to run autoit script/.exe as a task which in turn is automating a desktop user interactive application on windows 10 where user will not be logged in - at best I can get user locked? 
      If so how will this work or is there any tool available to do this?
      I am trying z-cron task scheduler but it runs only some part also I tried windows 10 task schedule with option to allow task to run which is user interactive type but that too does not work.
      Looking forward to hear from you to help me out of this situation.
      Thanks,
       
    • By therks
      So I have no example code currently because I'm not sure where to even start.
      We're using the parental controls on the computer and the kids each have their own user profiles with limited time. The problem we're encountering is when their time runs out, or if they just hit Win+L and leave the computer, their games are still running in the background. I was hoping to write up a quick AutoIt script and throw it in a recurring scheduled task to just sign off any of the kid's profiles that's not currently active. I found some suggestions to use "query session" and then "logoff [user]" in the command line (which it seems I could easily automate with AutoIt) but that's only available on Win Pro and this system is running Home (and I even tried copying the query.exe from a Pro system but it errors out). Is there some AutoIt equivalent to the query and logoff functions or am I stuck?
      Edit: I'm adding some clarification to exactly what I'm hoping to get out of this script.
      I'd like to setup a scheduled task that runs outside of the current user (perhaps under the SYSTEM account?) in case NO user is currently active, that will detect which users are currently signed in. If users from a predefined list are not currently active, sign them off entirely.
      So let me give two examples:
      Example #1:
      - I am logged in, but not active (I left my browser open and locked the computer) - Nephew A is logged in, but not active (his time ran out while his game was running and the computer auto-locked) - Nephew B is logged in, and currently playing a game When script runs, ignore my profile (leave it signed in), log out Nephew A (closing his game), and ignore Nephew B because he's actively using the computer. Example #2:
      - I am logged in - Nephew A is logged in - Nephew B is logged in - No users are currently active (Windows is sitting on the choose user / sign in screen) When script runs, ignore my profile, log out Nephew A and Nephew B.  
      I would perceive pseudo code, going as such:
      $aChildUsers = [ 'NephewA', 'NephewB' ] $aUserList = GetSignedInUsers() For $i = 0 to UBound($aUserList)-1 If Not UserIsActive($aUserList[$i]) Then For $j = 0 to UBound($aChildUsers)-1 If $aUserList[$i] = $aChildUsers[$j] Then LogOffUser($aUserList[$i]) Next EndIf Next Obviously, GetSignedInUsers(), UserIsActive(), LogOffUser() are not real functions. What I'm searching for is something of their equivalent.
      Thanks for your time!
×
×
  • Create New...