Enhance SandwichReminder-AutoOrder feature with direct checkout navigation and improved logic

- Added new configuration options for direct checkout navigation, including `useDirectCheckoutNavigation`, `checkoutPath`, and `checkoutOpenDelayMs`.
- Updated the auto-order flow to navigate directly to the checkout page, skipping the mini-cart and date/time steps.
- Improved keyboard automation logic for item remark and order confirmation processes.
- Removed the old SandwichAutoOrder.ps1 file as its functionality has been integrated into SandwichReminder-AutoOrder.ps1.
- Introduced a new runner-launcher.vbs to start the runner.ps1 without a visible console window, ensuring WinForms dialogs can appear.
- Implemented a mutex mechanism in runner.ps1 to prevent concurrent execution of the same feature.
This commit is contained in:
Arne Moerman
2026-05-11 13:59:22 +02:00
parent 2592c0145f
commit 6c10d359d2
7 changed files with 525 additions and 205 deletions
+22 -1
View File
@@ -11,7 +11,6 @@ $script:InternalRoot = $PSScriptRoot # runner.ps1 lives in internal\
. (Join-Path $InternalRoot 'lib\NetworkUtils.ps1')
. (Join-Path $InternalRoot 'lib\ToastHelper.ps1')
. (Join-Path $InternalRoot 'lib\PromptHelper.ps1')
. (Join-Path $InternalRoot 'lib\SandwichAutoOrder.ps1')
. (Join-Path $InternalRoot 'lib\Config.ps1')
Write-Log -Level Info -Message '────── Runner started ──────' -Feature 'Runner'
@@ -38,7 +37,23 @@ foreach ($featureKey in $config.features.Keys) {
continue
}
# Per-feature mutex: prevents two concurrent runner instances from executing
# the same feature simultaneously (e.g. if the previous run is still in progress).
$mutexName = "Global\PSAutomation-Feature-$featureKey"
$mutex = $null
$mutexAcquired = $false
try {
$mutex = New-Object System.Threading.Mutex($false, $mutexName)
$mutexAcquired = $mutex.WaitOne(0) # non-blocking: skip if already locked
if (-not $mutexAcquired) {
Write-Log -Level Warn `
-Message "Feature '$featureKey' skipped: another instance is still running." `
-Feature 'Runner'
continue
}
# Dot-source the feature — defines $FeatureMeta and Invoke-Feature in local scope.
# Each iteration overwrites Invoke-Feature, which is fine because we call it immediately.
$ErrorActionPreference = 'Stop'
@@ -61,6 +76,12 @@ foreach ($featureKey in $config.features.Keys) {
}
finally {
$ErrorActionPreference = 'Stop'
if ($mutexAcquired -and $null -ne $mutex) {
try { $mutex.ReleaseMutex() } catch {}
}
if ($null -ne $mutex) {
try { $mutex.Dispose() } catch {}
}
}
}