-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Do not show CmdPal on startup #38027
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
Conversation
|
Does this result in a cold launch from the Start Menu / taskbar not showing the window? Is there any way for us to differentiate the taskbar launch case from the PT enable case? |
I guess we can pass some dummy arg to CmdPal when starting from PowerToys... |
|
wow I suppose we could add an app execution alias, and then |
|
I tried SW_HIDE, doesn't work :( It's either shown for a second and then hidden or not hidden at all. I guess Window.Activate() overrides it somehow |
|
never mind, I did what you need. Take a look |
| sei.lpFile = appPath.c_str(); | ||
| sei.lpParameters = commandLineArgs.c_str(); | ||
| sei.lpDirectory = dir.c_str(); | ||
| sei.nShow = SW_SHOWNORMAL; |
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.
if we instead stick SW_HIDE in here, and get rid of the arg, and instead get the PInvoke.GetStartupInfo(), can we see if SW_HIDE was set there, and not show the window in that case?
(I feel like I don't really want to add a magic hidden arg to our exe, but I'll accept it for now if it's the only way)
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.
I'll give it a try
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.
doesn't work. even if I pass SW_HIDE when launching, PInvoke says SW_SHOW is there. No idea why
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.
damn. Mmk. We can come up with something more clever in the future. Thanks for taking a look!
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.
Pull Request Overview
This PR updates the CmdPal startup behavior to prevent the window from showing automatically unless launched by PowerToys.
- Introduces a command line argument check in App.xaml.cs for the "RunFromPT" flag to conditionally activate the window.
- Adds an Activate() call in MainWindow.xaml.cs during hotkey processing to ensure the window is brought forward when handling hotkey commands.
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs | Added command line argument logic to conditionally skip window activation on startup. |
| src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs | Added an Activate() call before summoning commands via hotkeys. |
Files not reviewed (1)
- src/modules/cmdpal/CmdPalModuleInterface/dllmain.cpp: Language not supported
Comments suppressed due to low confidence (3)
src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs:70
- [nitpick] Consider renaming 'runFromPT' to a more descriptive name such as 'isLaunchedFromPowerToys' to improve clarity.
bool runFromPT = false;
src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs:73
- Using the magic string "RunFromPT" directly may lead to inconsistencies; consider defining it as a constant.
if (arg == "RunFromPT")
src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs:469
- Verify that invoking Activate() in this context does not conflict with the intended hidden startup behavior, particularly for non-root hotkeys.
Activate();
shuaiyuanxx
left a comment
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.
No issues were found during the test.
moooyo
left a comment
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.
I prefer merge in first. We can use a better implementation in the future.
|
I'm putting notes in here, because #38393 is off the rails I bet we can use this somehow: rather than trying to use the |
Adds a command line arg to not show CmdPal on startup. When starting from PT Run, we won't immediately show the window. as noted in microsoft#37908
Adds a command line arg to not show CmdPal on startup. When starting from PT Run, we won't immediately show the window. as noted in microsoft#37908
Related to #37908