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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃捇 Option to run ColorPickerUI (or other modules) via command line #10593

Open
gaiking-uk opened this issue Apr 5, 2021 · 10 comments
Open
Labels
Area-Runner The PowerToys main executable Idea-Enhancement New feature or request on an existing product Product-Color Picker All things around the Color Picker utility

Comments

@gaiking-uk
Copy link

Hi guys,

Firstly, I would like to start by saying great work developing this great suite of tools/toys. Have been hunting for a decent cross-app colour picker, with a decent UI for years and ColorPickerUI is the best I have come across by far!

The rest of the apps are definitely useful, not suggesting that for a second - however for me personally (given the other apps/utils/scripts I put together over the years), ColorPickerUI is the main/only one I use... I would like to hook into my existing tool/script-set and wondered if there was a way to do this please (e.g. command line to invoke ColorPickerUI, that works even if PowerToys isn't running)?

Again, like I say - not trying to take away from what you guys have built as it's great!.. Just trying to consolidate/integrate parts of PowerToys into my existing config.

Cheers,
Martin 馃憤

@gaiking-uk gaiking-uk added the Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams label Apr 5, 2021
@gaiking-uk gaiking-uk changed the title 馃捇 Option to run ColorPickerUI (or other modules) direct from command line 馃捇 Option to run ColorPickerUI (or other modules) via command line Apr 5, 2021
@crutkas crutkas added Area-Module interface Area of code that works with how modules interact within PowerToys Idea-Enhancement New feature or request on an existing product Area-Runner The PowerToys main executable and removed Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams Area-Module interface Area of code that works with how modules interact within PowerToys labels Apr 5, 2021
@crutkas
Copy link
Member

crutkas commented Apr 5, 2021

putting this as runner but most items are designed to assume the runner (centralized app) is ... running. It actually is what lets us run parts of code not as admin but still be able to invoke when an admin app is in focus.

@martinchrzan-msft
Copy link
Contributor

@martin-zima You can start ColorPickerUI.exe without having PowerToys running (located here - C:\Program Files\PowerToys\modules\ColorPicker\ColorPickerUI.exe)

However you will need PT running if you want to change Color Picker settings, once you change them, PT is not necessary

@gaiking-uk
Copy link
Author

Hi guys thanks both for getting back to me so quickly!

@crutkas -- am afraid am not sure what you mean as a 'runner', is this something I should do to make this work (e.g. a parameter I should set in one of the xml/json files?)

@martinchrzan-msft -- thanks for that, unfortunately it does not seem to work (at least for me).. That was actually my first idea and tried to do that before posting, however when I run <C:\Program Files\PowerToys\modules\ColorPicker\ColorPickerUI.exe> nothing happens - well, the program does run Task Manager shows a 2nd ColorPickerUI.exe process, however no UI appears... I have tried setting the Colour Picker [CP] "Activation Behaviour" to all 3 options (CP with editor, Editor only, CP only) but still can't get any UI / CP window to appear when I run the .exe (which is why I thought maybe I am missing something, like a switch / argument I need to provide, etc)

  1. Is there anything else I can do to get CP to run (in a UI/interactive mode)?
  2. If my experience does not match the expected outcome, and/or you need any further info to help replicate, etc -- please let me know as am more than happy to help!

@martinchrzan-msft
Copy link
Contributor

@martin-zima yeah, running it will not open UI, it will just start a process, which listens to activation shortcut, only once that activation shortcut occurs, it will open UI. I thought that you want to have that, without PT running, but you want to open Color Editor immediately, right? In that case we don't really have a support for such scenario, there is no switch to open editor immediately - however it could be added easily.

@gaiking-uk
Copy link
Author

Hi @martinchrzan-msft -- yes, essentially I was looking for a way to open the ColorPicker UI window (ideally in "CP with editor mode enabled) AS IF I had pressed the activation shortut, but in reality I triggered it through some other means, such as command line, etc.

... Ultimately, over the years I have put together my own mini suite of tools/scripts to help my day-to-day work. (One example is a custom tray icon with a right click menu that launces various apps). It would be great if I could intergrate ColorPickerUI into my own existing toolset, but need someway to load the ColorPicker UI without the activation shortcut.

If you can implement this, that would be great!... I will look out for this feature in hopefully the not-to-distant future (I realise this is not top of your list and you are working on other fixes/enhacements, but if it is any easy thing to add, hopefully it can be sneaked into a release sometime soon).

NB: In terms of solution requirements - I wasn't particularly looking to bypass PowerToys, like I say, I respect the great work you guys have done building this app... that said, I confess that I basically run PT just to use CP, so if there was a way to initialise CP Editor without needing needing to always have PT running, that would possibly be better for me - thanks!

@martinchrzan-msft
Copy link
Contributor

@martin-zima Not sure how much you want to hack, but you can build it by yourself by just adding this code at the end of MainViewModel constructor (src\modules\colorPicker\ColorPickerUI\ViewModels\MainViewModel.cs)

var args = Environment.GetCommandLineArgs();
if (args.Length == 2 && args[1] == "openEditor")
{
    _appStateHandler.ShowColorPickerEditor();
}

It will open editor if you start ColorPickerUI.exe with parameter "openEditor"

Otherwise it is up to @crutkas to prioritize this feature

@gaiking-uk
Copy link
Author

Awesome, thanks! 馃憤馃徏

I will give it a try and let you know how I get on later (I mainly use VS code, but it was complaining when I tried to build the project so will install Visual Studio and see if I have more luck there).

@crutkas crutkas added the Product-Color Picker All things around the Color Picker utility label Apr 9, 2021
@gaiking-uk
Copy link
Author

UPDATE: Thanks for your help @martinchrzan-msft but ufortunately I am still struggling to get the code to compile on my system ( 鹿 further info at end of message, if desired)...

The main error I was getting was:
'AppStateHandler.ShowColorPickerEditor()' is inaccessible due to its protection level
Updated file: MainViewModel.cs.txt (in case I mis-understood your instructions)

I was getting other errors too, but TBH am assuming it is down to my lack of familiarity with VS / the code, so (unless there is something quick/obvious I have done wrong), I will probably have to leave my attempts to update the file myself here, and wait for you guys to include this in an upcoming release.

Thanks again for your help your help anyway!


鹿 FYI - Steps followed in trying to build the solution...

  1. I installed VS 2019
  2. Cloned the repository
  3. Installed the recommended additional VS 2019 compontents
  4. Restored nuget packages
  5. Set build confid to Release, x64
  6. Build PowerToys solution (failed)
  7. Build ColorPicker solution (failed)

@CombeeMike
Copy link

I'm also looking for a way to directly open color picker from cmd line without changing the activation behavior to Open editor. Ideally it would be possible to set the selected color form some cmd line argument as this would allow me to "work around" my feature requests #17335 and #17333 with some AHK script or something the like.

@s-oram
Copy link

s-oram commented Oct 27, 2022

Great work on the powertoys bundle. Like the other commenters here, I would also find the ability to open the color picker UI via a command line useful as I use Keypirinha to launch applications. Like the OP I will also write small scripts and tools to help with my day to day work. Keypirinha makes that kind of thing easy.

Thanks again for the great set of tools!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Runner The PowerToys main executable Idea-Enhancement New feature or request on an existing product Product-Color Picker All things around the Color Picker utility
Projects
None yet
Development

No branches or pull requests

5 participants