Page 2 of 2

Re: [solved] How to detect Calculator on Windows 10

Posted: 19 Aug 2019, 17:00
by mkanet
Would someone please be kind enough to provide a working example to detect the OneNote UWP app? Im trying to activate/restore a minimized OneNote (UWP) app. I tried replacing the process name with "onenoteim.exe" in the example provided in this thread that's supposed to be working, but the app is still not detected. When searching on google, there seems to be very little information for manipulating UWP apps on Windows using AutoHotKey; even though these apps have been around for years.

Re: [solved] How to detect Calculator on Windows 10

Posted: 19 Aug 2019, 19:51
by GollyJer
It's definitely not easy to work with these type of apps.

For OneNote I've simply using this command.

Code: Select all

Run, % "onenote:"
It will open OneNote if it's closed and bring it to the foreground if it's minimized or in the background. Working with OneNote beyond that is pretty hard though.

Re: [solved] How to detect Calculator on Windows 10

Posted: 20 Aug 2019, 21:50
by mkanet
Thanks for the reply back. Actually Run, % "onenote:" starts the obsolete Win32 version of OneNote (aka OneNote 2016), not the UWP version. I can launch the UWP version of this app via the below command-line; however, I don't know how to restore it from a minimized state using AHK.

Code: Select all

explorer "shell:appsFolder\Microsoft.Office.OneNote_8wekyb3d8bbwe!microsoft.onenoteim"
I can even resize and position the app using AHK (after I launch it using the above Windows command-line).
GollyJer wrote:
19 Aug 2019, 19:51
It's definitely not easy to work with these type of apps.

For OneNote I've simply using this command.

Code: Select all

Run, % "onenote:"
It will open OneNote if it's closed and bring it to the foreground if it's minimized or in the background. Working with OneNote beyond that is pretty hard though.

Re: [solved] How to detect Calculator on Windows 10

Posted: 21 Aug 2019, 03:43
by lexikos
Can OneNote 2016 be removed?

On my system onenote: launches the UWP app or restores it if minimized. But I am on an Insider build (18362.10012) and do not have any other version of OneNote installed.

You can probably choose which OneNote app is associated with the onenote: "protocol" by opening Settings, Default apps, Choose default applications by protocol, and finding "ONENOTE".

If you want to restore the minimized OneNote window, you just need to identify it correctly. Onenoteim.exe creates at least two windows, both "visible", but you can only see one of them. You can confirm which window a given WinTitle matches by using commands like WinGetTitle, WinGetClass and WinGet ID. To be more specific with the WinTitle, you can get details from Window Spy.

For instance, there were multiple examples with Calculator ahk_class ApplicationFrameWindow earlier in this thread. This window class is common to all UWP apps, and generally indicates an actual window the user can interact with.
GollyJer wrote:Maybe multiple criteria in WinExist is new since this post was created?
Nope.

Re: [solved] How to detect Calculator on Windows 10

Posted: 07 Sep 2019, 00:07
by mkanet
Thank you so much for the tip. You were right, I had to point the Win10 association protocol to the UWP version of the app. onenote: takes care of the only issue I had!

I didn't see a way to uninstall the OneNote 2016 app. I'm guessing that it will automatically be removed when Office is updated to the next version on my machine.
lexikos wrote:
21 Aug 2019, 03:43
Can OneNote 2016 be removed?

On my system onenote: launches the UWP app or restores it if minimized. But I am on an Insider build (18362.10012) and do not have any other version of OneNote installed.

You can probably choose which OneNote app is associated with the onenote: "protocol" by opening Settings, Default apps, Choose default applications by protocol, and finding "ONENOTE".

If you want to restore the minimized OneNote window, you just need to identify it correctly. Onenoteim.exe creates at least two windows, both "visible", but you can only see one of them. You can confirm which window a given WinTitle matches by using commands like WinGetTitle, WinGetClass and WinGet ID. To be more specific with the WinTitle, you can get details from Window Spy.

For instance, there were multiple examples with Calculator ahk_class ApplicationFrameWindow earlier in this thread. This window class is common to all UWP apps, and generally indicates an actual window the user can interact with.
GollyJer wrote:Maybe multiple criteria in WinExist is new since this post was created?
Nope.