WinGetMinMax false detection windows 10 Topic is solved

Propose new features and changes
Ashtefere
Posts: 14
Joined: 02 Dec 2017, 11:14

WinGetMinMax false detection windows 10

02 Dec 2017, 12:53

Windows 10 suspends it's "windows store" apps in the background using superfetch/prefetch, even if you don't open them.

Commonly 'stored' apps are Photos, Mail, and Windows Store itself.

The problem is, if these apps are maximized last time they were used, and then windows 10 decides to preload them (while they stay suspended - not on taskbar or alt tab) then autohotkey still detects them as "open" and maximized.

This is breaking the main functionality of the feature, I feel.

I searched this forum and the bugs forum and could not find this reported. I thought I would post it here as it may be considered a new feature perhaps.
User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: WinGetMinMax false detection windows 10

02 Dec 2017, 13:43

Yes, other window commands such as WinExist, etc, find these background windows
try it and see
...
Ashtefere
Posts: 14
Joined: 02 Dec 2017, 11:14

Re: WinGetMinMax false detection windows 10

03 Dec 2017, 00:02

I know they detect them. The minimax function is the problem. It's detecting a window as maximised when it is not visible.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: WinGetMinMax false detection windows 10

03 Dec 2017, 01:05

- Does this work to tell you if the window is visible or not? If so, you could write your own custom function version of the WinGet-MinMax subcommand.

Code: Select all

vWinIsVis := DllCall("user32\IsWindowVisible", Ptr,hWnd) ;1 = visible, 0 = not visible
- There seem to have been a lot of problems with certain Windows 10 windows e.g. Calculator.
- Which command(s) detects them as 'open'?
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Ashtefere
Posts: 14
Joined: 02 Dec 2017, 11:14

Re: WinGetMinMax false detection windows 10

03 Dec 2017, 03:46

Just tried this.

The windows store has currently resurrected itself in a suspended state. I last left the window maximized before I closed it.

It does not appear in alt-tab or the taskbar or my dock.

Here is the process in task manager details tab:

Image

The status is "suspended" but I cant target this with com commands because the status feature was never completed/implemented in windows.

If I open the store and then minimize it, Autohotkey then says the status is minimized.

Any ideas?
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: WinGetMinMax false detection windows 10

09 Dec 2017, 03:19

The Windows API (IsWindowVisible) reports that these windows are visible, so AutoHotkey treats them as such.

The Windows API reports the min/max state of these windows, and AutoHotkey merely returns it. I believe the min/max state returned is correct; if the window is made visible without also restoring/minimizing/maximizing it, it will be in that state.

Filtering out these windows requires using additional APIs which must be loaded and called dynamically as they are absent from some of the OS versions AutoHotkey supports. This filtering could have unforeseen consequences to the behaviour or performance of the majority of scripts (i.e. all scripts which use a command or function with WinTitle parameter, with some exceptions).

The simplest way to filter out these windows is to check for the DWMA_CLOAKED attribute with DwmGetWindowAttribute:

Code: Select all

IsWindowCloaked(hwnd) {
    ; Resolve dwmapi\DwmGetWindowAttribute once only, for performance.
    static gwa := DllCall("GetProcAddress", "ptr", DllCall("LoadLibrary", "str", "dwmapi", "ptr"), "astr", "DwmGetWindowAttribute", "ptr")
    ; DWMWA_CLOAKED := 14
    return (gwa && DllCall(gwa, "ptr", hwnd, "int", 14, "int*", cloaked, "int", 4) = 0) ? cloaked : 0
    ; Return values:
    ;  0: not cloaked
    ;  1: cloaked by the application
    ;  2: cloaked by the shell
    ;  4: cloak value inherited from its owner
}
Windows of suspended apps and windows on other virtual desktops return 2.

If we want to differentiate between suspended apps and windows on other virtual desktops, we can use IVirtualDesktopManager::GetWindowDesktopId (see IVirtualDesktopManager dllCall). My testing showed that only a suspended app returned a GUID with all zeroes. Whether one can rely on this is unknown. I have not tested the performance of this API, but I suspect it would be worse than DwmGetWindowAttribute (which takes about twice as long to call than IsWindowVisible with DllCall).

IVirtualDesktopManager::IsWindowOnCurrentVirtualDesktop (see Windows 10 - How to distinguish between "visible" and "invisible" windows) appears to return true for windows of suspended apps regardless of which desktop you are on.
Ashtefere
Posts: 14
Joined: 02 Dec 2017, 11:14

Re: WinGetMinMax false detection windows 10

09 Dec 2017, 06:57

This always returns 0 in my testing. This part:

Code: Select all

DllCall(gwa, "ptr", hwnd, "int", 14, "int*", cloaked, "int", 4)
Always returns -2147024890

I am sending this to the full function you have written:

Code: Select all

IsWindowCloaked("ahk_id " thisId)
This returns 0 for all windows.

Running windows 10 fall creators update.

EDIT:

Removing the "ahk_id " part in front of the ID, it works now.

For some reason I need this part everywhere else in my code but not here.

Thanks!
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: WinGetMinMax false detection windows 10

09 Dec 2017, 10:14

Ashtefere wrote: EDIT:

Removing the "ahk_id " part in front of the ID, it works now.

For some reason I need this part everywhere else in my code but not here.
you need the "ahk_id " prefix string only when using a hwnd in a WinTitle parameter of a Command

lexikos' function uses the hwnd directly, as does all of the microsoft win32 apis

lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: WinGetMinMax false detection windows 10  Topic is solved

21 Jun 2020, 01:34

v1.1.32.00
Changed commands and functions with a WinTitle parameter to treat cloaked windows as hidden.
I believe that satisfies @Ashtefere's request.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 39 guests