How does Windows work on the Back-End when Moving a Maximized Windows?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Cr8zy_Ivan
Posts: 131
Joined: 30 Mar 2019, 18:20

How does Windows work on the Back-End when Moving a Maximized Windows?

02 May 2023, 17:36

I wrote a Script to Automatically map out any Monitor Configuration and to Move any Active Window in various ways (link to the Script below). The Script works well, but I'd like to optimize it. One functionality I never figured out how to do was: Moving a Maximized Window to a Different Monitor. In the Script, I deliberately don't Restore the Window before Moving it because I found that the process was just too slow (the sequence would have been: Restore Window, Move Window, Maximize Window). One consequence of my Script operating this way is: When you Restore a Maximized Window that has been moved this way, it reappears on the Monitor you first moved it from. And this is the part I don't quite understand.

My half-baked Theory: When you Move a Maximized Window, "Windows" Moves the Window (the "Display" part) without changing the Monitor Addressing (if that is even a thing. The "Address" which would be something that says "Window A" belongs to "Monitor B"). When you Restore a Window, "Windows" then "remembers" on which Monitor it is addressed to, and Displays it on that Monitor. And if you move a Window that isn't Maximized (that is Restored), my hypothesis would have Windows (in this specific case) update the Windows' Address when it is Moved. This may be an absolute and complete misunderstanding of what is actually going on. I have to admit: What goes on in the Back-End of Windows, Windows Handles, and everything in between is still a mystery to me.

Officially I'm asking for help. When I Restore a Window, I want it to remain on the Monitor it is right now. Eg.: If my Window is on Monitor 4 while it's Maximized, when I Restore it, I want it to stay on Monitor 4. I don't want it to reappear on Monitor 1, where I Moved it from. I could potentially Fix this within my Mapping Script, but that would require building a History Backlog of every Window that gets opened. The Size and Position of every Window would have to be saved every time they are Moved, and before they get Maximized, so that when they are Restored they may be re-positioned on the "New" Monitor at the same place, with the same size. It just seems very tedious and clunky to me.

I will continue my thought process in the off chance my understanding might be tenable:
IF what's missing is in fact "Monitor Addressing", I would think it possible to change the Monitor Addressing, on the Back-End, only AFTER the Window has been Moved. This way I could keep the speed at which I move a Maximized Window, and I would achieve my goal of having a Restored Window stay on the appropriate Monitor.

Any help, insight, discussion or brainstorming are all welcome. Cheers.

Automatic Mapping Script:
[Mod edit: Topic seems v1-related. Thus, the topic was moved from AHK v2 help to v1 help. ]

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: arrondark, Bing [Bot], LAPIII and 99 guests