feat(fillbar): bouton Paste qui tape le presse-papiers Windows

Pour les clients a distance qui ne transmettent pas le presse-papiers
(TigerVNC vers un Mac) : le texte est tape par le chemin de l'autofill,
touches VNC et dispositions comprises, insere au curseur. Et l'arabe des
champs a chasse fixe s'affiche a la bonne taille (repli Segoe UI / Tahoma).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-10-14 17:53:09 +01:00
parent bf7a8f4d38
commit 092eb2f73a
4 changed files with 94 additions and 17 deletions
+58
View File
@@ -183,6 +183,7 @@ type
// les declenche aussi, meme capture de la fenetre cible.
procedure FireNewEntryRequest;
procedure FireQuickSearchRequest;
procedure PasteClipboardAsKeystrokes;
/// Pose l'opacite qui convient a l'etat de survol donne.
procedure ApplyLazyAlpha(AHover: Boolean);
/// Menu du clic droit sur la barrette : le choix de l'opacite au repos.
@@ -450,6 +451,7 @@ const
LAZY_ID_ADD = 106; // nouvelle entree depuis la fenetre en avant (Ctrl+Shift+A)
LAZY_ID_SEARCH = 107; // recherche rapide (Ctrl+Shift+Q)
LAZY_ID_SETTINGS = 108; // reglages, onglet Fill bar
LAZY_ID_PASTE = 109; // tape le presse-papiers Windows dans la fenetre en avant
LAZY_MENU_ICONS = 1; // hors des valeurs d'opacite (25..100) du meme menu
LAZY_MENU_SETTINGS = 2;
LAZY_MENU_CLEAR = 3;
@@ -1116,6 +1118,59 @@ end;
// The target of a fill is whatever window owns the foreground at the moment
// the user asks for it - a shortcut, or a click on the lazy strip, which takes
// no foreground precisely so this stays true.
/// COLLER EN TAPANT. Certains clients a distance (TigerVNC vers un Mac) ne
/// transmettent pas le presse-papiers Windows : Ctrl+V n'y colle rien. Le texte
/// est donc TAPE dans la fenetre en avant, par le meme chemin que l'autofill -
/// vraies touches pour un client VNC, dispositions basculees au besoin. Le
/// presse-papiers est celui de Windows : coffre ouvert ou non, rien ne passe
/// par la page. Pas de Ctrl+A + Suppr avant : on insere au curseur, comme un
/// collage.
procedure TPMBridge.PasteClipboardAsKeystrokes;
var
LTarget: HWND;
LData: THandle;
LPtr: PWideChar;
LText: string;
begin
LTarget := GetForegroundWindow;
if IsOwnProcessWindow(LTarget) then
begin
ShowBalloon('Nothing to paste into',
'Click where the text should go first, then press Paste.', True);
Exit;
end;
LText := '';
if OpenClipboard(0) then
try
LData := GetClipboardData(CF_UNICODETEXT);
if LData <> 0 then
begin
LPtr := GlobalLock(LData);
if LPtr <> nil then
try
LText := LPtr;
finally
GlobalUnlock(LData);
end;
end;
finally
CloseClipboard;
end;
// Un retour a la ligne final, tape dans un terminal, vaudrait Entree.
// Les sauts de ligne internes partent en #13 : Entree, comme un collage.
LText := LText.Replace(#13#10, #10).Replace(#13, #10).TrimRight([#10])
.Replace(#10, #13);
if LText = '' then
begin
// Une image ou un fichier copies ne sont pas du texte : le dire tel quel.
ShowBalloon('No text in the clipboard', 'Copy some text first, then press Paste.', True);
Exit;
end;
if not ExecuteAutofill(LTarget, '', LText, False, False, False) then
ShowBalloon('Paste blocked',
'The window did not accept the keystrokes (it may run as administrator).', True);
end;
procedure TPMBridge.FireAutofillRequest(AKind: TAutofillKind;
AFromBar: Boolean = False);
var
@@ -1302,6 +1357,7 @@ begin
LAZY_ID_SEARCH: LGlyph := #$E721; // Search
LAZY_ID_OPEN: LGlyph := #$E8A7; // OpenInNewWindow
LAZY_ID_SETTINGS: LGlyph := #$E713; // Settings (roue)
LAZY_ID_PASTE: LGlyph := #$E77F; // Paste
else
LGlyph := #$E711; // Cancel (X)
end;
@@ -1505,6 +1561,7 @@ begin
LAZY_ID_OPEN: if Assigned(FOnTrayRestore) then FOnTrayRestore();
LAZY_ID_ADD: FireNewEntryRequest;
LAZY_ID_SEARCH: FireQuickSearchRequest;
LAZY_ID_PASTE: PasteClipboardAsKeystrokes;
LAZY_ID_SETTINGS:
begin
if Assigned(FOnTrayRestore) then FOnTrayRestore();
@@ -1669,6 +1726,7 @@ begin
AddButton('full', LAZY_ID_FULL, 'Full', 'Fill username and password', 56);
AddButton('pwd', LAZY_ID_PWD, 'Password', 'Fill the password only', 76);
AddButton('totp', LAZY_ID_TOTP, '2FA', 'Fill the 2FA code', 52);
AddButton('paste', LAZY_ID_PASTE, 'Paste', 'Type the Windows clipboard into the current window', 52);
AddButton('add', LAZY_ID_ADD, 'Add', 'New entry from the current window', 48);
AddButton('search', LAZY_ID_SEARCH, 'Search', 'Quick search', 60);
// Meme raison que le X : quand la barrette est allumee, elle est souvent la