-
Notifications
You must be signed in to change notification settings - Fork 1
Fix: unify autostart to one per-user Run entry #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,8 +84,11 @@ MinVersion=10.0.17763 | |
| Name: "english"; MessagesFile: "compiler:Default.isl" | ||
|
|
||
| [Tasks] | ||
| Name: "autostart"; Description: "Launch {#AppName} when Windows starts (all users)"; \ | ||
| GroupDescription: "Additional options:" | ||
| ; NOTE: autostart is intentionally NOT an install-time task. The daemon owns a | ||
| ; single per-user HKCU\...\Run\FastFlowPrompt entry (Dashboard -> Config -> | ||
| ; "Launch Flowkey when I sign in") -- that's the one source of truth. A prior | ||
| ; machine-wide HKLM task here used a different value name and could run | ||
| ; alongside the per-user one, double-launching the app at logon. See T10/B6. | ||
| Name: "desktopicon"; Description: "Create a desktop shortcut"; \ | ||
| GroupDescription: "Additional options:"; Flags: unchecked | ||
|
|
||
|
|
@@ -160,13 +163,6 @@ Name: "{commondesktop}\{#AppName}"; Filename: "{app}\ahk\AutoHotkey64 | |
| Parameters: """{app}\scripts\grammarFix.ahk"""; WorkingDir: "{app}"; \ | ||
| IconFilename: "{app}\ffp-daemon.exe"; Tasks: desktopicon | ||
|
|
||
| [Registry] | ||
| ; --- Autostart (per-machine HKLM Run) — controlled by the autostart task ----- | ||
| Root: HKLM; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; \ | ||
| ValueType: string; ValueName: "{#AppName}"; \ | ||
| ValueData: """{app}\ahk\AutoHotkey64.exe"" ""{app}\scripts\grammarFix.ahk"""; \ | ||
| Flags: uninsdeletevalue; Tasks: autostart | ||
|
|
||
| [UninstallRun] | ||
| ; --- 1. Stop our processes before removing files ----------------------------- | ||
| ; CloseApplications=force handles in-use files but a windowless daemon | ||
|
|
@@ -177,6 +173,14 @@ Filename: "{sys}\taskkill.exe"; \ | |
| Parameters: "/F /IM AutoHotkey64.exe /FI ""WINDOWTITLE eq grammarFix*"""; \ | ||
| RunOnceId: "KillAhk"; Flags: runhidden waituntilterminated | ||
|
|
||
| ; --- 1b. Remove the per-user autostart entry, if the dashboard toggle or a | ||
| ; source install set it (installer itself never sets it — see [Tasks]). | ||
| ; reg.exe exits non-zero when the value is absent; that's fine, Inno | ||
| ; doesn't treat a nonzero [UninstallRun] exit as fatal. | ||
| Filename: "{sys}\reg.exe"; \ | ||
| Parameters: "delete ""HKCU\Software\Microsoft\Windows\CurrentVersion\Run"" /v ""FastFlowPrompt"" /f"; \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For machines that installed a previous package with the old autostart task selected, upgrading to this installer leaves Useful? React with 👍 / 👎. |
||
| RunOnceId: "RemoveAutostart"; Flags: runhidden waituntilterminated | ||
|
|
||
| ; --- 2. Chain FLM uninstaller — but ONLY if we installed it ------------------ | ||
| ; We tagged it with {app}\.flm_installed_by_us. Pascal helper reads the | ||
| ; QuietUninstallString out of the registry and runs it silently. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| """Drift guard: autostart must have exactly ONE mechanism — the daemon's | ||
| per-user HKCU\\...\\Run entry (ffp_daemon._AUTOSTART_VALUE_NAME), managed by the | ||
| dashboard's "Launch Flowkey when I sign in" toggle. | ||
|
|
||
| Regression: three independent Run-key registrations had drifted out of sync — | ||
| the daemon wrote HKCU\\Run\\FastFlowPrompt, installer/install.ps1 (source | ||
| install) wrote a DIFFERENT value HKCU\\Run\\Flowkey, and installer/installer.iss | ||
| (packaged installer) optionally wrote a separate machine-wide HKLM\\Run\\Flowkey | ||
| via an install-time task. The dashboard toggle only knew about the first, so a | ||
| source or packaged install could register autostart the toggle couldn't see or | ||
| control, and enabling the toggle afterwards added a second, redundant entry — | ||
| launching the app twice at logon. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import re | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| ROOT = Path(__file__).resolve().parents[1] | ||
| SCRIPTS = ROOT / "scripts" | ||
|
|
||
| if str(SCRIPTS) not in sys.path: | ||
| sys.path.insert(0, str(SCRIPTS)) | ||
|
|
||
| import ffp_daemon # noqa: E402 | ||
|
|
||
|
|
||
| def test_install_ps1_uses_the_same_value_name_as_the_daemon(): | ||
| text = (ROOT / "installer" / "install.ps1").read_text(encoding="utf-8") | ||
| m = re.search(r'\$RunKeyName\s*=\s*"([^"]+)"', text) | ||
| assert m, "install.ps1 no longer declares $RunKeyName" | ||
| assert m.group(1) == ffp_daemon._AUTOSTART_VALUE_NAME | ||
|
|
||
|
|
||
| def test_installer_iss_has_no_machine_wide_autostart(): | ||
| text = (ROOT / "installer" / "installer.iss").read_text(encoding="utf-8") | ||
| assert "Tasks: autostart" not in text, "a separate install-time autostart task reappeared" | ||
| assert not re.search(r"Root:\s*HKLM.*\n.*CurrentVersion\\Run", text), \ | ||
| "installer.iss writes an HKLM Run entry — autostart must be per-user (HKCU) only" | ||
|
|
||
|
|
||
| def test_installer_iss_uninstall_cleans_the_same_value_name(): | ||
| text = (ROOT / "installer" / "installer.iss").read_text(encoding="utf-8") | ||
| assert f'/v ""{ffp_daemon._AUTOSTART_VALUE_NAME}""' in text, \ | ||
| "uninstaller doesn't clean up the daemon's actual per-user autostart value" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a user who installed from source with the previous script reruns
installer/install.ps1to upgrade, their HKCU...\Run\Flowkeyvalue is still present. This line makes the script writeFastFlowPromptinstead, but step 5 only adds the new value and never deletesFlowkey, so Windows will launch both commands at sign-in and the dashboard can only toggle the new one. Please migrate/remove the old value before setting$RunKeyNameand in-Uninstall.Useful? React with 👍 / 👎.