WinMaximize fails with timer

Get help with using AutoHotkey and its commands and hotkeys
Posts: 31
Joined: 11 Apr 2015, 10:45

WinMaximize fails with timer

23 Feb 2019, 23:05

I've been referred here from the Bug Reports forum.

I'm looking at adding some enhancements to my "Go to bed!" nagger and have run across a case in which the WinMaximize command appears to fail when the function that includes it is called from a thread set up by SetTimer, but not when the same function is called from the main thread.

The intention for the script is to have each monitor covered by a full-screen window, displaying some text, that's very hard to dislodge. These windows persist for a short time and then go away. This can be run as a scheduled task in the evening as an inducement to stop surfing, creating an increasing level of interruption until one gives up and goes to bed (or at least finds something to do that doesn't involve the computer).

What's supposed to happen is that every 1000 ms, each of the script's windows is moved to the upper left of its monitor and maximized. (Maximization alone isn't sufficient, because the window could be dragged to a different monitor.) Please see the attached. It's configured to run for 30 seconds. When the function that updates the windows is called from the main thread, it does just what it's supposed to do.

But if line 81 is uncommented, enabling the SetTimer call, and line 88 is commented out to prevent the window updater from being called there, the WinMaximize is unreliable. One can drag a window by its title bar, which appears to shrink the window to fit the text, and move it around the screen. It gets repositioned to the upper left within a second of being released, as it should, but sometimes it doesn't get maximized. It looks rather as though the reduced window size is stored as the window's new maximum size. Or that AHK thinks that the window is already maximized when it isn't, so doesn't bother to repeat what it thinks is an unnecessary maximization.

Since the WinMove call immediately before the WinMaximize call is working properly, and the function that's doing those calls is the same in both cases, and everything else seems to be the same, I'm fairly sure that the problem is a glitch involving WinMaximize specifically in this situation.

I'm using this with Windows 8.1 . I'm currently using AHK v., but was seeing the same kind of behaviour with v. .

(6.52 KiB) Downloaded 27 times

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], malcev, mikeyww, NiptheZephyr, Xtra and 53 guests