Skip to content

Minimize to task tray only on auto-start, show window on normal startup#146

Merged
Freeesia merged 2 commits into
masterfrom
copilot/update-minimize-behavior
Oct 22, 2025
Merged

Minimize to task tray only on auto-start, show window on normal startup#146
Freeesia merged 2 commits into
masterfrom
copilot/update-minimize-behavior

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 22, 2025

Summary

This PR implements the feature requested in the issue to differentiate between normal application startup and auto-start behavior. Previously, the application would always minimize to the task tray on startup, which made it difficult to access the main window when launching manually.

Changes

The application now:

  • Shows the main window when launched normally by the user
  • Minimizes to task tray only when launched automatically at Windows startup

This is achieved by:

  1. Adding a --autostart command-line argument that is passed when the application is registered for auto-start
  2. Parsing this argument on startup to determine the launch mode
  3. Conditionally hiding the main window only when the auto-start flag is present

Implementation Details

Files Changed

  • StartupOptions.cs (new): Simple class to hold the auto-start state
  • Program.cs: Parse command-line arguments and register StartupOptions in the DI container
  • MainWindow.xaml.cs: Only hide the window on load if IsAutoStarted is true
  • MainViewModel.cs: Include --autostart argument when registering in Windows startup registry

Example Behavior

Normal Launch:

VdLabel.exe
# Main window is shown

Auto-Start Launch:

VdLabel.exe --autostart
# Main window is hidden (minimized to tray)

Registry Entry:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\VdLabel
Value: "C:\Path\To\VdLabel.exe" --autostart

Testing

The changes maintain backward compatibility:

  • Existing auto-start registry entries without the argument will still be detected as auto-start enabled
  • The argument is case-insensitive for robustness
  • The path is properly quoted to handle spaces in the installation directory

Fixes the issue where users had to manually open the main window from the task tray icon after every manual launch.

Original prompt

This section details on the original issue you should resolve

<issue_title>起動時にタスクトレイに最小化するのは自動起動のときのみにする</issue_title>
<issue_description>* 通常起動時は最小化しない

  • 自動起動登録時に引数を追加して、その引数があった時だけ最小化する</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #145


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
Copilot AI changed the title [WIP] Update minimize behavior for automatic startup Minimize to task tray only on auto-start, show window on normal startup Oct 22, 2025
Copilot AI requested a review from Freeesia October 22, 2025 11:27
@Freeesia Freeesia marked this pull request as ready for review October 22, 2025 11:30
@Freeesia Freeesia merged commit fa7fc54 into master Oct 22, 2025
6 checks passed
@Freeesia Freeesia deleted the copilot/update-minimize-behavior branch October 22, 2025 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

起動時にタスクトレイに最小化するのは自動起動のときのみにする

2 participants