fix(autofill): honest result reporting + restore maximized from tray
Bug 1: a maximized window trayed via the quick-search fill flow came back "normal" on the next restore. ExecuteAutofill minimizes the window BEFORE MinimizeToTray snapshots the placement, so the snapshot said SHOWMINIMIZED and the never-restore-minimized guard forced SHOWNORMAL. Now honours WPF_RESTORETOMAXIMIZED (Windows keeps the pre-minimize state in flags). Bug 2: filling into an elevated app (admin Notepad) showed "password sent" while UIPI silently discarded the keystrokes (SendInput even reports success). ExecuteAutofill is now a function: it checks the target process elevation up front (can't-open counts as elevated) and returns False without typing. UMainForm feeds the result to JS via Bridge.onAutofillResult; the quick-search success toast is deferred until Delphi confirms, and a failure shows "Autofill blocked - the target window runs as administrator". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1467,14 +1467,19 @@ begin
|
||||
TTimer(Sender).Free;
|
||||
|
||||
// ARestoreAfter = not HideAfter: if the app was open before the hotkey
|
||||
// (quick-search beside the target), it comes back after the fill; if it
|
||||
// (quick-search beside the target), it stays visible during the fill; if it
|
||||
// started hidden, the MinimizeToTray below re-hides it anyway.
|
||||
FBridge.ExecuteAutofill(TargetHwnd, PendingUser, PendingPass, UserOnly,
|
||||
not HideAfter);
|
||||
var LFillOk := FBridge.ExecuteAutofill(TargetHwnd, PendingUser, PendingPass,
|
||||
UserOnly, not HideAfter);
|
||||
ForegroundAfter := GetForegroundWindow;
|
||||
LogLine(Format('Autofill executed — target=%s, foreground_after=%s, match=%s',
|
||||
LogLine(Format('Autofill executed — target=%s, foreground_after=%s, ok=%s',
|
||||
[IntToHex(TargetHwnd, 8), IntToHex(ForegroundAfter, 8),
|
||||
BoolToStr(ForegroundAfter = TargetHwnd, True)]));
|
||||
BoolToStr(LFillOk, True)]));
|
||||
// Tell JS whether the keystrokes were actually sent — the success toast
|
||||
// must not lie when the target runs elevated (UIPI drops our input).
|
||||
WebBrowser.ExecuteJavaScript(
|
||||
'if(window.Bridge&&typeof Bridge.onAutofillResult==="function")' +
|
||||
'Bridge.onAutofillResult(' + BoolToStr(LFillOk, True).ToLower + ')');
|
||||
|
||||
// Hide-after (Ctrl+Shift+Q from tray): SendInput is done, the target
|
||||
// already has focus — now we can safely tray ourselves without
|
||||
|
||||
Reference in New Issue
Block a user