admin管理员组文章数量:1314557
I am trying to swap windows on my screen. The MsgBox
es work but WinMove
doesn't:
{
...
; 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%.
}
I also need to resize it because of difference between resolutions.
I am trying to swap windows on my screen. The MsgBox
es work but WinMove
doesn't:
{
...
; 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%.
}
I also need to resize it because of difference between resolutions.
Share Improve this question edited Feb 13 at 0:37 user4157124 3,00214 gold badges31 silver badges46 bronze badges asked Jan 30 at 12:00 Gökhan DumlupınarGökhan Dumlupınar 13 bronze badges2 Answers
Reset to default 1#7 will be useful:
;;∙============================================================∙
/*
本文标签:
autohotkeyI am trying to move my windows but WinMove doesn39t workStack Overflow
版权声明:本文标题:autohotkey - I am trying to move my windows but WinMove doesn't work - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1741967604a2407642.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论