Référence complète des commandes — v2.0 · Toutes validées sur le testeur PFPComplete command reference — v2.0 · all validated on the PFP tester
Show-PF "Fichier sauvegardé !" -IsSuccess
-TypeTitle line. Without one, the label is derived from -TypeInfo | Success | Warning | Error.\logo.png) ou absolu. Défaut = logo du projet ($form → Propriétés → Application)Logo — path relative to the app folder (.\logo.png) or absolute. Default = the project logo ($form → Properties → Application){ Ok; Native; Error } au lieu du booléenReturns { Ok; Native; Error } instead of the booleanShow-PF, pas un remplaçant : Show-PF = bulle dans la fenêtre, Toast-PF = notification du système (visible fenêtre minimisée, conservée dans le centre de notifications). C'est le seul verbe de notification autorisé dans un bloc -Work : il ne touche aucun contrôle WinForms. Retourne $true/$false, ne lève jamais d'exception ; en cas d'échec de la voie native il replie sur le toast in-app et la cause est dans $script:PFToastError.Complements Show-PF, it does not replace it: Show-PF = a bubble inside the window, Toast-PF = a system notification (visible when minimised, kept in the Action Center). It is the only notification verb allowed inside a -Work block: it touches no WinForms control. Returns $true/$false and never throws; if the native path fails it falls back to the in-app toast and the reason is in $script:PFToastError.toast("Sauvegarde effectuée") toast("Export terminé", { type: "success", sound: false }) toast("Serveur injoignable", { type: "error", onClick: { Go-PF "Journal" } }) if (-not (Toast-PF -Message "Terminé")) { Write-PF $script:lblEtat $script:PFToastError }
Alert-PF "Action impossible" -IsError Alert-PF "Connexion lente détectée" -IsWarning Alert-PF "Traitement terminé avec succès."
$true = OUI, $false = NON / Annulerif (Ask-PF "Voulez-vous supprimer cet enregistrement ?") { # L'utilisateur a cliqué OUI Clear-PF $script:dgvData Show-PF "Supprimé !" -IsSuccess }
$null -ne $val avant d'utiliser le résultat. L'utilisateur peut cliquer Annuler.$nom = Read-PF "Entrez votre nom :" -Default "Dupont" if ($null -ne $nom) { Write-PF $script:lblBonjour "Bonjour $nom !" }
"75")Value to write. For a ProgressBar, pass an integer (e.g. "75")Start-PF -Work. Ne jamais accéder directement à $script: depuis le runspace de -Work.Write-PF $script:lblStatut "Prêt" Write-PF $script:txtLog "Ligne ajoutée`n" -Append Write-PF $script:prgAvancement "75" # ProgressBar à 75 %
$true si le contrôle est valide. En cas d'échec, la commande affiche elle-même un toast orange (sauf -Silent).return, pour n'afficher qu'un message à la fois. Attention : -Regex, -Min et -Max ne détectent pas un champ vide — ajouter -Required.Validates one control per call: chain one line per field, each with its own return, so only one message shows at a time. Note: -Regex, -Min and -Max do not catch an empty field — add -Required.if (-not (Validate-PF $script:txtNom -Required -Message "Le nom est obligatoire.")) { return } if (-not (Validate-PF $script:txtAge -Required -Min 0 -Max 130)) { return } # Ici, tous les champs sont valides
Clear-PF $script:txtSaisie Clear-PF $script:dgvResultats Clear-PF $script:cmbFiltres
-All = tous les éléments d'une liste (ou toutes les lignes d'une grille, en objets) · -Checked = éléments cochés d'une CheckedListBox · -Index = index de la ligne DataGridView sélectionnée (-1 si aucune) · -Field "Col" = champ nommé de la ligne courante · -Prop "BackColor" = lecture générique d'une propriété .NET.Get-PF ctrl Text (nom sans $ + propriété en 2e argument) n'existe pas : elle renvoie du vide sans erreur. Écrivez Get-PF $ctrl ou Get-PF $ctrl -Prop Text.-All = every item of a list (or every grid row, as objects) · -Checked = ticked items of a CheckedListBox · -Index = index of the selected DataGridView row (-1 if none) · -Field "Col" = named field of the current row · -Prop "BackColor" = generic read of any .NET property.Get-PF ctrl Text form (bare name + property argument) does not exist: it silently returns empty. Write Get-PF $ctrl or Get-PF $ctrl -Prop Text.$nom = Get-PF $script:txtNom # string $date = Get-PF $script:dtpDate # DateTime $ok = Get-PF $script:chkActif # bool $item = Get-PF $script:dgvListe # objet lié
-Where filtre les données à l'affichage (le bloc reçoit chaque élément dans $_) — idéal pour une barre de recherche : on refiltre la même source à chaque frappe, sans la dupliquer.Fill-PF $dgv $data -Where { $_.Nom -like "*$q*" }-Where filters the data at display time (the block receives each item as $_) — ideal for a search box: refilter the same source on each keystroke, with no duplicate.Fill-PF $dgv $data -Where { $_.Nom -like "*$q*" }$null vide le contrôle.Array of strings, hashtables, PSCustomObjects or DataRows. $null clears the control.@() de Hashtables, PSCustomObjects ou valeurs simples. Les colonnes sont créées automatiquement et auto-redimensionnées.# Liste simple Fill-PF $script:cmbVilles @("Paris", "Lyon", "Bordeaux") # DataGridView avec PSCustomObjects $data = Import-Csv "data.csv" Fill-PF $script:dgvData $data # Vider un contrôle Fill-PF $script:lstItems $null
Fill-PF, qui lui remplace tout. Sur une DataGridView liée (après Fill-PF), la ligne est ajoutée/retirée directement dans la source de données : plus besoin de variable miroir $script:. Thread-safe.Complements Fill-PF, which replaces everything. On a bound DataGridView (after Fill-PF), the row is added/removed straight in the data source: no mirror $script: variable needed. Thread-safe.Add-PF $script:lstTaches "Nouvelle tâche" Add-PF $script:cbxVilles @("Paris", "Lyon") Remove-PF $script:lstTaches "Paris" Remove-PF $script:lstTaches -Index 0 # DataGridView liée Add-PF $script:dgvClients @{ Nom="Carol"; Age=40 } Remove-PF $script:dgvClients -Index (Get-PF $script:dgvClients -Index)
@() et le scope $script:. (Note : Remplacé par Toggle-PF dans de nombreux cas en v2.0)
Lock-PF -Controls @($script:btnValider, $script:txtInput)
@($script:c1, $script:c2) ou contrôle uniqueArray of controls @($script:c1, $script:c2) or a single control# Désactiver un panel entier Toggle-PF $script:pnlFormulaire -Action Disable # Masquer plusieurs boutons d'un coup Toggle-PF @($script:btnSave, $script:btnCancel) -Action Hide
-Prop, Set-PF est purement numérique. -Prop écrit n'importe quelle propriété .NET (Visible, Enabled, BackColor, Width…), de façon gardée et thread-safe — ex. Set-PF $pnl -Prop "Visible" $false. Pour l'apparence d'un bouton, préférez Style-PF.Without -Prop, Set-PF is numeric only. -Prop writes any .NET property (Visible, Enabled, BackColor, Width…), guarded and thread-safe — e.g. Set-PF $pnl -Prop "Visible" $false. For button looks, prefer Style-PF.-Work de Start-PF / Wait-PF (gère InvokeRequired automatiquement). Le clamp Min/Max évite tout dépassement.Thread-safe: callable straight from a -Work block of Start-PF / Wait-PF (handles InvokeRequired automatically). The Min/Max clamp prevents any overflow.Set-PF $script:prgCharge -Value 75 # à 75 % Set-PF $script:prgCharge -Add -Value 10 # +10 Set-PF $script:prgCharge -Reset # → Minimum
$script: directement.ScriptBlock run in the background. Never read $script: directly inside it.$result.UI callback run on success. Receives $result.$prog.UI callback to update a ProgressBar. Receives $prog.$_shared.Data passed to the runspace through $_shared.-With pour injecter des chemins ou valeurs venant de l'UI.Start-PF -Work { param($s) for($i=0;$i-lt100;$i++){ Start-Sleep -m 50; Report-Progress $i } return "Fini !" } -OnProgress { param($p) Write-PF $script:prg $p } -Then { param($r) Show-PF $r }
$script:. Tester $_shared["_canceled"] pour arrêt propre.ScriptBlock run in a separate runspace (background thread). Never read $script: inside it. Test $_shared["_canceled"] for a clean stop.$_shared. Seul moyen de passer des valeurs UI.Data passed to the runspace through $_shared. The only way to hand over UI values.$script:_controls est inaccessible. Utiliser -With pour injecter les valeurs, lire les résultats dans -Then. Pour un accès direct aux contrôles, utiliser Sleep-PF (synchrone).$result = Wait-PF -Message "Import en cours…" -Work { param($_s) foreach ($item in $_s.Liste) { if ($_s["_canceled"]) { break } # traitement lourd ici… } return "Terminé" } -With @{ Liste = $maListe } -Then { param($r) Show-PF $r -IsSuccess }
DoEvents().Pause length in milliseconds (default: 100). The UI stays responsive throughout via DoEvents().finally).Closes and disposes the dialog. MUST be called at the end of the loop (or in a finally block).$script:_controls est accessible directement dans la boucle appelante. Le dialog est créé au premier appel et reste persistant jusqu'à -End.-End retourne aussi l'état d'annulation final.Sleep-PF -End en fin de boucle, idéalement dans un bloc finally, pour garantir la fermeture du dialog même en cas d'exception.Lock-PF try { for ($i = 1; $i -le 100; $i++) { Set-PF $script:_controls["pb"] -Value $i # ✅ thread UI direct Write-PF $script:_controls["lbl"] "Étape $i/100" # ✅ idem if (Sleep-PF -Ms 80 -Message "Traitement $i/100…") { break } } } finally { Sleep-PF -End # ferme le dialog — garanti même si exception Unlock-PF } Show-PF "Import terminé !" -IsSuccess
Start-PF (runspace + timer) : la commande tourne en arrière-plan, un timer UI vide la file ligne par ligne. Le bloc de commande tourne dans un runspace isolé — aucun accès UI direct dedans (pas de Set-PF, Fill-PF, $ctrl.Text) : passez par -Then.Same engine as Start-PF (runspace + timer): the command runs in the background and a UI timer drains the queue line by line. The command block runs in an isolated runspace — no direct UI access inside (no Set-PF, Fill-PF, $ctrl.Text): go through -Then.Watch-PF { ping "8.8.8.8" -n 10 } -Into $script:rtxLog Watch-PF { Get-ChildItem "C:\Temp" -Recurse } -Into $script:rtxLog -Then { Show-PF "Analyse terminée" -IsSuccess }
Go-PF "Configuration"
Read-PFData $src renvoie des objets prêts pour Fill-PF. Write-PFData $src $data écrit, Get-PFSchema $src liste les colonnes. Ou renseignez le fichier dans l'encadré Source de données des propriétés d'une DataGridView : elle se remplit seule à l'ouverture. Join-PFData $a $b -On "Cle" -Add "Col" associe deux sources par une clé commune (jointure façon LookUp).Read-PFData $src returns objects ready for Fill-PF. Write-PFData $src $data writes, Get-PFSchema $src lists columns. Or set the file in the Data source box of a DataGridView's properties: it fills itself on open. Join-PFData $a $b -On "Key" -Add "Col" links two sources on a shared key (LookUp-style join).$src = Connect-PFData -Provider Excel -Path "C:/Data/contacts.xlsx" -Sheet "Contacts" Fill-PF $DgvContacts (Read-PFData $src) Fill-PF $DgvContacts (Read-PFData $src -Where { $_.Actif -eq $true }) Write-PFData $src (Get-PF $DgvContacts -All) # Jointure relationnelle (façon LookUp) : enrichir chaque commande du nom de son service Join-PFData $cmds $services -On "ServiceId" -RightKey "Id" -Add "Nom"
$path = Pick-PF -Mode Save -Filter "CSV|*.csv" if ($null -ne $path) { Export-PFGrid -Grid $script:dgvStocks -Path $path }
@{ "Running"="Green"; "Stopped"="Red" }Value→.NET colour table, e.g. @{ "Running"="Green"; "Stopped"="Red" }Fill-PF. Robuste au re-binding : s'abonne une seule fois à CellFormatting et relit ses règles à chaque rendu. Les noms de couleur inconnus sont ignorés sans erreur.Call it after Fill-PF. Robust to re-binding: subscribes once to CellFormatting and re-reads its rules on every render. Unknown colour names are ignored without error.Fill-PF $script:dgvServices (Get-Service) Format-PF $script:dgvServices -Column "Status" -Rules @{ "Running"="Green"; "Stopped"="Red" }
-As Auto) : collection d'objets → Export-Csv, sinon → Out-File. Précisez -As dès que le contenu compte : Json = round-trip fiable de n'importe quelle valeur (hashtable, objet imbriqué), Text = jamais reniflé en CSV. Le format est piloté par -As, pas par l'extension du fichier.By default (-As Auto): a collection of objects → Export-Csv, otherwise → Out-File. Set -As as soon as the content matters: Json = reliable round-trip of any value (hashtable, nested object), Text = never sniffed as CSV. The format is driven by -As, not by the file extension.Save-PF -Data $mesLogs -Path "log.txt" -Append
Auto, un texte contenant , ou ; est relu à tort comme du CSV. Utilisez -As Text (ou -As Json) pour un round-trip garanti. Json → objet · Csv → PSObject[] · Text → string[].In Auto, text containing , or ; is wrongly parsed as CSV. Use -As Text (or -As Json) for a guaranteed round-trip. Json → object · Csv → PSObject[] · Text → string[].$data = Load-PF "settings.csv"
$null -ne $result car l'utilisateur peut annuler la fenêtre.$folder = Pick-PF -Mode Folder -Title "Cible"
fontSize d'un Label, la valeur doit impérativement être une chaîne de caractères (ex: "11").Style-PF $script:btnSave -Type Primary
0xE74D. C'est un nombre, pas une chaîne.MDL2 glyph code point, in hexadecimal notation: 0xE74D. It is a number, not a string.Set-IconPF, l'icône et le libellé tiennent dans LE MÊME contrôle.Label. With Set-IconPF, icon and label sit in THE SAME control.-IconSize sur Set-IconTextPF (défaut 13).Glyph size (default 14). Named -IconSize on Set-IconTextPF (default 13).Set-IconPF prend un contrôle (icône + libellé dans le même bouton) ; Set-IconTextPF en prend deux — l'icône sur le premier, le texte sur le second. L'icône utilise la police "Segoe MDL2 Assets" par défaut, pour une compatibilité maximale Win10/11.Two commands, two uses: Set-IconPF takes one control (icon + label in the same button); Set-IconTextPF takes two — icon on the first, text on the second. The icon uses the "Segoe MDL2 Assets" font by default, for maximum Win10/11 compatibility.# Icone + libelle dans le meme bouton Set-IconPF $script:btnDel -Code 0xE74D -Text "Supprimer" # Icone sur un controle, libelle sur un autre Set-IconTextPF $script:btnIcone $script:lblDel -Code 0xE74D -Text "Supprimer"