3

I'm trying to build a script that allows me to open and use OneNote (The store app not OneNote 2016) with a hotkey, but I would like to use the same hotkey to switch the the app from another window. I have accomplished this with many other programs, but never with windows store app. Here is the code I'm trying to use.

#If WinExist("OneNote ahk_class ApplicationFrameWindow", "OneNote")
{
  WinActivate,
}
Else
  Run, C:\Users\ChrisCochrun\Documents\OneNote
#If

Unfortunately it's not detecting that the window exists and it'll only just launch a new instance of onenote. I've looked for answers, but I'm having trouble making it so that AHK actually sees the window already running and jumping to it.

Thanks very much for any help at all!

2 Answers2

1

If the window's title doesn't start with "OneNote", you need to use SetTitleMatchMode 2.

The #If-directive is only used for creating context-sensitive hotkeys and hotstrings.

F1:: ; or a hotkey of your choise
    SetTitleMatchMode 2
    If WinExist("OneNote ahk_class ApplicationFrameWindow", "OneNote")
        WinActivate
    Else
        Run, C:\Users\ChrisCochrun\Documents\OneNote
return
user3419297
  • 9,537
  • 2
  • 15
  • 24
0

rshfit:: 
SetTitleMatchMode 2 
If WinExist("OneNote for Windows 10") 
WinActivate return

;If I use rshift to activate Onenote for Windows 10
Alex
  • 1
  • 1