I am trying to swap my windows from my screen, all the MsgBoxes works fine but WinMove still doesn't work any body can se what is wrong.
{
...
; Move from Monitor 1 to Monitor 2
if (WinX >= Monitor1X && WinX < Monitor1EndX) {
SwapToScreen(thisID, Monitor2X, WinX, WinY, Monitor1X)
MsgBox , 1 to 2, %Title%
}
; Move from Monitor 2 to Monitor 1
else if (WinX >= Monitor2X && WinX < Monitor2EndX) {
SwapToScreen(thisID, Monitor1X, WinX, WinY, Monitor2X)
MsgBox, 2 to 1, %Title%
}
; Handle fullscreen cases (X = -9)
else if (WinX < 0 || WinY < 0) {
WinGet, IsMaximized, MinMax, ahk_id %thisID%
if (IsMaximized) {
SwapToScreen(thisID, Monitor2X, Monitor1X, WinY, Monitor1X)
WinRestore, ahk_id %thisID%
}
if (IsMaximized) {
WinMaximize, ahk_id %thisID%
}
}
else {
MsgBox, Active window is not within defined screen boundaries.
}
}
}
SwapToScreen(ActiveWinID, TargetMonitorX, CurrentX, CurrentY,
SourceMonitorX) {
NewX := TargetMonitorX + (CurrentX - SourceMonitorX)
WinGetPos, OldX, OldY, OldWidth, OldHeight, ahk_id %ActiveWinID%
; Adjust size based on scaling factor
if (TargetMonitorX = 0) {
ScaleFactor := 1 ; Moving to Monitor 1
} else {
ScaleFactor := 1 ; Moving to Monitor 2
}
NewWidth := OldWidth * ScaleFactor
NewHeight := OldHeight * ScaleFactor
; Move the window and report success
MsgBox, Moving Window ID: %ActiveWinID% to X: %NewX%, Y: %CurrentY%, Width: %NewWidth%, Height: %NewHeight%
WinMove, ahk_id %ActiveWinID% , %NewX% , %CurrentY% , %NewWidth%, %NewHeight%
MsgBox, Window moved successfully to X: %OldX%,%NewX%, Y: %OldY%,%CurrentY%, Width: %OldWidth%,%NewWidth%, Height: %OldHeight%,%NewHeight%.
}
if I can move it also I need to resize it becuase of different between resulations first I thought that s problem becuse it gives float height however I it doesnt work
Ok ı find it ,
WinMove, WinTitle, WinText, X, Y [, Width, Height, ExcludeTitle, ExcludeText]
İf I don't want to specify the WinText however still it needs the extra comma anyway