Add SandwichReminder-AutoOrder feature for automated sandwich ordering and enhance SandwichReminder logic
This commit is contained in:
@@ -36,11 +36,14 @@ ArnePowershellAutomation/
|
||||
│ ├── Config.ps1 # Configuration and state I/O
|
||||
│ ├── Elevation.ps1 # UAC elevation helper
|
||||
│ ├── NetworkUtils.ps1 # DNS suffix detection
|
||||
│ └── ToastHelper.ps1 # Windows 11 toast notifications
|
||||
│ ├── ToastHelper.ps1 # Windows 11 toast notifications
|
||||
│ ├── PromptHelper.ps1 # Multi-choice dialog boxes (up to 4 buttons)
|
||||
│ └── SandwichAutoOrder.ps1 # Browser keyboard automation for sandwich auto-order
|
||||
├── features/ # Automation feature modules
|
||||
│ ├── DynamicLock.ps1 # Toggle Dynamic Lock on network presence
|
||||
│ ├── DefaultBrowser.ps1 # Monitor default browser setting
|
||||
│ └── SandwichReminder.ps1 # Time-based reminder notifications
|
||||
│ ├── SandwichReminder.ps1 # Time-based reminder with snooze options
|
||||
│ └── SandwichReminder-AutoOrder.ps1 # Personal browser automation for sandwich ordering
|
||||
└── data/
|
||||
├── config.json # Feature toggles & settings (auto-seeded)
|
||||
├── state/
|
||||
@@ -123,14 +126,27 @@ Enables/disables Windows Dynamic Lock based on network connectivity.
|
||||
### DefaultBrowser
|
||||
Monitors if your default browser matches expected ProgId (app identifier).
|
||||
- **Settings**: Target ProgId (e.g., "FirefoxURL", "OperaGXStable")
|
||||
- **Logic**: On each run, reads current ProgId; if mismatch, shows toast with link to settings; max once per day
|
||||
- **Logic**: On each run, reads current ProgId; if mismatch, shows a Yes/No dialog; "Yes" opens Windows Settings → Default apps for manual selection; max once per day
|
||||
- **State Tracked**: Last notification date to avoid spam
|
||||
- **Note**: Windows 11 protects the default browser registry key with a hash; the browser cannot be changed programmatically, hence the guided Settings approach
|
||||
|
||||
### SandwichReminder
|
||||
Shows a toast reminder at a specific time on a specific network.
|
||||
- **Settings**: Reminder time (HH:MM), network domain suffix, reminder URL, notification window (±5 minutes)
|
||||
- **Logic**: If on configured network AND current time is within ±5 min of reminder time AND not shown today, display toast with link
|
||||
- **State Tracked**: Last notification date
|
||||
Shows a reminder dialog at a specific time on a specific network with snooze options.
|
||||
- **Settings**: Reminder time (HH:MM), network domain suffix, reminder URL, notification window in minutes
|
||||
- **Logic**: If on configured network AND current time is within window of reminder time AND not shown today, display a 4-choice dialog: Order now / Snooze 15 min / Snooze 1 hour / No
|
||||
- **State Tracked**: Last shown date, snooze-until timestamp
|
||||
- **Auto-order delegation**: If `SandwichReminder-AutoOrder` feature is enabled, selecting "Order now" triggers the automated browser flow instead of just opening the URL
|
||||
|
||||
### SandwichReminder-AutoOrder
|
||||
Personal browser automation feature that drives the sandwich ordering website via keyboard navigation.
|
||||
- **Settings**: Base URL, item ID, browser window title hint, tab counts for each navigation step, delays, calibration mode
|
||||
- **Logic**: Opens the item modal URL, brings the browser window to the foreground (with retry), then sends keyboard inputs to: toggle option checkboxes → click add-to-cart → refresh page → tab to mini-cart → open cart → tab to confirm order button → open delivery popup
|
||||
- **Key settings**:
|
||||
- `tabsToOption1` / `tabsBetweenOptions` / `tabsToAddButton`: navigation within item modal
|
||||
- `refreshBeforeCart`: send F5 after add-to-cart to reset focus to a known page position
|
||||
- `tabsToCartButton` / `tabsToConfirmButton`: navigation after refresh
|
||||
- `calibrationOnly` + `calibrationTabs`: safe mode to manually count tab stops without clicking
|
||||
- **Note**: Uses WScript.Shell SendKeys (best-effort); relies on stable tab order in the target website
|
||||
|
||||
## Usage Guide
|
||||
|
||||
@@ -168,54 +184,6 @@ When you select a feature for configuration, you'll be prompted for each setting
|
||||
- **Type: time** → Enter HH:MM format
|
||||
- Press Enter to accept the displayed default
|
||||
|
||||
## Testing Plan
|
||||
|
||||
### T1 — Basic Logging & Config Load
|
||||
- [ ] Run `.\configure.ps1` → Main menu displays
|
||||
- [ ] Verify `internal/data/config.json` was created (if first run)
|
||||
- [ ] Verify `internal/data/logs/automation-<date>.log` has initialization entries
|
||||
|
||||
### T2 — Feature Discovery & Configuration Menu
|
||||
- [ ] Select menu option 4 (Configure)
|
||||
- [ ] Verify all three features appear (DynamicLock, DefaultBrowser, SandwichReminder)
|
||||
- [ ] Toggle DynamicLock (1) → Verify enabled flag flips in config.json
|
||||
- [ ] Select C1 (configure DynamicLock) → Modify network suffix, save, verify in config.json
|
||||
|
||||
### T3 — Registration & Task Scheduler
|
||||
- [ ] Select menu option 2 (Register)
|
||||
- [ ] If prompted for UAC, approve elevation
|
||||
- [ ] Verify success message and `last-register-result.json` shows success=true
|
||||
- [ ] Open Task Scheduler → Navigate to Library root → Verify "PSAutomation-Runner" task exists
|
||||
- [ ] Right-click task → Properties → Verify "Run as current user" (not elevated), AtLogOn trigger, 2-min repetition
|
||||
|
||||
### T4 — Feature Execution (DynamicLock)
|
||||
- [ ] Register the runner (option 2)
|
||||
- [ ] Enable DynamicLock in configuration menu (option 4)
|
||||
- [ ] Configure DynamicLock network to current network suffix (use `Get-DnsClient` or `ipconfig /all` to find)
|
||||
- [ ] Wait for runner to execute (at next 2-min interval or logon event)
|
||||
- [ ] Check `internal/data/logs/automation-<date>.log` for "DynamicLock" entries
|
||||
- [ ] Verify state.json has updated `isConnected` flag
|
||||
|
||||
### T5 — Feature Execution (DefaultBrowser)
|
||||
- [ ] Enable DefaultBrowser in configuration menu
|
||||
- [ ] Verify toast notification appears (if configured ProgId differs from current default)
|
||||
- [ ] Click "Yes" button on toast → Should open Settings → Default apps
|
||||
- [ ] Check logs for "DefaultBrowser" entries and state.json for `lastShownDate`
|
||||
|
||||
### T6 — Feature Execution (SandwichReminder)
|
||||
- [ ] Enable SandwichReminder in configuration menu
|
||||
- [ ] Configure reminderTime to a time 1–2 minutes in the future (e.g., if current time is 14:35, set to 14:37)
|
||||
- [ ] Configure to current network suffix
|
||||
- [ ] Wait for runner to execute
|
||||
- [ ] Verify toast appears with configured URL
|
||||
- [ ] Check logs for "SandwichReminder" entries and state.json for `lastShownDate`
|
||||
|
||||
### T7 — Error Isolation
|
||||
- [ ] Intentionally break one feature (e.g., edit `internal/features/DynamicLock.ps1`, add invalid syntax)
|
||||
- [ ] Wait for runner to execute
|
||||
- [ ] Verify broken feature logged an error in automation-<date>.log
|
||||
- [ ] Verify other features still executed successfully (logged their own entries)
|
||||
|
||||
## Known Limitations
|
||||
|
||||
- **Default Browser Registry Protection**: On Windows 11, Microsoft protects the default browser registry key with a hash. The DefaultBrowser feature reads the ProgId but cannot *set* the default browser programmatically. The toast provides a link to Settings for manual override.
|
||||
|
||||
Reference in New Issue
Block a user