microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
106.43k stars 6.27k forks source link

Distraction Dimmer - Haze Over / dim all but #13035

Open YoussefRaafatNasry opened 2 years ago

YoussefRaafatNasry commented 2 years ago

Description of the new feature / enhancement

A tool like HazeOver to dim inactive windows, to help reduce distraction and increase focus.

Example

Scenario when this would be used?

Supporting information

I found a windows alternative called LeDimmer, but it's abandoned and not open-source. It also lacks a lot of options.

crutchcorn commented 2 years ago

I'm interested in contributing this tool to the project and would be happy to champion development on it. I'm currently doing some exploratory looks into what APIs we'd use for this

franky920920 commented 2 years ago

I'm interested in contributing this tool to the project and would be happy to champion development on it. I'm currently doing some exploratory looks into what APIs we'd use for this

If you would like to contribute to PowerToys, we can discuss it here and you can start working on this :)

cc: @crutkas

crutchcorn commented 2 years ago

Some initial thoughts, as I'm unfamiliar with what hooks Windows might have to achieve this:

1) Do we simply get the window borders and draw around them to create a dimming effect? Will this be performant enough on low-powered devices to create a good experience? 2) Alternatively, how does Windows handle drawing in terms of layering. Like, is there a z-index equivalent on Windows that would let me draw n-1 overlay to create the effect? 3) It seems like this repo has split C# and CPP code - Does the PowerToys folks have preference one way or the other? I was leaning CPP, simply because FancyZones seems to be using it, and I suspect some codesharing might be able to occur there EDIT: Apologies, it seems to be pretty clearly in favor of CPP per the style guide

Something I wanna test: I want to make sure multi-monitor support is handled OOTB - since this is a big part of the feature for me

Aaron-Junker commented 2 years ago

Some initial thoughts, as I'm unfamiliar with what hooks Windows might have to achieve this:

  1. Do we simply get the window borders and draw around them to create a dimming effect? Will this be performant enough on low-powered devices to create a good experience?
  2. Alternatively, how does Windows handle drawing in terms of layering. Like, is there a z-index equivalent on Windows that would let me draw n-1 overlay to create the effect?
  3. ~It seems like this repo has split C# and CPP code - Does the PowerToys folks have preference one way or the other? I was leaning CPP, simply because FancyZones seems to be using it, and I suspect some codesharing might be able to occur there~ EDIT: Apologies, it seems to be pretty clearly in favor of CPP per the style guide

Something I wanna test: I want to make sure multi-monitor support is handled OOTB - since this is a big part of the feature for me

@crutchcorn I saw you started working on this. I will add the in progress label for you, if this is ok.

crutkas commented 2 years ago

This is actually #9496

crutkas commented 2 years ago

but lets move that here as this has more info.

crutkas commented 2 years ago

I would suggest creating a POC that is outside powertoys itself so we can test that directly. From there we can talk about implementation back in. Trust me on so many levels this will be easier :)

Pick either C++ or C#

Aaron-Junker commented 2 years ago

So there are some questions which need clarification:

  1. Do we need a specifiaction for this?
  2. This doesn't seem to fit really in the existing utilities. But I think it's also to small dor a own utility. Any ideas on this?
  3. Personally I think this would be a good feature for the focus sessions in the new Windows 11 clock app. Should we still integrate it?

cc: @dedavis6797 @crutkas

crutkas commented 2 years ago
  1. Make this a different app.
  2. Lets not over think this.
  3. Honestly i think this can just a be a c# app.
  4. We can refactor code as needed.
  5. POC first, integrations later. I don't know what types of hooks the clock app has for integration. I think integration would be nice but lets do a Minimal lovable product

Here is what i'm thinking: @crutchcorn what are your thoughts?

  1. hot key activate when a window is in focus
  2. underlay is invoked.
  3. underlay has color + transparency setting.
    1. would be nice to add mica / acrylic later
  4. Right clicking / double clicking on underlay dismisses it.
  5. Alt-Tab dismisses underlay
  6. game mode can't be activated
crutchcorn commented 2 years ago

Sounds good. I'll try to make it with C# and just do some experimentation. I tried to start with a PowerToys instance, and couldn't even get main or stable building on my end after 3hrs of attempts (I'm not great w/ C# or CPP Windows build tooling, so that's prob on me) so this works out well

Yeah, that makes sense. Ideally, we also have the ability to toggle it on/off from a tray icon as well - although I don't know any other PowerToy that does this

I don't agree about the underlay dismissing it or alt-tab dismissing it entirely, however (at least not without settings).

For example, I do technical content writing and use HazeOver on my laptop to help me focus on writing when I need it. However, I also want to focus on research and quickly switch between the two. It helps a fair bit with my ADHD when I need to go full heads down mode but still need to multitask.

Disabling game mode makes sense to me - although I think that will be a post-POC feature.

crutkas commented 2 years ago

PowerToys itself is a hub and spoke model, every feature is actually a different item and everything reports back to runner / settings but even then, everything is designed to be self contained.

I think once we have something to play with, we can make some further design choices like you said. Some of these were guessing how i may want it to work.

Part of me thinks maybe the alt-tab we may want as a setting but yeah, lets test out a POC like we have with Always on top and the find my mouse recently to see what may need to be refined to hit minimal lovable :)

crutkas commented 2 years ago

@crutchcorn how is it going! would love to see what insanity you whipped up

shayne commented 2 years ago

Wanted to see this happen so I wrote PowerDimmer, a first attempt.

Be nice as I know next to nothing about developing .NET/Win32/etc... Got it working and using it, though! 😄

https://github.com/shayne/PowerDimmer

crutchcorn commented 2 years ago

@shayne is it possible this repo is private? It 404s for me

@crutkas I admittedly haven't yet given it a stab. I was planning on doing so this week, but it seems like @shayne possibly has a strong start. I'm hoping I can help a bit when I can take a look at it :)

shayne commented 2 years ago

Woops! Yeah, public now.

crutkas commented 2 years ago

I will take a look tomorrow!

crutchcorn commented 2 years ago

It works well! (although does have a bug or two I noticed - but the core is definitely there!)

@shayne - is it okay if I submit bug reports and/or PRs to the GH repo? Or would you like me to hold off for now until @crutkas has a chance to look through the code?

shayne commented 2 years ago

Feel free to file the bug in case it's not on my radar. There are a few known issues. I figured I should release it as is since (when you're not trying to break it) it works well. Perhaps some Windows experts can spot the issues instead of me spinning my wheels :)

happiness801 commented 2 years ago

@shayne - Looking good so far! I didn't know LeDimmer existed and I was playing around with PowerToys today and thought it would be nice to have a focus app like this. Hopeful to see this make it into PowerToys soon!

crutchcorn commented 2 years ago

Just wanted to leave confirmation that @shayne's work works extremely well - even for weird multi-monitor and multi-DPI setups like @happiness801 and mine! Thanks again for building it @shayne - it's deeply appreciated

crutkas commented 2 years ago

Tried, this is neat. I think one thing i would want is to quickly toggle on / off entire feature without exiting it.

@shayne, you're thought is to maybe have put this in powertoys? correct? With the item above, this is at what i'd classify as lovable.

shayne commented 2 years ago

i would want is to quickly toggle on / off entire feature without exiting it

Added this as well as an "Active on launch?" setting.

crutkas commented 2 years ago

I think there are two settings.

This IMO would be a good reference for this. At times i need the overlay, others i don't. Some people may want it just fully off. image

shayne commented 2 years ago

@crutkas the activation shortcut is in place. I agree with the "fully off" feature like others in PT. It would make sense to add that feature when integrating my project into PT. Right now it exists as a standalone app.

To answer your previous question, yes I would like to see this in PT. It is a lot less effort to develop and test it standalone. I was waiting for feedback and general support before working on PT integration.

Jay-o-Way commented 2 years ago

Is anybody working on this?

franky920920 commented 2 years ago

@crutchcorn Do you need any help from us?

eduardohilariodev commented 2 years ago

Wanted to see this happen so I wrote PowerDimmer, a first attempt.

Be nice as I know next to nothing about developing .NET/Win32/etc... Got it working and using it, though! 😄

https://github.com/shayne/PowerDimmer

Thanks for this! It's exactly what I was looking for: simple and elegant. Great job!

crutkas commented 1 year ago

@shayne on multiple launches, it fails to run, i like it however.

  1. I think adding the chance for an acrylic / mica underlay would be baller too
  2. Another quirk is elevated apps when it isn't

Both livable

shayne commented 1 year ago

@crutkas curious about the launch failures. I do know it doesn't handle conflicting global keybinds gracefully.

I do use it daily, however I find with Windows 11 I have to restart it to get it to properly layer. It's like the "dim windows" stop ordering correctly.

Any direction would be greatly appreciated.

crutkas commented 1 year ago

@shayne it crashes on 2nd launch for me on

            settings = new ConfigurationBuilder<ISettings>().UseJsonFile("settings.json").Build();
            settings.DimmingEnabled = settings.ActiveOnLaunch;

System.IO.IOException: 'Unable to move the replacement file to the file to be replaced. The file to be replaced has retained its original name.'

davidegiacometti commented 1 year ago

@shayne nice job 😃

I gave it a try and I am also experiencing System.IO.IOException: 'Unable to move the replacement file to the file to be replaced. The file to be replaced has retained its original name.' on 2nd launch that looks related to Config.Net nuget package. On first launch I am randomly experiencing An unhandled exception of type 'System.ExecutionEngineException' occurred in WindowsBase.dll after a few minutes of usage. I have been able to fix the crash converting the Win32.WinEventDelegate to a field. https://github.com/shayne/PowerDimmer/blob/5f1b63ecc359f911159f364e6a8c7211decbe52b/App.xaml.cs#L84

Reference: https://stackoverflow.com/a/56774612

jlcd commented 1 year ago

How is this feature coming along? I noticed @shayne's PowerDimmer repo is a couple years without any improvements, so I assume it is still a PoC?

shayne commented 11 months ago

I use it daily and works for me. Unfortunately, I don't have the bandwidth to bring it into PowerToys.

ca-boh commented 10 months ago

One more vote for this! Absolutely needed for focused work.

viznaut commented 9 months ago

would love to see this as well

ca-boh commented 9 months ago

These guys just release "Crop & Lock" in v0.73. Interesting feature, but really doesn't help much with focus...

...if you are interested, I found CinemaDrape actually does what we need (or something very close to it).

cylkee commented 3 months ago

I'm seeing a lot of 'dim screen' feature requests being duped and referred here, so rather than create a new feature request, I'd like to request an extension of the feature described in this thread please.

Sometimes I find that my screen is just way too bright in some dark situations. I don't want to or cannot turn on another light source to counter-balance the situation, so instead I try to dim my screen, but my graphics driver or Windows will only dim it so far. Pitifully so. Dark Mode at the OS or application level is not a solution either - I find its support is patchy. So instead I use colour inversion in dark settings, in Ease of Access > Colour filters. This is good for me, but even then some elements of the screen (text, UI) can be too bright as to be piercing my eyeballs. My device has a pretty good screen, not gonna lie.

So I'm looking for a Super Dim or Ultra Dim app, and I'm hoping it can graduate to the suite of PowerToys.

I imagine it's just a black layer with an opacity setting (I work with CSS, so that's where my thinking comes from). A dark translucent filter layer that covers the entire screen at the touch of a key combo.

I'd also like the option for this filter to be a light (as in white) filter too (remember I talked about colour inversion).

Loving your work with PowerToys, thank you.

wooonotcool commented 1 month ago

Hello! The dimming feature is super helpful for me especially with the OLED Display of my laptop. Right now, I am using the LeDimmer because the PowerDimmer does not work on my system and in my opinion, adding this feature in PowerToys is a very great idea. I have been using PowerToys for years and it helped me in being productive. Looking forward in new features PowerToys!

MarcinOrlowski commented 1 month ago

Since ticket still opened: PowerDimmer mentioned already works perfectly fine for me on Win11 if one bothers their repo being not too active.

Sugaroverdose commented 1 month ago

Since ticket still opened: PowerDimmer mentioned already works perfectly fine for me on Win11 if one bothers their repo being not too active.

For me it crashed silently a lot, this fork is working pretty much perfectly, but you have to build it yourself

UPD: updated url to specific branch

shayne commented 1 month ago

If they send me a PR I'd be happy to merge it. 🤷‍♂️

Sugaroverdose commented 4 weeks ago

If they send me a PR I'd be happy to merge it. 🤷‍♂️

Author of those fork isn't active for two years, i'm pretty sure that it's completely forgotten

alaseridan commented 3 weeks ago

Someone reached out to me about my PowerDimmer fork... Yep, I totally forgot about it! I just opened a PR that fixes the silent crashes and added dimming/shades to windows and selected areas of windows.