• 1000 поэтому я использовал обходной путь, вызвав Альфреда и используя рабочий процесс, который может открывать определенные c разделы:
https://github.com/kevin-funderburg/alfred-microsoft-onenote-navigator Это кажется немного глупым и, вероятно, наименее эффективным методом для сделай это. Я имею в виду, что если это возможно в рабочем процессе, это должно быть возможно в Applescript, не так ли?
В любом случае мой (очень беспорядочный и неэффективный) сценарий ниже; не стесняйтесь изучать.
tell application "System Events"
set activeApp to name of first application process whose frontmost is true
end tell
if application "Microsoft OneNote" is running then
if "Google Chrome" is in activeApp then
tell application "Google Chrome"
set theTitle to title of active tab of front window
end tell
tell application "Google Chrome"
tell active tab of window 1
set theURL to (get URL)
end tell
end tell
if theTitle contains "YouTube" then
set the clipboard to "? "
set vidNotesSection to "annotations" (* Change this if the section changes *)
tell application "System Events"
keystroke space using command down
delay 0.5
keystroke "one " & vidNotesSection
delay 0.5
keystroke return
end tell
tell application "System Events"
tell process "Microsoft OneNote"
set frontmost to true
end tell
delay 0.5
keystroke "n" using command down
delay 0.5
keystroke "v" using command down
delay 0.1
keystroke theTitle
set the clipboard to theURL
keystroke return
keystroke "v" using command down
delay 0.5
keystroke (key code 125)
keystroke (key code 125)
keystroke (key code 125)
keystroke (key code 125)
keystroke "Notes"
delay 0.1
keystroke "1" using command down
keystroke return
delay 0.1
keystroke "." using command down
end tell
else
set the clipboard to "✏️ "
set webNotesSection to "inbox" (* change this if the section changes *)
tell application "System Events"
keystroke space using command down
delay 0.5
keystroke "one " & webNotesSection
delay 0.5
keystroke return
end tell
tell application "System Events"
tell process "Microsoft OneNote"
set frontmost to true
end tell
delay 0.5
keystroke "n" using command down
delay 0.5
keystroke "v" using command down
delay 0.1
keystroke theTitle
set the clipboard to theURL
keystroke return
keystroke "v" using command down
delay 0.1
keystroke (key code 125)
delay 0.1
keystroke return
end tell
end if
else
tell application "System Events"
if not (exists (window 1 of process "Microsoft OneNote")) then
tell process "Microsoft OneNote"
set frontmost to true
end tell
delay 0.3
keystroke "m" using control down
else
tell process "Microsoft OneNote"
set frontmost to true
end tell
end if
end tell
end if
else if application "Microsoft OneNote" is not running then
if "Google Chrome" is in activeApp then
tell application "Google Chrome"
set theTitle to title of active tab of front window
end tell
tell application "Google Chrome"
tell active tab of window 1
set theURL to (get URL)
end tell
end tell
tell application "Microsoft OneNote"
activate
end tell
repeat until application "Microsoft OneNote" is running
delay 0.1
end repeat
delay 1
if theTitle contains "YouTube" then
set the clipboard to "? "
set vidNotesSection to "annotations" (* Change this if the section changes *)
tell application "System Events"
keystroke space using command down
delay 0.5
keystroke "one " & vidNotesSection
delay 0.5
keystroke return
end tell
tell application "System Events"
tell process "Microsoft OneNote"
set frontmost to true
end tell
delay 1
keystroke "n" using command down
delay 1
keystroke "v" using command down
delay 0.5
keystroke theTitle
set the clipboard to theURL
keystroke return
keystroke "v" using command down
delay 1
keystroke (key code 125)
keystroke (key code 125)
keystroke (key code 125)
keystroke (key code 125)
keystroke "Notes"
delay 0.1
keystroke "1" using command down
keystroke return
delay 0.1
keystroke "." using command down
end tell
else
set the clipboard to "✏️ "
set webNotesSection to "inbox" (* change this if the section changes *)
tell application "System Events"
keystroke space using command down
delay 0.5
keystroke "one " & webNotesSection
delay 0.5
keystroke return
end tell
tell application "System Events"
tell process "Microsoft OneNote"
set frontmost to true
end tell
delay 1
keystroke "n" using command down
delay 1
keystroke "v" using command down
delay 0.1
keystroke theTitle
set the clipboard to theURL
keystroke return
keystroke "v" using command down
delay 0.1
keystroke (key code 125)
delay 0.1
keystroke return
end tell
end if
else
tell application "Microsoft OneNote"
activate
end tell
end if
конец, если