Skip to content

Commit 9bbd0b6

Browse files
committed
ui-tests: document how CaptureTextFromWindowsTerminal() works
It is a tricky (and somewhat fragile) part of the testing framework, let's document what it does, how, and why it's done this way. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 73feec7 commit 9bbd0b6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ui-tests/ui-test-library.ahk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ RunWaitOne(command) {
6262
return exec.StdOut.ReadAll()
6363
}
6464

65+
; This function is quite the hack. It assumes that the Windows Terminal is the active window,
66+
; then drags the mouse diagonally across the window to select all text and then copies it.
67+
;
68+
; This is fragile! If any other window becomes active, or if the mouse is moved,
69+
; the function will not work as intended.
70+
;
71+
; An alternative would be to use `ControlSend`, e.g.
72+
; `ControlSend '+^a', 'Windows.UI.Input.InputSite.WindowClass1', 'ahk_id ' . hwnd
73+
; This _kinda_ works, the text is selected (all text, in fact), but the PowerShell itself
74+
; _also_ processes the keyboard events and therefore they leave ugly and unintended
75+
; `^Ac` characters in the prompt. So that alternative is not really usable.
6576
CaptureTextFromWindowsTerminal() {
6677
ControlGetPos &cx, &cy, &cw, &ch, 'Windows.UI.Composition.DesktopWindowContentBridge1', "A"
6778
titleBarHeight := 54

0 commit comments

Comments
 (0)