#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$hGUI1 = GUICreate('GUI 1')
$hGUI2 = GUICreate('GUI 2')
GUIRegisterMsg($WM_WINDOWPOSCHANGING, 'WM_WINDOWPOSCHANGING')
GUISetState(@SW_SHOW, $hGUI1)
GUISetState(@SW_SHOW, $hGUI2)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func WM_WINDOWPOSCHANGING($hWnd, $iMsg, $wParam, $lParam)
Local $aPos1 = WinGetPos($hGUI1)
Local $aPos2 = WinGetPos($hGUI2)
Local $iBorder = ($aPos2[2] - WinGetClientSize($hGUI1)[0]) * 1.5
Switch $hWnd
Case $hGUI1
WinMove($hGUI2, '', $aPos1[0] + $aPos1[2] + $iBorder, $aPos1[1])
If Not WinActive($hGUI2) Then
;WinActivate($hGUI2)
EndIf
Case $hGUI2
WinMove($hGUI1, '', $aPos2[0] - $aPos1[2] - $iBorder, $aPos2[1])
If Not WinActive($hGUI1) Then
;WinActivate($hGUI1)
EndIf
EndSwitch
EndFunc