Grab one of the windowsAHK Guis by the titlebar and move it around. The others will move together with it.

Just push all handles of interest into a global array called Handles, and include the function.The example includes inside the autoexecute section, which will run three lines of "modifying".The function could read the current settings, modify as needed and restore afterwards.

EDIT: clarified the fact that function only works for AHK Gui'sEDIT2: keep reading, what follows is a collaboration to improve the function, or see the improved function here.Edit3: added a link to Lexikos' teaching session

Last edited by wolf_II on 12 Feb 2018, 09:31, edited 3 times in total.

i've used majkinetor's DockA script in the past for this use-case. not sure whether i like your solution better or not. I don't really like your global Handles var. DockA lets me pass individual hwnds in. anyway, its good work. two things:

1. i dont think you should be globally setting SetBatchLines, CoordMode, etc. i think you should save the old values, then change them in the func, and then change them back:

As guest3456 indicated, you do not need global variables or settings. The Handles can be passed as the first parameter and stored in a static variable, and the settings can be set inside the function. Since OnMessage callbacks always run in new threads, there is no need to restore settings before the function returns. Example,

I wrote first a similar function for a related project (class Spinner), where Spinner.Handles is accessible in the function since Spinner is a superglobal. (not sure if that's the right expression)In my use-case, I don't use the global, I put it in the general function as a hint how to use the function. Obviously a better approach to make it more general is how Helgef is showing, Thanks for that, btw.I had a look at DockA as well and I don't understand most of it, but it looks very professional. I'm sure DockA will sort things out correctly, where my simple spinner won't need to get anything done at all.

DockA comments wrote:windows will behave like single window - moving, sizing, focusing, hiding and other OS events will be handled by the module so that the "composite window" behaves like the single window.

The intended purpose of my function is to allow for several spinners to be shown and move them around fast when I move the top-level GUI.Thank you very much for the tips how to store and restore settings. I will keep this good advice in mind.

Nice, I used an application which has an option similar to this, but doesn't fully suit my needs. Using AHK with WinMove to mimic it just didn't look smooth enough, but this looks good and probably is the same method used by that other app.

I think with WinEventProc using EVENT_SYSTEM_MOVESIZESTART and EVENT_SYSTEM_MOVESIZEEND as a trigger, you can make it work for non-AHK windows too.

Thank you for your work. While it is true that the function moves AutoHotkey Guis together, if the window being dragged is a AutoHotkey Gui, it will also move any other window whose handle has been added to the Handles array. The script below demonstrates that with an additional Notepad window. I took the liberty of simplifying the function a bit by using an associative array and added the ability of pressing the Shift key to disable moving the other windows. Here is the script:

;-------------------------------------------------------------------------------MoveTogether(wParam, lParam ="", _ ="", hWnd =""){; using DeferWindowPos;-------------------------------------------------------------------------------; call MoveTogether(Handles) with an array of handles; to set up a bundle of AHK Gui's that move together;---------------------------------------------------------------------------; https://autohotkey.com/boards/viewtopic.php?p=199402#p199402; version 2018.02.08

Guiclose:;- when close Listbox-GUI close also attached DOSWinClose, ahk_pid %pid2%;- if close only DOS , ahk-script freeze but you can close itWinWaitClose,ahk_pid %pid2%exitapp;------------------------------------

;-------------------------------------------------------------------------------MoveTogether(wParam, lParam ="", _ ="", hWnd =""){; using DeferWindowPos;-------------------------------------------------------------------------------; call MoveTogether(Handles) with an array of handles; to set up a bundle of AHK Gui's that move together;---------------------------------------------------------------------------; https://autohotkey.com/boards/viewtopic.php?p=199402#p199402; version 2018.02.08

;-------------------------------------------------------------------------------MoveTogether(wParam, lParam ="", _ ="", hWnd =""){; using DeferWindowPos;-------------------------------------------------------------------------------; call MoveTogether(Handles) with an array of handles; to set up a bundle of AHK Gui's that move together;---------------------------------------------------------------------------; https://autohotkey.com/boards/viewtopic.php?p=199402#p199402; version 2018.02.08

;-------------------------------------------------------------------------------MoveTogether(wParam, lParam ="", _ ="", hWnd =""){; using DeferWindowPos;-------------------------------------------------------------------------------; call MoveTogether(Handles) with an array of handles; to set up a bundle of AHK Gui's that move together;---------------------------------------------------------------------------; https://autohotkey.com/boards/viewtopic.php?p=199402#p199402; version 2018.02.08