Skip to content
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

[Run] Option to change/remember the search window location/position #4576

Open
leumas1104 opened this issue Jun 29, 2020 · 14 comments
Open

[Run] Option to change/remember the search window location/position #4576

leumas1104 opened this issue Jun 29, 2020 · 14 comments
Labels
Area-User Interface things that regard UX for PowerToys Help Wanted We encourage anyone to jump in on these and submit a PR. Idea-Enhancement New feature or request on an existing product Planning-Consideration Consideration for 2021 stability release Priority-3 Bug that is low priority Product-PowerToys Run Improved app launch PT Run (Win+R) Window
Milestone

Comments

@leumas1104
Copy link

leumas1104 commented Jun 29, 2020

I would like to be able to change the position of PowerToys Run search window

I think a search function in the middle of the screen is never a good idea. The user should be able to freely access the desktop while searching. The feature I would add, would allow the user to pick a permanent location on their screen for the search window to appear. Giving the user more customization.
-->

Simply using the same mechanic used with custom FancyZone selection would suffice.

In the powerToys settings under 'PowerToys Run' the user can click a 'Customize search bar location' button. When clicked they can move a grey box representing the search bar to any position on the desktop.
-->

@ghost ghost added the Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams label Jun 29, 2020
@saahmedm saahmedm added Idea-Enhancement New feature or request on an existing product Help Wanted We encourage anyone to jump in on these and submit a PR. labels Jun 29, 2020
@saahmedm saahmedm added this to the Suggested Enhancements milestone Jun 29, 2020
@saahmedm
Copy link
Contributor

this is a good idea @leumas1104, we directly mentioned this in our spec and didn't get an community feedback so it is not priority for v1 right now.

However, I added the "help wanted" tag as we'd love to see the community get involved here

@htcfreek
Copy link
Collaborator

Related to #1607.

@stefan-schweiger
Copy link

stefan-schweiger commented Jul 7, 2020

In addition to this, I would like the option to "Remember last position". Because you can currently drag the overlay around but the next time it is at the default position again. macOS handles the positioning like this and it always seemed intuitive enough for me.

EDIT: After digging around in the source code a bit it seems like the option is already there "RememberLastLaunchLocation" but there is no GUI for actually changing it.

EDIT2: You can acutally change the setting. You need to exit PowerToys, then change the setting in %homepath%\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Settings.json and start PowerToys again.

It would be great to also have this option configurable in the GUI. But as far as I can tell the settings are done in C++ which is not my area of expertise

@saahmedm saahmedm removed the Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams label Jul 8, 2020
@crutkas crutkas added the Product-PowerToys Run Improved app launch PT Run (Win+R) Window label Dec 31, 2020
@crutkas crutkas added Planning-Consideration Consideration for 2021 stability release Priority-3 Bug that is low priority labels Dec 31, 2020
@enricogior enricogior changed the title Changing PowerToys Run search window location. [Run] Option to change the search window location Jan 9, 2021
@enricogior enricogior changed the title [Run] Option to change the search window location [Run] Option to change/remember the search window location/position Jan 9, 2021
@enricogior
Copy link
Contributor

Related to #1607

@stefan-schweiger
Copy link

@enricogior how are those two related? Just because someone mentioned the setting name in a comment? Those are still different functionalities in my opinion.

@enricogior enricogior reopened this Feb 4, 2021
@enricogior
Copy link
Contributor

@stefan-schweiger
I closed it by mistake.

@hrko
Copy link

hrko commented Apr 25, 2022

EDIT: After digging around in the source code a bit it seems like the option is already there "RememberLastLaunchLocation" but there is no GUI for actually changing it.

EDIT2: You can acutally change the setting. You need to exit PowerToys, then change the setting in %homepath%\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Settings.json and start PowerToys again.

In my case, changing the settings in Settings.json did not work, but PowerToysRunSettings.json in the same directory did. I hope this will be helpful to those who want to enable the feature until this issue resolved.

@nfind
Copy link

nfind commented Jan 31, 2023

EDIT: After digging around in the source code a bit it seems like the option is already there "RememberLastLaunchLocation" but there is no GUI for actually changing it.
EDIT2: You can acutally change the setting. You need to exit PowerToys, then change the setting in %homepath%\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Settings.json and start PowerToys again.

In my case, changing the settings in Settings.json did not work, but PowerToysRunSettings.json in the same directory did. I hope this will be helpful to those who want to enable the feature until this issue resolved.

Hi, this worked for me as-well. However I regognized that this will save the position only until the next reboot of the PC. After a reboot you have to drag Powertoy Run once again to the desired screen position and then it is saved.

Can someone verify this behaviour or is it just buggy more me?

@Anant-mishra1729
Copy link

EDIT: After digging around in the source code a bit it seems like the option is already there "RememberLastLaunchLocation" but there is no GUI for actually changing it.
EDIT2: You can acutally change the setting. You need to exit PowerToys, then change the setting in %homepath%\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Settings.json and start PowerToys again.

In my case, changing the settings in Settings.json did not work, but PowerToysRunSettings.json in the same directory did. I hope this will be helpful to those who want to enable the feature until this issue resolved.

Hi, this worked for me as-well. However I regognized that this will save the position only until the next reboot of the PC. After a reboot you have to drag Powertoy Run once again to the desired screen position and then it is saved.

Can someone verify this behaviour or is it just buggy more me?

Yes, still in 2023 same issue...
After every reboot power toys run returns to its previous location.

@github-project-automation github-project-automation bot moved this to ⚠️Needs Walkthrough in 3. Help Wanted Mar 22, 2024
@jazzydog
Copy link

A issue been through four years now.

@FilipeBento
Copy link

Hi, everyone! Any news on this? Any plans to develop this in 2025?

When I try to compare the results from Run with something else on the screen the Run app stays on top, completely blocking the visibility on the underlying data. Ability to drag and drop it would be a great quality-of-life improvement. I unfortunately don't know how to code this.

Thank you all for your excellent work in PowerToys! ❤

@e-t-l
Copy link
Contributor

e-t-l commented Jan 31, 2025

EDIT: After digging around in the source code a bit it seems like the option is already there "RememberLastLaunchLocation" but there is no GUI for actually changing it.
EDIT2: You can acutally change the setting. You need to exit PowerToys, then change the setting in %homepath%\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Settings.json and start PowerToys again.

In my case, changing the settings in Settings.json did not work, but PowerToysRunSettings.json in the same directory did. I hope this will be helpful to those who want to enable the feature until this issue resolved.

Hi, this worked for me as-well. However I regognized that this will save the position only until the next reboot of the PC. After a reboot you have to drag Powertoy Run once again to the desired screen position and then it is saved.
Can someone verify this behaviour or is it just buggy more me?

Yes, still in 2023 same issue... After every reboot power toys run returns to its previous location.

It might be as simple as figuring out where the window position is cached and writing that value to the json so it persists through reboots. Can anyone figure out (or could any helpful dev weigh in) what part of the code manages RememberLastLaunchLocation?

@e-t-l
Copy link
Contributor

e-t-l commented Jan 31, 2025

Update: so it's pretty obviously this:

private void OnLocationChanged(object sender, EventArgs e)
{
if (_settings != null && _settings.RememberLastLaunchLocation)
{
_settings.WindowLeft = Left;
_settings.WindowTop = Top;
}
}
private Screen GetScreen()
{
ManagedCommon.StartupPosition position = _settings.StartupPosition;
switch (position)
{
case ManagedCommon.StartupPosition.PrimaryMonitor:
return Screen.PrimaryScreen;
case ManagedCommon.StartupPosition.Focus:
IntPtr foregroundWindowHandle = NativeMethods.GetForegroundWindow();
Screen activeScreen = Screen.FromHandle(foregroundWindowHandle);
return activeScreen;
case ManagedCommon.StartupPosition.Cursor:
default:
return Screen.FromPoint(System.Windows.Forms.Cursor.Position);
}
}

which references this:

public bool RememberLastLaunchLocation { get; set; }

so... I'm really a very amateur coder and have never taken a cs class, but it seems like we just need to create new values like "WindowPositionX" and "WindowPositionY" in the Settings.json and write the position values to it. Just not sure how to do that part.

.

.

(In fact, there are already values "WindowTop" and "WindowLeft" that seem like they should serve this function, yet don't seem to change even when I move the window, nor does the window position change if I try reassigning the values and restarting.)

internal StringMatcher.SearchPrecisionScore QuerySearchPrecision { get; private set; } = StringMatcher.SearchPrecisionScore.Regular;
public double WindowLeft { get; set; }
public double WindowTop { get; set; }

private void UpdatePosition()
{
if (_settings.RememberLastLaunchLocation)
{
Left = _settings.WindowLeft;
Top = _settings.WindowTop;
}
else
{
MoveToDesiredPosition();
}
}

...wait I might actually be figuring this out. Check out here:

// Not called on first launch
// Called when window is made visible by hotkey. Not called when the window is deactivated by clicking away
UpdatePosition();
BringProcessToForeground();
^This is the only time UpdatePosition() is called, and it's explicitly noted that it doesn't fire on first launch. So that would be the first thing to change. Although I'm still not sure why the "WindowTop" and "WindowLeft" values don't seem to do anything when I try to force them to change....

Would really appreciate the input of someone more knowledgeable than me!

@e-t-l
Copy link
Contributor

e-t-l commented Jan 31, 2025

(In fact, there are already values "WindowTop" and "WindowLeft" that seem like they should serve this function, yet don't seem to change even when I move the window, nor does the window position change if I try reassigning the values and restarting.)

Messed around with it a bit more and I think what's happening is that the json gets loaded into memory when the program launches, and since WindowTop and WindowLeft don't get read on first launch, they get overwritten by the (default center-screen) window position when it first launches. But these values don't actually get written to the json file until Powertoys next quits, for some reason.

So to fix this, I think literally the only thing we need to do (besides making a GUI switch for RememberLastLaunchLocation) is to make UpdatePosition() fire on PowerLauncher's first launch. ...I still don't know how to do that though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface things that regard UX for PowerToys Help Wanted We encourage anyone to jump in on these and submit a PR. Idea-Enhancement New feature or request on an existing product Planning-Consideration Consideration for 2021 stability release Priority-3 Bug that is low priority Product-PowerToys Run Improved app launch PT Run (Win+R) Window
Projects
Status: ⚠️Needs Walkthrough
Development

No branches or pull requests