Le script ne cherchait que dans les dossiers de l'installeur officiel (Program Files, LOCALAPPDATA) : avec Scoop, il concluait à tort à une absence d'AutoHotkey. Détection désormais, dans l'ordre : - variables d'environnement PROMPTKEY_AHK_EXE / PROMPTKEY_AHK2EXE ; - PATH via Get-Command (shims Scoop inclus), avec résolution de la cible réelle du shim (le fichier .shim compagnon) car un shim ne peut pas servir de base à Ahk2Exe ; - dossiers usuels de l'installeur officiel ; - racines Scoop (SCOOP, ~/scoop, SCOOP_GLOBAL, ProgramData\scoop), apps\autohotkey\current et dossiers de version. Si seul le lanceur AutoHotkey.exe est trouvé, préférer le vrai AutoHotkey64.exe voisin comme base de compilation. Messages d'erreur détaillant les endroits cherchés et les contournements.
This commit is contained in:
@@ -2,6 +2,12 @@
|
||||
|
||||
Le format suit [Keep a Changelog](https://keepachangelog.com/fr/1.0.0/) et le projet utilise le versionnage sémantique.
|
||||
|
||||
## [Non publié] — 2026-10-11
|
||||
|
||||
### Corrigé
|
||||
|
||||
- `build.ps1` : la détection d'AutoHotkey et d'Ahk2Exe couvre désormais les installations **Scoop** (commandes du PATH et shims — avec résolution de la cible réelle du shim, car le shim ne peut pas servir de base à Ahk2Exe — et dossiers `apps\autohotkey\` des racines Scoop utilisateur et globale), en plus de l'installeur officiel. Chemins imposables via les variables d'environnement `PROMPTKEY_AHK_EXE` / `PROMPTKEY_AHK2EXE`. Quand seul le lanceur `AutoHotkey.exe` est trouvé, le script préfère le vrai interpréteur `AutoHotkey64.exe` situé à côté, comme l'exige Ahk2Exe.
|
||||
|
||||
## [1.0.0] — 2026-10-11
|
||||
|
||||
Première version.
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
# 5. Affiche la somme SHA256 de l'exécutable.
|
||||
#
|
||||
# Prérequis : AutoHotkey v2.0 (64 bits) installé, Ahk2Exe fourni avec
|
||||
# (dossier Compiler\ de l'installation AutoHotkey).
|
||||
# (dossier Compiler\ de l'installation AutoHotkey). Installations détectées :
|
||||
# installeur officiel, Scoop (PATH/shims et apps\), ou chemins imposés par
|
||||
# les variables d'environnement PROMPTKEY_AHK_EXE / PROMPTKEY_AHK2EXE.
|
||||
|
||||
#Requires -Version 5.1
|
||||
$ErrorActionPreference = 'Stop'
|
||||
@@ -23,23 +25,86 @@ function Echouer($Message) {
|
||||
}
|
||||
|
||||
# --- 1. Localiser AutoHotkey v2 et Ahk2Exe ----------------------------------
|
||||
$AhkExe = $null
|
||||
$Ahk2Exe = $null
|
||||
$Candidats = @(
|
||||
# Ordre de détection :
|
||||
# 1. Variables d'environnement PROMPTKEY_AHK_EXE / PROMPTKEY_AHK2EXE (si définies).
|
||||
# 2. Le PATH : Get-Command (couvre notamment les shims Scoop, dont on résout
|
||||
# la cible réelle — le shim lui-même ne peut pas servir de « base » à Ahk2Exe).
|
||||
# 3. Les dossiers d'installation usuels (installeur officiel).
|
||||
# 4. Les racines Scoop : $env:SCOOP, %USERPROFILE%\scoop, $env:SCOOP_GLOBAL,
|
||||
# %ProgramData%\scoop (apps\autohotkey\current\ et dossiers de version).
|
||||
|
||||
function Resoudre-Shim($Chemin) {
|
||||
# Un shim Scoop a un fichier compagnon <nom>.shim contenant « path = "..." ».
|
||||
if ($Chemin -and (Test-Path $Chemin)) {
|
||||
# Le compagnon d'un shim « truc.exe » s'appelle « truc.shim ».
|
||||
$CandidatsShim = @(($Chemin -replace '\.exe$', '.shim'), "$Chemin.shim")
|
||||
foreach ($FichierShim in $CandidatsShim) {
|
||||
if (Test-Path $FichierShim) {
|
||||
foreach ($Ligne in Get-Content $FichierShim) {
|
||||
if ($Ligne -match '^\s*path\s*=\s*"(.+)"\s*$' -and (Test-Path $Matches[1])) {
|
||||
return $Matches[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $Chemin
|
||||
}
|
||||
|
||||
function Chercher-DansDossiers($Dossiers, $Noms) {
|
||||
foreach ($Dossier in $Dossiers) {
|
||||
if ($Dossier -and (Test-Path $Dossier)) {
|
||||
foreach ($Nom in $Noms) {
|
||||
$Trouve = Get-ChildItem -Path $Dossier -Recurse -Filter $Nom -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if ($Trouve) { return $Trouve.FullName }
|
||||
}
|
||||
}
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
function Chercher-DansPath($Noms) {
|
||||
foreach ($Nom in $Noms) {
|
||||
$Cmd = Get-Command $Nom -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if ($Cmd) { return Resoudre-Shim $Cmd.Source }
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
$RacinesScoop = @($env:SCOOP, "$env:USERPROFILE\scoop", $env:SCOOP_GLOBAL, "$env:ProgramData\scoop") |
|
||||
Where-Object { $_ } | Select-Object -Unique
|
||||
$DossiersRecherche = @(
|
||||
"$env:ProgramFiles\AutoHotkey",
|
||||
"${env:ProgramFiles(x86)}\AutoHotkey",
|
||||
"$env:LOCALAPPDATA\Programs\AutoHotkey"
|
||||
)
|
||||
foreach ($Dossier in $Candidats) {
|
||||
if (Test-Path $Dossier) {
|
||||
$Trouve = Get-ChildItem -Path $Dossier -Recurse -Filter 'AutoHotkey64.exe' -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if ($Trouve) { $AhkExe = $Trouve.FullName }
|
||||
$Trouve = Get-ChildItem -Path $Dossier -Recurse -Filter 'Ahk2Exe.exe' -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if ($Trouve) { $Ahk2Exe = $Trouve.FullName }
|
||||
}
|
||||
foreach ($RacineScoop in $RacinesScoop) {
|
||||
$DossiersRecherche += Join-Path $RacineScoop 'apps\autohotkey\current'
|
||||
$DossiersRecherche += Join-Path $RacineScoop 'apps\autohotkey'
|
||||
}
|
||||
if (-not $AhkExe) { Echouer "AutoHotkey v2 introuvable. Installez AutoHotkey v2.0 (64 bits) depuis https://www.autohotkey.com/" }
|
||||
if (-not $Ahk2Exe) { Echouer "Ahk2Exe introuvable. Il est fourni avec AutoHotkey v2 (dossier Compiler\) ; réinstallez en incluant l'option de compilation." }
|
||||
|
||||
$AhkExe = $null
|
||||
$Ahk2Exe = $null
|
||||
if ($env:PROMPTKEY_AHK_EXE -and (Test-Path $env:PROMPTKEY_AHK_EXE)) { $AhkExe = $env:PROMPTKEY_AHK_EXE }
|
||||
if (-not $AhkExe) { $AhkExe = Chercher-DansPath @('AutoHotkey64.exe', 'AutoHotkey.exe', 'autohotkey.exe') }
|
||||
if (-not $AhkExe) { $AhkExe = Chercher-DansDossiers $DossiersRecherche @('AutoHotkey64.exe', 'AutoHotkey.exe') }
|
||||
if ($AhkExe -and ((Split-Path -Leaf $AhkExe) -ieq 'AutoHotkey.exe')) {
|
||||
# « AutoHotkey.exe » tout court est le lanceur (installeur ou shim) : comme base
|
||||
# de compilation, Ahk2Exe exige le vrai interpréteur 64 bits — le chercher à côté.
|
||||
$Mieux = Chercher-DansDossiers @((Split-Path -Parent $AhkExe)) @('AutoHotkey64.exe')
|
||||
if ($Mieux) { $AhkExe = $Mieux }
|
||||
}
|
||||
if ($env:PROMPTKEY_AHK2EXE -and (Test-Path $env:PROMPTKEY_AHK2EXE)) { $Ahk2Exe = $env:PROMPTKEY_AHK2EXE }
|
||||
if (-not $Ahk2Exe -and $AhkExe) {
|
||||
# Cas le plus fréquent : Compiler\Ahk2Exe.exe à côté de l'interpréteur trouvé.
|
||||
$Voisin = Join-Path (Split-Path -Parent $AhkExe) 'Compiler\Ahk2Exe.exe'
|
||||
if (Test-Path $Voisin) { $Ahk2Exe = $Voisin }
|
||||
}
|
||||
if (-not $Ahk2Exe) { $Ahk2Exe = Chercher-DansPath @('Ahk2Exe.exe', 'ahk2exe.exe') }
|
||||
if (-not $Ahk2Exe) { $Ahk2Exe = Chercher-DansDossiers $DossiersRecherche @('Ahk2Exe.exe') }
|
||||
|
||||
if (-not $AhkExe) { Echouer "AutoHotkey v2 introuvable (cherché : PATH et shims, dossiers d'installation usuels, racines Scoop [$($RacinesScoop -join ', ')]). Installez AutoHotkey v2.0 (64 bits) — installeur https://www.autohotkey.com/ ou « scoop install autohotkey » — ou définissez la variable d'environnement PROMPTKEY_AHK_EXE vers AutoHotkey64.exe." }
|
||||
if (-not $Ahk2Exe) { Echouer "Ahk2Exe introuvable. Il est fourni avec AutoHotkey v2 (dossier Compiler\ de l'installation, y compris Scoop) ; à défaut, définissez la variable d'environnement PROMPTKEY_AHK2EXE vers Ahk2Exe.exe." }
|
||||
|
||||
# Vérifier qu'il s'agit bien de la v2 (le champ FileVersion commence par 2.)
|
||||
$Version = (Get-Item $AhkExe).VersionInfo.FileVersion
|
||||
|
||||
Reference in New Issue
Block a user