WinMaximize unreliable: dragging during maximizing

Report problems with documented functionality
BunsenH
Posts: 31
Joined: 11 Apr 2015, 10:45

WinMaximize unreliable: dragging during maximizing

26 Feb 2019, 03:20

Here's a simple example:

Code: Select all

Run, Notepad.exe
WinWait, Untitled - Notepad, , 120

Loop, 60
{
   WinMaximize, Untitled - Notepad
   Sleep, 1000   
}
It creates a Notepad window, then should maximize that window every second for one minute.

While it's running, drag the window by its title bar around the screen; this "restores" the window to its normal size. If you do it really quickly, the WinMaximize works. You can do this repeatedly. But if you drag it around for a few seconds, the WinMaximize stops working. Then if you manually maximize the window again, the WinMaximize starts working again for quick window drags.

The failure looks like it involves the script trying to do the maximize while the window is being dragged. That AHK then thinks the window is still maximized, and doesn't bother trying to re-maximize it. Or something like that.
Last edited by BunsenH on 26 Feb 2019, 12:53, edited 2 times in total.
BunsenH
Posts: 31
Joined: 11 Apr 2015, 10:45

Re: WinMaximize unreliable: dragging during maximizing

26 Feb 2019, 12:47

By the way, this is the same problem that I reported last week. Which was blown off as obviously being a bug in my code, and not worth trying to reproduce following the actual steps I'd taken to cause the bug to manifest.
BunsenH
Posts: 31
Joined: 11 Apr 2015, 10:45

Re: WinMaximize unreliable: dragging during maximizing

26 Feb 2019, 13:00

Oh, and if the WinMaximize is replaced by the appropriate PostMessage command, i.e.

Code: Select all

Run, Notepad.exe
WinWait, Untitled - Notepad, , 120

Loop, 60
{
   PostMessage, 0x112, 0xF030,,, WinTitle, WinText ; 0x112 = WM_SYSCOMMAND, 0xF030 = SC_MAXIMIZE
   Sleep, 1000   
}
the script behaves as it should.

Mod's note: Sorry, accidently edited your post - gregster
BunsenH: No problem; I've fixed it.
Last edited by BunsenH on 26 Feb 2019, 13:53, edited 1 time in total.
gregster
Posts: 8918
Joined: 30 Sep 2013, 06:48

Re: WinMaximize unreliable: dragging during maximizing

26 Feb 2019, 13:10

BunsenH wrote:Oh, and if the WinMaximize is replaced by the appropriate PostMessage command, [...]
the script behaves as it should.
Seems pretty consistent with the docs, if you interpret a dragged window as a particular type of window:
https://autohotkey.com/docs/commands/WinMaximize.htm#Remarks wrote:If a particular type of window does not respond correctly to WinMaximize, try using the following instead:

PostMessage, 0x112, 0xF030,,, WinTitle, WinText ; 0x112 = WM_SYSCOMMAND, 0xF030 = SC_MAXIMIZE

Ps: Please see also my personal message.
BunsenH
Posts: 31
Joined: 11 Apr 2015, 10:45

Re: WinMaximize unreliable: dragging during maximizing

26 Feb 2019, 13:59

Is that what the docs actually mean by that phrase? It seems counter-intuitive, as almost any window can be dragged.
gregster
Posts: 8918
Joined: 30 Sep 2013, 06:48

Re: WinMaximize unreliable: dragging during maximizing

26 Feb 2019, 14:08

Well, not necessarily... the creators of the docs might have not thought of this particular case - but in a wider sense it might apply: Try this alternative, if WinMaximize doesn't work. Perhaps the docs should be slightly modified.

I am not sure, if I would really expect WinMaximize to work while the specific window is dragged - but then again, I never encountered this case before.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: WinMaximize unreliable: dragging during maximizing

26 Feb 2019, 14:09

i see what u mean now
Spoiler
steps to reproduce:
  1. clickhold the titlebar of a window
  2. issue a WinMaximize command
    1. the window is now fullscreen
    2. titlebar is still being held down
  3. move the mouse, so as to automatically resize(make smaller) the window
  4. the window is now no longer fullscreen, but its state is still maximized
    1. subsequent WinMaximizes wont do anything
    2. WinRestore can unbug the state
for me this PostMessage hack doesnt do anything, while the window is being dragged. neither does it work, when the maximized state is "bugged"(read: stuck)

as to whether thats an AHK bug. imma go with "no". circumventing WinMaximize entirely and calling ShowWindow() directly, results in the same bug.
should WinMaximize be reworked to account for this edge case? idk.

as a workaround u can either:
    • check the window's state
    • retreive the window's pos & dimensions
    • retreive all monitor dimensions
    • figure out which monitor the window is supposed to fullscreen on
    • compare the window and respective monitor dimensions
    • if the window state is maximized and there's a coordinate mismatch(ie not at the right place and not the right size):
      • do WinRestore
    • do WinMaximize
  1. set a winEventHook. EVENT_OBJECT_LOCATIONCHANGE is probably what u should be looking at.
BunsenH
Posts: 31
Joined: 11 Apr 2015, 10:45

Re: WinMaximize unreliable: dragging during maximizing

26 Feb 2019, 14:18

Getting back to my original report, there's the odd behaviour that the WinMaximize worked just fine when the function it was in was being called from a loop in the main thread, but not when that same function was being called from a SetTimer call. Working on exactly the same windows both times.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: WinMaximize unreliable: dragging during maximizing

26 Feb 2019, 14:18

BunsenH wrote:
26 Feb 2019, 12:47
By the way, this is the same problem that I reported last week. Which was blown off as obviously being a bug in my code, and not worth trying to reproduce following the actual steps I'd taken to cause the bug to manifest.
This code doesn't use settimer, so evidently your other (the same) problem had nothing to do with settimer.
BunsenH
Posts: 31
Joined: 11 Apr 2015, 10:45

Re: WinMaximize unreliable: dragging during maximizing

26 Feb 2019, 15:57

gregster wrote:
26 Feb 2019, 14:08
I am not sure, if I would really expect WinMaximize to work while the specific window is dragged - but then again, I never encountered this case before.
I wouldn't expect WinMaximize to work while the window was being dragged; if the dragging was still going on, the window would immediately un-maximize again. But I would expect it to work after the dragging was done.
Helgef wrote:
26 Feb 2019, 14:18
This code doesn't use settimer, so evidently your other (the same) problem had nothing to do with settimer.
It seems evident to me that SetTimer was having some effect, even if it was indirect. Since that was the only difference in the program between working and not-working.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: WinMaximize unreliable: dragging during maximizing

26 Feb 2019, 16:23

i see what the problem is

ur infinite loop in the main thread gets interrupted by a new thread once u start dragging the gui. therefore, WinMaximize isnt attempted. therefore, theres no way for the max state to get bugged

Code: Select all

CoordMode ToolTip

Gui Show, w300 h300

Loop
	ToolTip % Format("[{}] Looping in main...", A_TickCount), A_ScreenWidth // 2, A_ScreenHeight // 2 ; doesnt update if dragging

Esc::
GuiEscape:
GuiClose:
	ExitApp
if u do it in a timer, however, it will try to maximize it regardless of what ure doing with the gui, since the timer starts its own thread

Code: Select all

CoordMode ToolTip

Gui Show, w300 h300

SetTimer TimerThread, 10

Esc::
GuiEscape:
GuiClose:
	ExitApp

TimerThread:
	ToolTip % Format("[{}] Looping in timer...", A_TickCount), A_ScreenWidth // 2, A_ScreenHeight // 2 ; updates all the time
Return
BunsenH
Posts: 31
Joined: 11 Apr 2015, 10:45

Re: WinMaximize unreliable: dragging during maximizing

26 Feb 2019, 17:23

I'm not following you. In my original report, I was seeing the problem in the SetTimer version but not in the Loop with a delay. With this newer small script, I see the problem with both SetTimer and Loop versions.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: WinMaximize unreliable: dragging during maximizing

26 Feb 2019, 18:15

guimove blocks loop in main thread
guimove cant block creation of new timer threads

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 34 guests