MScholtes / PSVirtualDesktop

VirtualDesktop is a Powershell module that provides commandlets to manage virtual desktops of Windows 10.
MIT License
304 stars 18 forks source link

FR: Pin application by process #5

Closed sirAndros closed 3 years ago

sirAndros commented 3 years ago

Hello! Unfortunately, some applications create windows on demand and to pin them you should write watcher to query their windows. I found, that it's possible to get AppIds for process: MSDN. I concern that for some (may be most) apps it may not work, because not all apps are modern and not all Win32 app developers explicitly set app id, but its the same for application windows, used in current implementation of Pin-Application cmdlet, I think. I will create pull request if I found enough time to test it by myself, but I think its not a near future. But if you have some free time - it will be great if you could implement that idea. Thank you!

MScholtes commented 3 years ago

You can query all windows with:

Find-WindowHandle *

With this you can pick the window you need.

Greetings

Markus

sirAndros commented 3 years ago

Indeed, if window already has been created. I describe situation when application already started, but does not have any window until some event (click by tray icon, e.g.)

MScholtes commented 3 years ago

Hello,

I have to admit It took some time for me to understand your request. I guess this could work, I will make some attempts. But it seems to be some coding work since we need a process handle to call.

Greetings

Markus

sirAndros commented 3 years ago

Thank you!

MScholtes commented 3 years ago

Hello,

I made some tests and saw this does not work like hoped. The WinAPI function GetApplicationUserModelId returns an error _APPMODEL_ERROR_NOAPPLICATION for every non modern app.

A fast way to see this is compiling the C++ example on the MSDN web page.

Greetings

Markus

sirAndros commented 3 years ago

Hello, Thank you very much for investigation! It's sad, but as we have workaround it's not terminal. Thanks again for your time!

MScholtes commented 3 years ago

Closed since no response for over 2 weeks