Posts: 1,031
Threads: 246
Joined: Jul 2022
03-26-2024, 02:00 AM
(This post was last modified: 03-26-2024, 02:00 AM by Davider.)
After executing the following code, the measured window X coordinate is -7, the measured window width is 1373, and the height is 553.
The reason for this result seems to be that there is a certain margin between the left border, right border, and bottom border of the window.
Can optional parameters be added to solve this problem?
var wc = wnd.find(1, "* - Google Chrome", "Chrome_WidgetWin_1");
wc.Move(0, 0, 1386, 560);
Posts: 1,031
Threads: 246
Joined: Jul 2022
It seems that only certain specific windows(E.g: Chrome) have borders; most windows can be precisely moved using the Move command.
Posts: 12,073
Threads: 140
Joined: Dec 2002
I tested on Windows 11. Chrome and other windows are exactly where moved.
var w = wnd.find(1, "* - Google Chrome", "Chrome_WidgetWin_1");
w.Move(0, 0, 1386, 560);
print.it(w.Rect); //{L=0 T=0 W=1386 H=560}
500.ms();
print.it(w.Rect); //{L=0 T=0 W=1386 H=560}
Posts: 1,031
Threads: 246
Joined: Jul 2022
03-28-2024, 05:18 AM
(This post was last modified: 03-28-2024, 05:42 AM by Davider.)
My previous expression may not have been accurate.
What I meant was the actual position, width, and height of the window after it's been moved on the screen.
The left border of the window is positioned at a certain distance from the left edge of the screen after it's been moved.
My System Win10 Pro 1909
Demo:
https://i.ibb.co/WxhqVGd/abc.gif
Posts: 12,073
Threads: 140
Joined: Dec 2002
var w = wnd.find(1, "* - Google Chrome", "Chrome_WidgetWin_1");
w.MoveVisibleArea(0, 0, 1386, 560);
print.it(w.Rect);
if (w.GetRect(out var r, withoutExtendedFrame: true)) print.it(r);
static class MyExtWnd {
/// <summary>
/// Moves this window as if its rectangle does not include the transparent frame.
/// </summary>
/// <exception cref="AuWndException">Invalid window.</exception>
public static void MoveVisibleArea(this wnd t, RECT r) {
if (!t.GetRect(out var rTrue) || !t.GetRect(out var rVisible, withoutExtendedFrame: true)) throw new AuWndException(t);
if (rVisible != rTrue) {
r.left -= rVisible.left - rTrue.left;
r.right += rTrue.right - rVisible.right;
r.bottom += rTrue.bottom - rVisible.bottom;
}
t.MoveL(r);
}
/// <inheritdoc cref="MoveVisibleArea(wnd, RECT)"/>
public static void MoveVisibleArea(this wnd t, int left, int top, int width, int height)
=> MoveVisibleArea(t, new(left, top, width, height));
}
Posts: 1,031
Threads: 246
Joined: Jul 2022
03-28-2024, 06:21 AM
(This post was last modified: 03-28-2024, 06:26 AM by Davider.)
Got it, thank you.
It would be more convenient to use if the above functionality could be added as a parameter to the Move function's properties.
w.MoveVisibleArea(0, 0, 500, 300);
out:
{L=0 T=0 W=502 H=300}
Posts: 12,073
Threads: 140
Joined: Dec 2002
In next LA Move etc have parameter visibleRect. Thank you.
Quote:{L=0 T=0 W=502 H=300}
The window refuses to be smaller than 502.