dsh-native-uia 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/client/client.js +6 -8
- package/market/icon.svg +11 -0
- package/market/index.json +98 -0
- package/package.json +2 -1
- package/scripts/check-lease.mjs +4 -4
- package/scripts/install.mjs +2 -2
- package/scripts/lib/sources.mjs +1 -1
- package/scripts/regression-halt-latch.mjs +1 -1
- package/scripts/regression-worker.ps1 +1074 -1071
- package/scripts/verify-locator.mjs +4 -4
- package/scripts/verify.mjs +53 -6
- package/src/tools/defs/act.js +6 -7
- package/src/tools/defs/observe.js +5 -5
- package/src/tools/format.js +10 -10
- package/src/tools/ocr.js +2 -3
- package/src/tools/recipes.js +3 -4
- package/src/worker-client.js +9 -10
- package/worker/bin/build-ocr.ps1 +41 -41
- package/worker/indicator-server.ps1 +13 -6
- package/worker/lib/02-uia.ps1 +13 -16
- package/worker/lib/03-window.ps1 +7 -7
- package/worker/lib/04-match.ps1 +11 -12
- package/worker/lib/05-value.ps1 +9 -9
- package/worker/lib/06-snapshot.ps1 +2 -2
- package/worker/lib/07-action.ps1 +3 -3
- package/worker/lib/08-command.ps1 +24 -28
- package/worker/lib/09-pointer.ps1 +2 -2
- package/worker/ps-stdio.ps1 +173 -173
- package/worker/uia-worker.ps1 +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* Locator round trip, no desktop input: a `by` descriptor that find_text hands back must be
|
|
4
|
-
* resolvable by prepare_batch (the same path computer_run/computer_replay take).
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* resolvable by prepare_batch (the same path computer_run/computer_replay take). The failure mode
|
|
5
|
+
* is silent: nth/nearPoint drop the id/exact conditions, and descriptors built from truncated
|
|
6
|
+
* display names stop matching.
|
|
7
7
|
*/
|
|
8
8
|
import { CuaWorker } from '../src/worker-client.js';
|
|
9
9
|
|
|
@@ -49,4 +49,4 @@ try {
|
|
|
49
49
|
} finally {
|
|
50
50
|
await worker.shutdown({ killMs: 5000 });
|
|
51
51
|
}
|
|
52
|
-
process.exit(code);
|
|
52
|
+
process.exit(code);
|
package/scripts/verify.mjs
CHANGED
|
@@ -187,15 +187,15 @@ gate('guard denies every category the user asked to block (MUST FIRE)', () => {
|
|
|
187
187
|
{ action: 'launch', descriptor: {}, extra: 'wscript.exe' },
|
|
188
188
|
{ action: 'launch', descriptor: {}, extra: 'mshta.exe' },
|
|
189
189
|
{ action: 'launch', descriptor: {}, extra: 'taskmgr.exe' },
|
|
190
|
-
// The window-close affordance: invoking it ends the application exactly like Alt+F4, and
|
|
191
|
-
//
|
|
190
|
+
// The window-close affordance: invoking it ends the application exactly like Alt+F4, and the
|
|
191
|
+
// text pattern must catch it even though the label is not "退出程序"/"关闭程序".
|
|
192
192
|
{ action: 'invoke', descriptor: { name: '关闭', controlType: 'Button' } },
|
|
193
193
|
{ action: 'invoke', descriptor: { name: 'Close', controlType: 'Button' } },
|
|
194
194
|
{ action: 'invoke', descriptor: { name: '✕', controlType: 'Button' } },
|
|
195
195
|
{ action: 'invoke', descriptor: { name: '×', controlType: 'Button' } },
|
|
196
196
|
// Case variants: computer_run/replay accept free JSON, so a step can carry any case; the
|
|
197
197
|
// worker lower-cases before executing, so the guard must match the same way or "Invoke"
|
|
198
|
-
// sails past the text refusal while the step still runs
|
|
198
|
+
// sails past the text refusal while the step still runs.
|
|
199
199
|
{ action: 'Invoke', descriptor: { name: 'Shut down', controlType: 'Button' } },
|
|
200
200
|
{ action: 'INVOKE', descriptor: { name: 'Exit', controlType: 'MenuItem' } },
|
|
201
201
|
{ action: 'Toggle', descriptor: { name: 'Delete all history', controlType: 'Button' } },
|
|
@@ -605,7 +605,7 @@ gate('read-only mode refuses every ACTION command at the choke point and lets ev
|
|
|
605
605
|
const setOf = (name) => {
|
|
606
606
|
const body = client.match(new RegExp(`${name} = new Set\\(\\[([\\s\\S]*?)\\]\\)`))?.[1];
|
|
607
607
|
assert(body !== undefined, `${name} not found`);
|
|
608
|
-
// The literal carries
|
|
608
|
+
// The literal carries a comment naming commands the Set does not contain; its quoted words are
|
|
609
609
|
// NOT set members — parsing them would behaviourally test a command the Set rejects, and a
|
|
610
610
|
// non-member call just pends forever instead of refusing. Parse code lines only.
|
|
611
611
|
const code = body.split('\n').filter((l) => !/^\s*\/\//.test(l)).join('\n');
|
|
@@ -1176,6 +1176,23 @@ gate('a phase change recolours in place instead of rebuilding the capsule', () =
|
|
|
1176
1176
|
return 'phase changes recolour ring + mask + bloom in place; no rebuild, no replayed intro';
|
|
1177
1177
|
});
|
|
1178
1178
|
|
|
1179
|
+
gate('a show that resumes a stopped run repaints the ring', () => {
|
|
1180
|
+
// Stopped auto-hides with the red palette still baked into the ring element. Render-Layout reuses
|
|
1181
|
+
// the tree on the next show, so without an explicit repaint the capsule announces "running" over
|
|
1182
|
+
// a red edge light -- the "restart after a stop, the ring is red" report.
|
|
1183
|
+
const server = readFileSync(join(ROOT, 'worker', 'indicator-server.ps1'), 'utf8');
|
|
1184
|
+
assert(/ringPhase\s*=/.test(server), 'the baked ring phase is no longer tracked: a resumed show cannot tell the palette is stale');
|
|
1185
|
+
const show = server.slice(server.indexOf('function Show-Overlay'), server.indexOf('function Hide-Overlay'));
|
|
1186
|
+
assert(/if \(\$script:S\.phase -ne 'hidden' -and \$script:S\.ringPhase -ne \[string\]\$script:S\.phase\) \{ Update-PhaseLook \}/.test(show),
|
|
1187
|
+
'Show-Overlay no longer repaints a stale ring: resuming after a stop shows a red ring under a running capsule');
|
|
1188
|
+
assert(show.indexOf('Update-PhaseLook') < show.indexOf('win.Show()'),
|
|
1189
|
+
'the repaint happens after the window is shown: the stale colour flashes for a frame');
|
|
1190
|
+
const look = server.slice(server.indexOf('function Update-PhaseLook'), server.indexOf('function Render-Layout'));
|
|
1191
|
+
assert(/\$script:S\.ringPhase = \[string\]\$script:S\.phase/.test(look),
|
|
1192
|
+
'the in-place recolour no longer records which palette the ring now carries');
|
|
1193
|
+
return 'show repaints a stale ring before the window is shown';
|
|
1194
|
+
});
|
|
1195
|
+
|
|
1179
1196
|
gate('a look change is visible on an idle session, not only during a run', () => {
|
|
1180
1197
|
// Choosing a shape or a palette used to do nothing a person could SEE unless a run was already
|
|
1181
1198
|
// painting the capsule: `refresh()` returns early when no run is active, so the stored value
|
|
@@ -2195,8 +2212,12 @@ gate('notes persist across runs, and the clipboard read stays gated on the run o
|
|
|
2195
2212
|
assert(!/Set-Clipboard -Value ''/.test(ps), "Set-Clipboard -Value '' throws on Windows PowerShell 5.1; use [string[]]@()");
|
|
2196
2213
|
assert((ps.match(/\[string\[\]\]@\(\)/g) ?? []).length >= 2, 'clear and empty write no longer both use the empty-array form');
|
|
2197
2214
|
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'));
|
|
2198
|
-
|
|
2199
|
-
|
|
2215
|
+
// The release number lives in two places a person reads; pin them to each other instead of
|
|
2216
|
+
// hardcoding the current version here, which turns every bump into a gate failure.
|
|
2217
|
+
const readme = readFileSync(join(ROOT, 'README.md'), 'utf8');
|
|
2218
|
+
const claim = readme.match(/当前版本 \*\*([0-9]+\.[0-9]+\.[0-9]+)\*\*/)?.[1];
|
|
2219
|
+
assert(claim === pkg.version, `README advertises version ${claim} while package.json is ${pkg.version}`);
|
|
2220
|
+
return `notes capped/deduped/sanitised and read back by observations; clipboard read gated on ctrl+c; version ${pkg.version} matches README`;
|
|
2200
2221
|
});
|
|
2201
2222
|
|
|
2202
2223
|
gate('the worker body lives in lib, and the entry dot-sources the same list the gates read', () => {
|
|
@@ -2234,6 +2255,32 @@ gate('the split tool modules actually resolve and register as a graph', () => {
|
|
|
2234
2255
|
return `graph loads: ${out.trim().split('\n').pop()}`;
|
|
2235
2256
|
});
|
|
2236
2257
|
|
|
2258
|
+
gate('the packaged market index is format 1, points at this package, and ships its icon', () => {
|
|
2259
|
+
const manifest = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'));
|
|
2260
|
+
const index = JSON.parse(readFileSync(join(ROOT, 'market', 'index.json'), 'utf8'));
|
|
2261
|
+
assert(index.format === 1, `market index format is ${index.format}`);
|
|
2262
|
+
assert(index.title?.en && index.title?.zh, 'the index has no bilingual title');
|
|
2263
|
+
assert(Array.isArray(index.plugins) && index.plugins.length === 1, 'the index must list exactly this plugin');
|
|
2264
|
+
const entry = index.plugins[0];
|
|
2265
|
+
assert(entry.name === manifest.name, `the index lists ${entry.name}, the package is ${manifest.name}`);
|
|
2266
|
+
assert(entry.icon === 'icon.svg', 'the index icon must stay relative to the index');
|
|
2267
|
+
assert(existsSync(join(ROOT, 'market', 'icon.svg')), 'market/icon.svg is missing');
|
|
2268
|
+
const categories = new Set(Object.keys(index.metadata?.categories ?? {}));
|
|
2269
|
+
assert(categories.has(entry.metadata?.category), `category ${entry.metadata?.category} is not declared`);
|
|
2270
|
+
const labels = new Set(Object.keys(index.metadata?.labels ?? {}));
|
|
2271
|
+
for (const label of entry.metadata?.labels ?? []) assert(labels.has(label), `label ${label} is not declared`);
|
|
2272
|
+
const versions = entry.versions.map((v) => v.version);
|
|
2273
|
+
assert(new Set(versions).size === versions.length, 'the index lists a version twice');
|
|
2274
|
+
assert(versions.includes(manifest.version), `the index does not list the packaged version ${manifest.version}`);
|
|
2275
|
+
for (const v of entry.versions) {
|
|
2276
|
+
assert(/^\d+\.\d+\.\d+$/.test(v.version), `version ${v.version} is not plain SemVer`);
|
|
2277
|
+
assert(Number.isInteger(v.publishTimestamp) && v.publishTimestamp > 0, `version ${v.version} has no publishTimestamp`);
|
|
2278
|
+
assert(v.source?.type === 'npm', `version ${v.version} is not an npm source`);
|
|
2279
|
+
}
|
|
2280
|
+
assert(manifest.files.includes('market'), 'package.json files omits market, so npm never ships the index');
|
|
2281
|
+
return `${versions.length} versions, ${entry.name}@${manifest.version}`;
|
|
2282
|
+
});
|
|
2283
|
+
|
|
2237
2284
|
await Promise.all(inflight); // async gates must settle before the summary counts them
|
|
2238
2285
|
console.log(`\n${results.length} gates: ${results.filter((r) => r.verdict === 'PASS').length} PASS / ${results.filter((r) => r.verdict === 'SKIP').length} SKIP / ${failed} FAIL`);
|
|
2239
2286
|
process.exit(failed > 0 ? 1 : 0);
|
package/src/tools/defs/act.js
CHANGED
|
@@ -59,7 +59,7 @@ export function registerAct(d) {
|
|
|
59
59
|
// A missed verify must not read as a passed step: applied stays true (the action WAS
|
|
60
60
|
// delivered), but the step status, the opening word and the follow-up advice all have to
|
|
61
61
|
// say "delivered, not confirmed" — otherwise the model retries a click that may already
|
|
62
|
-
// have fired (the batch path hard-stops on verify_failed; the single path
|
|
62
|
+
// have fired (the batch path hard-stops on verify_failed; the single path must match it).
|
|
63
63
|
const verifyMissed = result.verify != null && result.verify.matched !== true;
|
|
64
64
|
store.step({
|
|
65
65
|
label,
|
|
@@ -74,10 +74,9 @@ export function registerAct(d) {
|
|
|
74
74
|
const state = (hasValue(result.before) || hasValue(result.after))
|
|
75
75
|
? ` before=${JSON.stringify(result.before ?? null)} after=${JSON.stringify(result.after ?? null)}`
|
|
76
76
|
: '';
|
|
77
|
-
// The verify verdict in the same Chinese shape the batch path renders
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
// from "值就不对".
|
|
77
|
+
// The verify verdict in the same Chinese shape the batch path renders, plus the observed
|
|
78
|
+
// reading the worker captured while waiting — that is what tells "还没生效" apart from
|
|
79
|
+
// "值就不对".
|
|
81
80
|
const verifyText = result.verify ? ` 校验=${result.verify.matched === true ? '命中' : '未命中'}(${result.verify.type ?? '?'})` : '';
|
|
82
81
|
const effect = result.verify ? (result.verify.matched === true ? ' 效果=校验命中' : ' 效果=校验未命中') : '';
|
|
83
82
|
const observed = verifyMissed && result.verify.observed !== undefined && result.verify.observed !== null
|
|
@@ -478,8 +477,8 @@ export function registerAct(d) {
|
|
|
478
477
|
const type = String(cond.type ?? '');
|
|
479
478
|
const isWindowType = ['window_appears', 'window_gone', 'window_title_contains'].includes(type);
|
|
480
479
|
// Catch the mistake before the worker burns its whole timeout: the four measurement types
|
|
481
|
-
// read a property of ONE element, so without ref/by there is nothing to measure.
|
|
482
|
-
//
|
|
480
|
+
// read a property of ONE element, so without ref/by there is nothing to measure. Letting it
|
|
481
|
+
// through would return "matched:false, error:element_gone" after the full budget, which
|
|
483
482
|
// reads as "the element disappeared" rather than "you never named one".
|
|
484
483
|
const needsTarget = ['name_contains', 'value_equals', 'value_changed', 'no_change', 'enabled_is'].includes(type);
|
|
485
484
|
const hasTarget = [cond.ref, cond.by].some((v) => v !== undefined && v !== null && (typeof v === 'string' ? v !== '' : true));
|
|
@@ -145,7 +145,7 @@ export function registerObserve(d) {
|
|
|
145
145
|
// Text is deliberately NOT actionable: it carries the Text pattern, and treating that as an
|
|
146
146
|
// action made every paragraph of the chat log compete with the menu item being searched for.
|
|
147
147
|
// The tiers themselves live in the module-level rankMatch() so find_text and computer_parse
|
|
148
|
-
// sort by ONE shared ranking
|
|
148
|
+
// sort by ONE shared ranking instead of two copies that can drift apart.
|
|
149
149
|
const CONTAINERS = PASS_THROUGH;
|
|
150
150
|
const isContainer = (m) => CONTAINERS.has(String(m.controlType));
|
|
151
151
|
const actionable = (m) => (m.patterns ?? []).some((p) => ACT_VERBS.has(p));
|
|
@@ -232,8 +232,8 @@ export function registerObserve(d) {
|
|
|
232
232
|
if (args.includeUia !== false) {
|
|
233
233
|
// Same vocabulary as find_text: only nodes carrying a verb the model can actually issue are
|
|
234
234
|
// operable, ranked by the shared rankMatch (commands first, navigation/container rows and
|
|
235
|
-
// offscreen last).
|
|
236
|
-
// enclosing Pane
|
|
235
|
+
// offscreen last). Taking ANY pattern-bearing node would let Text paragraphs and their
|
|
236
|
+
// enclosing Pane compete with buttons, and in auto mode acting on one falls through to a
|
|
237
237
|
// physical pixel click on the paragraph's center.
|
|
238
238
|
const inter = nodes
|
|
239
239
|
.filter((n) => (n.patterns ?? []).some((p) => ACT_VERBS.has(p)))
|
|
@@ -310,8 +310,8 @@ export function registerObserve(d) {
|
|
|
310
310
|
? `\n截图像素 = 屏幕像素(scale 1,原生 1:1):${result.coordinateMap}。可以直接点击图像中的坐标。`
|
|
311
311
|
: `\n截图像素→屏幕坐标(给 computer_click 用):${result.coordinateMap}。截图 ${result.imageWidth}x${result.imageHeight} 已缩放,需按地图换算。`)
|
|
312
312
|
: '';
|
|
313
|
-
// A blank capture
|
|
314
|
-
//
|
|
313
|
+
// A blank capture reported as a success with a tiny image reads as "the screen is small"
|
|
314
|
+
// instead of "this surface could not be painted". Say which it is.
|
|
315
315
|
const blank = result.blank === true
|
|
316
316
|
? '\n⚠ 截图是空白的:这个表面没法用当前方式绘制(窗口最小化/被遮挡,或会话已锁屏)。元素树仍是可信通道;整屏可用 scope="screen"。'
|
|
317
317
|
: '';
|
package/src/tools/format.js
CHANGED
|
@@ -35,10 +35,10 @@ export const ACT_VERBS = new Set(['Invoke', 'Value', 'Toggle', 'SelectionItem',
|
|
|
35
35
|
export function renderActionables(nodes, max = 24) {
|
|
36
36
|
const acts = nodes.filter((n) => (n.patterns ?? []).some((p) => ACT_VERBS.has(p)));
|
|
37
37
|
if (acts.length === 0) return '';
|
|
38
|
-
// Each entry is a complete "ref + controlType + name" metadata row: two same-named buttons
|
|
39
|
-
//
|
|
40
|
-
// center coordinate doubles as the by.nearPoint input, so same-name disambiguation no
|
|
41
|
-
//
|
|
38
|
+
// Each entry is a complete "ref + controlType + name" metadata row: two same-named buttons would
|
|
39
|
+
// otherwise render byte-identical, and a model reading only this line could not tell them apart.
|
|
40
|
+
// The center coordinate doubles as the by.nearPoint input, so same-name disambiguation needs no
|
|
41
|
+
// second find_text pass over the whole tree.
|
|
42
42
|
const shown = acts.slice(0, max).map((n) => {
|
|
43
43
|
const c = n.rect && n.rect.w > 0 ? ` @(${Math.round(n.rect.x + n.rect.w / 2)},${Math.round(n.rect.y + n.rect.h / 2)})` : '';
|
|
44
44
|
return `${n.ref} ${n.controlType}${n.name && n.name.trim() ? ` "${str(n.name, 24)}"` : ''}${c}`;
|
|
@@ -161,9 +161,9 @@ export function renderResults(results, performed) {
|
|
|
161
161
|
const tail = unverified > 0
|
|
162
162
|
? `\nperformedCount=${performed}(其中 ${unverified} 步没有校验条件:结果只代表已送达,不代表界面已按预期改变)`
|
|
163
163
|
: `\nperformedCount=${performed}`;
|
|
164
|
-
// Four-state tally so the model does not re-count the lines itself:
|
|
165
|
-
//
|
|
166
|
-
//
|
|
164
|
+
// Four-state tally so the model does not re-count the lines itself: performedCount alone leaves
|
|
165
|
+
// 成功/失败/校验未命中/未执行 to be inferred per row. '校验未命中' keeps the contract wording:
|
|
166
|
+
// the action WAS delivered — do not blindly retry it.
|
|
167
167
|
const passedCount = results.filter((r) => r.status === 'passed').length;
|
|
168
168
|
const verifyMissedCount = results.filter((r) => r.status === 'verify_failed').length;
|
|
169
169
|
const notExecutedCount = results.filter((r) => r.status === 'not_executed').length;
|
|
@@ -298,7 +298,7 @@ export function snapshotNotes(snap) {
|
|
|
298
298
|
* removed, so nothing the model can act on disappears.
|
|
299
299
|
*/
|
|
300
300
|
// Exported so the find_text ladder and any consumer share ONE definition of "a container whose
|
|
301
|
-
// click only focuses the window"
|
|
301
|
+
// click only focuses the window", instead of copies that drift into a different order.
|
|
302
302
|
export const PASS_THROUGH = new Set(['Pane', 'Group', 'Document', 'Custom', 'Window']);
|
|
303
303
|
|
|
304
304
|
// Navigation rows and real commands, shared by find_text ranking and computer_parse's operable
|
|
@@ -310,8 +310,8 @@ export const COMMANDS = new Set(['Button', 'MenuItem', 'Tab', 'TabItem', 'CheckB
|
|
|
310
310
|
|
|
311
311
|
/**
|
|
312
312
|
* One ranking for both channels that list clickable things (5 = least clickable):
|
|
313
|
-
* find_text sorts its hits by it and computer_parse sorts its operable list by it.
|
|
314
|
-
*
|
|
313
|
+
* find_text sorts its hits by it and computer_parse sorts its operable list by it. One function,
|
|
314
|
+
* so the two channels cannot rank the same node differently.
|
|
315
315
|
*/
|
|
316
316
|
export function rankMatch(m) {
|
|
317
317
|
if (m.isOffscreen === true) return 5; // unreachable without scrolling
|
package/src/tools/ocr.js
CHANGED
|
@@ -64,9 +64,8 @@ export function groupOcrWords(words, { maxGapFactor = 2.0, lineOverlap = 0.6 } =
|
|
|
64
64
|
* Exported as a pure function so the same rule is used by the tool, the unit tests and the live
|
|
65
65
|
* A/B measurement — a rule that only exists inside a tool handler cannot be tested or compared.
|
|
66
66
|
*/
|
|
67
|
-
// Exported so the measurement script compares against the SAME cover set the tool uses
|
|
68
|
-
//
|
|
69
|
-
// this list verbatim).
|
|
67
|
+
// Exported so the measurement script compares against the SAME cover set the tool uses; a copy in
|
|
68
|
+
// scripts/ would drift from this list.
|
|
70
69
|
export const OCR_COVER = new Set(['Button', 'Edit', 'Text', 'Hyperlink', 'ListItem', 'MenuItem', 'CheckBox', 'RadioButton', 'TabItem', 'ComboBox', 'Slider', 'Spinner', 'TreeItem', 'DataItem', 'HeaderItem', 'Link']);
|
|
71
70
|
|
|
72
71
|
export function ocrCoverers(nodes) {
|
package/src/tools/recipes.js
CHANGED
|
@@ -11,10 +11,9 @@ export async function saveRecipe(dir, recipe) {
|
|
|
11
11
|
const slug = String(recipe.goal).toLowerCase().replace(/[^a-z0-9\u4e00-\u9fa5]+/g, '-').replace(/^-|-$/g, '').slice(0, 40) || 'recipe';
|
|
12
12
|
const name = `${slug}-${Date.now()}`;
|
|
13
13
|
await writeFile(join(dir, `${name}.json`), JSON.stringify({ ...recipe, createdAt: new Date().toISOString() }, null, 2), 'utf8');
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// a failed prune must never fail the batch the user asked for.
|
|
14
|
+
// Every passing batch adds one recipe and each carries the full step list, so the directory only
|
|
15
|
+
// grows. Prune to the newest `keep` files so a long-lived install cannot fill the disk.
|
|
16
|
+
// Best-effort: a failed prune must never fail the batch the user asked for.
|
|
18
17
|
//
|
|
19
18
|
// Ordered by the timestamp in the name, NOT lexicographically: names are `<slug>-<epoch>`, so a
|
|
20
19
|
// plain string sort groups by slug and would delete the newest recipe of one app while keeping
|
package/src/worker-client.js
CHANGED
|
@@ -44,21 +44,20 @@ const ACTION_COMMANDS = new Set([
|
|
|
44
44
|
// Writing or clearing the clipboard is input on shared state: read-only mode must refuse it, and
|
|
45
45
|
// it deserves the same claim/kill discipline as typing. Reading is deliberately NOT here.
|
|
46
46
|
'clipboard_write', 'clipboard_clear',
|
|
47
|
-
// 'foreground'
|
|
48
|
-
// entry in the input whitelist is a policy blind spot
|
|
49
|
-
// foreground/pointer_state/pointer_move/text_caret together).
|
|
47
|
+
// No 'foreground', 'pointer_state', 'pointer_move' or 'text_caret' here: the worker has no such
|
|
48
|
+
// commands, and an unsendable entry in the input whitelist is a policy blind spot.
|
|
50
49
|
]);
|
|
51
50
|
|
|
52
51
|
/**
|
|
53
52
|
* Commands that mean "the model is looking at the desktop" for a live run, so they renew the
|
|
54
|
-
* overlay's lease. The lease renews ONLY here and in claim()
|
|
55
|
-
*
|
|
53
|
+
* overlay's lease. The lease renews ONLY here and in claim(): the plugin's own heartbeat feeds the
|
|
54
|
+
* renderer and is not model activity, so it must not extend the lease.
|
|
56
55
|
*
|
|
57
|
-
* This is a whitelist on purpose.
|
|
58
|
-
*
|
|
59
|
-
* beat
|
|
60
|
-
*
|
|
61
|
-
*
|
|
56
|
+
* This is a whitelist on purpose. "Not an action" is not the same as "an observation": the Esc
|
|
57
|
+
* watchdog polls `escape_pressed` every 40 ms, so an else-branch would fire a beat ~25×/s. Each
|
|
58
|
+
* beat re-syncs the HWND, re-positions the pill and re-renders its text while the pulse timer
|
|
59
|
+
* pushes new opacity values on every tick (~30 Hz), and the two interleave into a visible flicker
|
|
60
|
+
* on the ring. Internal probes are not observations and must stay silent here.
|
|
62
61
|
*/
|
|
63
62
|
const OBSERVE_COMMANDS = new Set([
|
|
64
63
|
'list_windows', 'snapshot', 'describe', 'capture', 'ocr', 'wait', 'prepare_batch',
|
package/worker/bin/build-ocr.ps1
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
# Rebuild ocr.exe from ocr.cs — the WinRT OCR shim the PowerShell worker shells out to.
|
|
2
|
-
#
|
|
3
|
-
# Why a compiled shim at all: Windows PowerShell 5.1's dynamic WinRT binding cannot construct a
|
|
4
|
-
# SoftwareBitmap from captured bytes (every CreateCopyFromPixels / IBuffer route throws
|
|
5
|
-
# MethodNotFound), so OCR-in-PS is a dead end. Compiled C# resolves those WinRT types at COMPILE
|
|
6
|
-
# time and works. The .exe needs NEITHER csc NOR the SDK at RUNTIME — it runs on any Win10/11 with
|
|
7
|
-
# .NET Framework 4.x + the OS OCR language pack. Footprint: ~7 KB, zero bundled model
|
|
8
|
-
# (Windows.Media.Ocr is an OS component).
|
|
9
|
-
#
|
|
10
|
-
# Needs: the Framework C# compiler (ships with .NET Framework) and the Windows SDK's unified
|
|
11
|
-
# Windows.winmd for the WinRT metadata. Run after installing the SDK via: powershell -File build-ocr.ps1
|
|
12
|
-
$ErrorActionPreference = 'Stop'
|
|
13
|
-
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
14
|
-
$FW = Join-Path $env:WINDIR 'Microsoft.NET\Framework64\v4.0.30319'
|
|
15
|
-
$csc = Join-Path $FW 'csc.exe'
|
|
16
|
-
if (-not (Test-Path $csc)) { throw "csc.exe not found at $csc" }
|
|
17
|
-
|
|
18
|
-
$sdkRoot = 'C:\Program Files (x86)\Windows Kits\10\UnionMetadata'
|
|
19
|
-
# Take the FULL versioned metadata (UnionMetadata\<ver>\Windows.winmd), NOT the type-forwarding
|
|
20
|
-
# Facade\Windows.WinMD — the facade has no real Windows.Media.Ocr types and fails to compile.
|
|
21
|
-
$winmd = Get-ChildItem -Path $sdkRoot -Recurse -Filter 'Windows.winmd' -ErrorAction SilentlyContinue |
|
|
22
|
-
Where-Object { $_.FullName -notmatch '\\Facade\\' } |
|
|
23
|
-
Sort-Object FullName -Descending | Select-Object -First 1
|
|
24
|
-
if ($null -eq $winmd) { throw "Windows.winmd not found under $sdkRoot — install the Windows 10/11 SDK" }
|
|
25
|
-
|
|
26
|
-
$refs = @(
|
|
27
|
-
"-reference:$($winmd.FullName)",
|
|
28
|
-
"-reference:$FW\System.Runtime.WindowsRuntime.dll",
|
|
29
|
-
"-reference:$FW\System.Runtime.dll",
|
|
30
|
-
"-reference:$FW\System.ObjectModel.dll",
|
|
31
|
-
"-reference:$FW\System.Collections.dll",
|
|
32
|
-
"-reference:$FW\System.Globalization.dll",
|
|
33
|
-
"-reference:$FW\System.Threading.Tasks.dll",
|
|
34
|
-
"-reference:$FW\System.Runtime.InteropServices.dll",
|
|
35
|
-
"-reference:$FW\System.Diagnostics.Debug.dll",
|
|
36
|
-
"-reference:$FW\System.Runtime.InteropServices.WindowsRuntime.dll"
|
|
37
|
-
)
|
|
38
|
-
$out = Join-Path $here 'ocr.exe'
|
|
39
|
-
& $csc -nologo -target:exe "-out:$out" $refs (Join-Path $here 'ocr.cs')
|
|
40
|
-
if ($LASTEXITCODE -ne 0) { throw "csc failed (exit $LASTEXITCODE)" }
|
|
41
|
-
Write-Output ("built " + $out + " (" + (Get-Item $out).Length + " bytes) against " + $winmd.FullName)
|
|
1
|
+
# Rebuild ocr.exe from ocr.cs — the WinRT OCR shim the PowerShell worker shells out to.
|
|
2
|
+
#
|
|
3
|
+
# Why a compiled shim at all: Windows PowerShell 5.1's dynamic WinRT binding cannot construct a
|
|
4
|
+
# SoftwareBitmap from captured bytes (every CreateCopyFromPixels / IBuffer route throws
|
|
5
|
+
# MethodNotFound), so OCR-in-PS is a dead end. Compiled C# resolves those WinRT types at COMPILE
|
|
6
|
+
# time and works. The .exe needs NEITHER csc NOR the SDK at RUNTIME — it runs on any Win10/11 with
|
|
7
|
+
# .NET Framework 4.x + the OS OCR language pack. Footprint: ~7 KB, zero bundled model
|
|
8
|
+
# (Windows.Media.Ocr is an OS component).
|
|
9
|
+
#
|
|
10
|
+
# Needs: the Framework C# compiler (ships with .NET Framework) and the Windows SDK's unified
|
|
11
|
+
# Windows.winmd for the WinRT metadata. Run after installing the SDK via: powershell -File build-ocr.ps1
|
|
12
|
+
$ErrorActionPreference = 'Stop'
|
|
13
|
+
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
14
|
+
$FW = Join-Path $env:WINDIR 'Microsoft.NET\Framework64\v4.0.30319'
|
|
15
|
+
$csc = Join-Path $FW 'csc.exe'
|
|
16
|
+
if (-not (Test-Path $csc)) { throw "csc.exe not found at $csc" }
|
|
17
|
+
|
|
18
|
+
$sdkRoot = 'C:\Program Files (x86)\Windows Kits\10\UnionMetadata'
|
|
19
|
+
# Take the FULL versioned metadata (UnionMetadata\<ver>\Windows.winmd), NOT the type-forwarding
|
|
20
|
+
# Facade\Windows.WinMD — the facade has no real Windows.Media.Ocr types and fails to compile.
|
|
21
|
+
$winmd = Get-ChildItem -Path $sdkRoot -Recurse -Filter 'Windows.winmd' -ErrorAction SilentlyContinue |
|
|
22
|
+
Where-Object { $_.FullName -notmatch '\\Facade\\' } |
|
|
23
|
+
Sort-Object FullName -Descending | Select-Object -First 1
|
|
24
|
+
if ($null -eq $winmd) { throw "Windows.winmd not found under $sdkRoot — install the Windows 10/11 SDK" }
|
|
25
|
+
|
|
26
|
+
$refs = @(
|
|
27
|
+
"-reference:$($winmd.FullName)",
|
|
28
|
+
"-reference:$FW\System.Runtime.WindowsRuntime.dll",
|
|
29
|
+
"-reference:$FW\System.Runtime.dll",
|
|
30
|
+
"-reference:$FW\System.ObjectModel.dll",
|
|
31
|
+
"-reference:$FW\System.Collections.dll",
|
|
32
|
+
"-reference:$FW\System.Globalization.dll",
|
|
33
|
+
"-reference:$FW\System.Threading.Tasks.dll",
|
|
34
|
+
"-reference:$FW\System.Runtime.InteropServices.dll",
|
|
35
|
+
"-reference:$FW\System.Diagnostics.Debug.dll",
|
|
36
|
+
"-reference:$FW\System.Runtime.InteropServices.WindowsRuntime.dll"
|
|
37
|
+
)
|
|
38
|
+
$out = Join-Path $here 'ocr.exe'
|
|
39
|
+
& $csc -nologo -target:exe "-out:$out" $refs (Join-Path $here 'ocr.cs')
|
|
40
|
+
if ($LASTEXITCODE -ne 0) { throw "csc failed (exit $LASTEXITCODE)" }
|
|
41
|
+
Write-Output ("built " + $out + " (" + (Get-Item $out).Length + " bytes) against " + $winmd.FullName)
|
|
@@ -441,8 +441,8 @@ $script:TEXT = [ordered]@{
|
|
|
441
441
|
# change must recolour and reword the state without dropping the name itself. The brand is the
|
|
442
442
|
# host (DSH), because the person at the keyboard is sharing their desktop with the harness, not
|
|
443
443
|
# with a plugin — 御屏 is what this thing is called in the plugin list, not what is on their screen.
|
|
444
|
-
#
|
|
445
|
-
#
|
|
444
|
+
# Two visible phases, and no third: the capsule only ever says "acting" or (briefly, on the way
|
|
445
|
+
# out) "stopped".
|
|
446
446
|
$script:PILL = @{
|
|
447
447
|
acting = ($script:TEXT.brand + ' ' + $script:TEXT.dot + ' ' + $script:TEXT.acting)
|
|
448
448
|
stopped = ($script:TEXT.brand + ' ' + $script:TEXT.dot + ' ' + $script:TEXT.stopped)
|
|
@@ -594,6 +594,7 @@ $script:S = [ordered]@{
|
|
|
594
594
|
chosenFont = ''
|
|
595
595
|
dipW = 0.0
|
|
596
596
|
ringDip = 0.0
|
|
597
|
+
ringPhase = ''
|
|
597
598
|
pillX = 0
|
|
598
599
|
pillY = 0
|
|
599
600
|
pillW = 0
|
|
@@ -911,6 +912,7 @@ function Build-Ring([double]$W, [double]$H, [double]$T, $ph) {
|
|
|
911
912
|
Log 'ring texture unavailable: edge light skipped'
|
|
912
913
|
} else {
|
|
913
914
|
$script:S.ringImg = $layer
|
|
915
|
+
$script:S.ringPhase = [string]$script:S.phase
|
|
914
916
|
[void]$bloom.Add($layer)
|
|
915
917
|
}
|
|
916
918
|
return @{ bars = $bars; bloom = $bloom }
|
|
@@ -1841,7 +1843,7 @@ function Clear-Canvas {
|
|
|
1841
1843
|
# twenty actions must show layoutBuilds = 1, not 20.
|
|
1842
1844
|
$script:S.layoutBuilds += 1
|
|
1843
1845
|
if ($null -ne $script:S.canvas) { $script:S.canvas.Children.Clear() }
|
|
1844
|
-
$script:S.ring = @(); $script:S.bloom = @(); $script:S.ringImg = $null
|
|
1846
|
+
$script:S.ring = @(); $script:S.bloom = @(); $script:S.ringImg = $null; $script:S.ringPhase = ''
|
|
1845
1847
|
$script:S.pill = $null; $script:S.pillText = $null; $script:S.pillSub = $null
|
|
1846
1848
|
$script:S.pillOrb = $null; $script:S.pillOrbScale = $null; $script:S.pillOrbHalo = $null; $script:S.pillOrbHaloScale = $null; $script:S.pillBars = @()
|
|
1847
1849
|
$script:S.pillScale = $null; $script:S.pillBrandRun = $null; $script:S.pillRestRun = $null
|
|
@@ -1877,6 +1879,7 @@ function Update-PhaseLook {
|
|
|
1877
1879
|
$fresh = New-RingTexture $W $H $T $ph
|
|
1878
1880
|
if ($null -ne $fresh) { $script:S.ringImg.Source = $fresh }
|
|
1879
1881
|
}
|
|
1882
|
+
$script:S.ringPhase = [string]$script:S.phase
|
|
1880
1883
|
# The pill's bloom is the phase accent, so it has to follow too -- otherwise a red stopped phase
|
|
1881
1884
|
# sits in a silver halo.
|
|
1882
1885
|
if ($null -ne $script:S.pill) {
|
|
@@ -2186,6 +2189,10 @@ function Show-Overlay($m) {
|
|
|
2186
2189
|
$ds = (Get-DeviceScale)
|
|
2187
2190
|
if ($ds -gt 0) { $script:S.scale = $ds } else { $script:S.scale = ([double]$m.dpi / 96.0) }
|
|
2188
2191
|
Render-Layout | Out-Null
|
|
2192
|
+
# The tree is reused across a stop, and Hide-Overlay leaves the last baked palette on the ring:
|
|
2193
|
+
# a `show` that resumes with phase=acting would otherwise light a red ring under a running capsule
|
|
2194
|
+
# until the next phase command. Repaint before the window is shown, so no frame flashes the old colour.
|
|
2195
|
+
if ($script:S.phase -ne 'hidden' -and $script:S.ringPhase -ne [string]$script:S.phase) { Update-PhaseLook }
|
|
2189
2196
|
Move-To-Monitor $m
|
|
2190
2197
|
if (-not $script:S.visible) {
|
|
2191
2198
|
$win.Show() # ShowActivated=false, so this never takes the foreground
|
|
@@ -2235,9 +2242,9 @@ function Start-RenderLoop {
|
|
|
2235
2242
|
$script:pulseTimer = $t
|
|
2236
2243
|
$script:S.timers += $t
|
|
2237
2244
|
}
|
|
2238
|
-
# Subscribing to WPF's render event is only an OBSERVER, and an expensive one:
|
|
2239
|
-
#
|
|
2240
|
-
#
|
|
2245
|
+
# Subscribing to WPF's render event is only an OBSERVER, and an expensive one: it forces
|
|
2246
|
+
# full-surface compositing (measured ~55 Hz on a 2560x1600 layered surface) even when few
|
|
2247
|
+
# updates are pushed. Off by default, on for diagnostics.
|
|
2241
2248
|
if ($script:renderLoaded -and [int]$CFG.renderHook -eq 1) {
|
|
2242
2249
|
try {
|
|
2243
2250
|
[IndWpf]::StartRendering([System.Action]{ On-Frame })
|
package/worker/lib/02-uia.ps1
CHANGED
|
@@ -24,8 +24,8 @@ function ControlTypeName($ct) {
|
|
|
24
24
|
$script:patCache = @{}
|
|
25
25
|
# GetSupportedPatterns() returns AutomationPattern objects (NOT AutomationPatternInfo): the
|
|
26
26
|
# usable name is $q.ProgrammaticName, shaped "ValuePatternIdentifiers.Pattern"; $q.Id is a bare
|
|
27
|
-
# int (10002) and has no ProgrammaticName, so reading $q.Id.ProgrammaticName yields ''
|
|
28
|
-
# node
|
|
27
|
+
# int (10002) and has no ProgrammaticName, so reading $q.Id.ProgrammaticName yields '' for every
|
|
28
|
+
# node — read only ProgrammaticName.
|
|
29
29
|
#
|
|
30
30
|
# The COM call itself cannot be avoided (78% of nodes in a real tree are interactive, so filtering
|
|
31
31
|
# by type saves nothing), but the string work after it can: the same control type yields the same
|
|
@@ -47,9 +47,9 @@ function PatternsOf($el) {
|
|
|
47
47
|
if ($null -ne $sp) {
|
|
48
48
|
# Build the signature cheaply, then look the friendly list up once per distinct signature.
|
|
49
49
|
# Every value that reaches a Hashtable key or a List[string] is normalised to a non-empty
|
|
50
|
-
# string first: a provider
|
|
51
|
-
#
|
|
52
|
-
#
|
|
50
|
+
# string first: a provider can report a pattern with no ProgrammaticName and no Id, and a
|
|
51
|
+
# $null key throws "Key cannot be null" — which would fail the whole snapshot as
|
|
52
|
+
# internal_error.
|
|
53
53
|
$sigParts = New-Object System.Collections.Generic.List[string]
|
|
54
54
|
foreach ($q in $sp) {
|
|
55
55
|
$pk = ''
|
|
@@ -101,7 +101,7 @@ function PatternsOf($el) {
|
|
|
101
101
|
# managed wrapper type for that pattern, so it can neither be requested nor reported here, and
|
|
102
102
|
# LegacyIAccessible is deliberately absent from a cached pattern list: the capability table
|
|
103
103
|
# computer_act checks never names it and the rendered tree filters patterns
|
|
104
|
-
# through ACTIONABLE, which
|
|
104
|
+
# through ACTIONABLE, which does not list it).
|
|
105
105
|
$script:cachedPatProps = @(
|
|
106
106
|
'IsDockPatternAvailableProperty', 'IsExpandCollapsePatternAvailableProperty', 'IsGridItemPatternAvailableProperty',
|
|
107
107
|
'IsGridPatternAvailableProperty', 'IsInvokePatternAvailableProperty', 'IsItemContainerPatternAvailableProperty',
|
|
@@ -140,8 +140,7 @@ $patternTypes = @{
|
|
|
140
140
|
Transform = [System.Windows.Automation.TransformPattern]
|
|
141
141
|
Text = [System.Windows.Automation.TextPattern]
|
|
142
142
|
GridItem = [System.Windows.Automation.GridItemPattern]
|
|
143
|
-
# ScrollItem
|
|
144
|
-
# (nothing asked for it) and adding it would have been a dead table entry.
|
|
143
|
+
# ScrollItem backs the scroll_to verb; without that verb the entry would be dead.
|
|
145
144
|
ScrollItem = [System.Windows.Automation.ScrollItemPattern]
|
|
146
145
|
}
|
|
147
146
|
|
|
@@ -154,9 +153,9 @@ function GetPattern($el, $name) {
|
|
|
154
153
|
} catch { return $null }
|
|
155
154
|
}
|
|
156
155
|
|
|
157
|
-
# Same lookup as GetPattern, but the pattern OBJECT is kept on the ref record
|
|
158
|
-
# before → action → after
|
|
159
|
-
# cross-process round-trips for one set_value
|
|
156
|
+
# Same lookup as GetPattern, but the pattern OBJECT is kept on the ref record, so the act sequence
|
|
157
|
+
# before → action → after reuses ONE pattern object instead of three GetCurrentPattern
|
|
158
|
+
# cross-process round-trips for one set_value. Invalidated by Resolve-Ref on rebind, because the
|
|
160
159
|
# cached object is bound to the element it was fetched from.
|
|
161
160
|
function Get-RefPattern($re, $name) {
|
|
162
161
|
if ($null -eq $re) { return $null }
|
|
@@ -182,11 +181,9 @@ function RectOf($cp) {
|
|
|
182
181
|
|
|
183
182
|
function RuntimeIdKey($el) {
|
|
184
183
|
# Cached elements (snapshot subtree / find_text scan) read the runtime id from the cache —
|
|
185
|
-
# probe-verified bit-identical to GetRuntimeId() on real trees
|
|
186
|
-
#
|
|
187
|
-
#
|
|
188
|
-
# (or a provider that never cached it) keeps the live call below; both shapes land in the same
|
|
189
|
-
# comma-joined string, so the rebind identity check does not change meaning.
|
|
184
|
+
# probe-verified bit-identical to GetRuntimeId() on real trees, live request or GetUpdatedCache.
|
|
185
|
+
# A live element (or a provider that never cached it) keeps the live call below; both shapes land
|
|
186
|
+
# in the same comma-joined string, so the rebind identity check does not change meaning.
|
|
190
187
|
try {
|
|
191
188
|
$rid = $el.GetCachedPropertyValue([System.Windows.Automation.AutomationElement]::RuntimeIdProperty)
|
|
192
189
|
if ($null -ne $rid) { return (($rid | ForEach-Object { [string]$_ }) -join ',') }
|
package/worker/lib/03-window.ps1
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# 03-window.ps1 -- window registry and ref table
|
|
2
|
-
#
|
|
3
|
-
# Part of worker/uia-worker.ps1, dot-sourced by it in the order scripts/lib/sources.mjs declares.
|
|
4
|
-
# It lives in its own file only so a section can be read without scrolling the whole RPC server.
|
|
5
|
-
# Dot-sourcing shares the entry's script scope, so a helper here may use $script:W and may call
|
|
1
|
+
# 03-window.ps1 -- window registry and ref table
|
|
2
|
+
#
|
|
3
|
+
# Part of worker/uia-worker.ps1, dot-sourced by it in the order scripts/lib/sources.mjs declares.
|
|
4
|
+
# It lives in its own file only so a section can be read without scrolling the whole RPC server.
|
|
5
|
+
# Dot-sourcing shares the entry's script scope, so a helper here may use $script:W and may call
|
|
6
6
|
# any function from any other part: neighbour order is not a dependency.
|
|
7
7
|
# ---------------------------------------------------------------- window registry
|
|
8
8
|
function Ensure-Window($hwnd, $aeHint) {
|
|
@@ -167,8 +167,8 @@ function Evict-ForReservation($needed) {
|
|
|
167
167
|
if ($null -eq $victim) { break }
|
|
168
168
|
$count = $victim.refs.Count
|
|
169
169
|
foreach ($rk in $victim.refs) {
|
|
170
|
-
#
|
|
171
|
-
#
|
|
170
|
+
# A ref list can hold an entry that never became a string key, and .Item($null) throws
|
|
171
|
+
# "Key cannot be null" — which would abort the whole snapshot with internal_error.
|
|
172
172
|
if ([string]::IsNullOrEmpty([string]$rk)) { continue }
|
|
173
173
|
$r = $null
|
|
174
174
|
if ($script:W.refs.ContainsKey($rk)) { $r = $script:W.refs[$rk] }
|
package/worker/lib/04-match.ps1
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# 04-match.ps1 -- descriptor matching (name ladders, scoring)
|
|
2
|
-
#
|
|
3
|
-
# Part of worker/uia-worker.ps1, dot-sourced by it in the order scripts/lib/sources.mjs declares.
|
|
4
|
-
# It lives in its own file only so a section can be read without scrolling the whole RPC server.
|
|
5
|
-
# Dot-sourcing shares the entry's script scope, so a helper here may use $script:W and may call
|
|
1
|
+
# 04-match.ps1 -- descriptor matching (name ladders, scoring)
|
|
2
|
+
#
|
|
3
|
+
# Part of worker/uia-worker.ps1, dot-sourced by it in the order scripts/lib/sources.mjs declares.
|
|
4
|
+
# It lives in its own file only so a section can be read without scrolling the whole RPC server.
|
|
5
|
+
# Dot-sourcing shares the entry's script scope, so a helper here may use $script:W and may call
|
|
6
6
|
# any function from any other part: neighbour order is not a dependency.
|
|
7
7
|
# ---------------------------------------------------------------- descriptor matching
|
|
8
8
|
# Match ladder, strictly ordered and never silently fuzzy:
|
|
9
|
-
# 1. strict the caller's AND of exact UIA conditions (
|
|
9
|
+
# 1. strict the caller's AND of exact UIA conditions (the default exact match)
|
|
10
10
|
# 2. id automationId (+controlType/className) only; the name is allowed to churn
|
|
11
11
|
# 3. normalizedName the name's dynamic tail normalised away, then compared exactly
|
|
12
12
|
# 4. prefix literal substring, ONLY for an explicit nameExact:false
|
|
@@ -296,9 +296,9 @@ function Find-ByDescriptor($entry, $by) {
|
|
|
296
296
|
$keepArg = $wantName
|
|
297
297
|
}
|
|
298
298
|
$cond = Join-UiaCondition $conds
|
|
299
|
-
# Fast path:
|
|
300
|
-
#
|
|
301
|
-
#
|
|
299
|
+
# Fast path: FindFirst whenever nothing has to be disambiguated and the name stays exact. A
|
|
300
|
+
# recipe that resolved before resolves the same way, and the common case does not pay for a
|
|
301
|
+
# full descendant enumeration.
|
|
302
302
|
if ($tier -eq 'strict' -and $null -eq $keep -and $nth -le 1 -and $null -eq $near) {
|
|
303
303
|
$hit = $null
|
|
304
304
|
try { $hit = $ae.FindFirst([System.Windows.Automation.TreeScope]::Descendants, $cond) } catch { $hit = $null }
|
|
@@ -308,9 +308,8 @@ function Find-ByDescriptor($entry, $by) {
|
|
|
308
308
|
$lm.score = (Get-MatchScore 'strict' '')
|
|
309
309
|
$lm.degraded = $false
|
|
310
310
|
# FindFirst stops at the first hit, so the REAL number of same-named candidates is unknown
|
|
311
|
-
# here. Writing 1
|
|
312
|
-
#
|
|
313
|
-
# is true instead: the count is unknown, and the condition is kept so the read-only
|
|
311
|
+
# here. Writing 1 would fake a uniqueness this scan never established; say what is true
|
|
312
|
+
# instead: the count is unknown, and the condition is kept so the read-only
|
|
314
313
|
# descriptor_match diagnostic can re-enumerate it and recover the real number.
|
|
315
314
|
$lm.candidateCountKnown = $false
|
|
316
315
|
$lm.fastCond = $cond
|