最近,这种情况开始发生了。
我需要非常快速地在“日期编辑”和“标题”之间切换对笔记进行排序,因此我经常按下“cmd+”键,然后按下“向下箭头”,使用“enter”和“escape”进行选择。现在该窗口已打开,但它没有焦点,我无法仅使用键盘切换设置。与“tab”的组合也不起作用 - 使用“tab”循环控制或使用“cmd+tab”或“alt+tab”从某个隐藏窗口切换。我已关闭所有应用程序,因此不会干扰其他应用程序。
所以我想到的是——捕捉具有该焦点的对象。
如何在 Apple MacOS 中检测当前活动窗口?
答案1
我找到了一个解决方案。相应地更改“mySort”:
set sort1 to "Date Edited"
set sort2 to "Date Created"
set sort3 to "Title"
set mySort to sort1
tell application "System Events"
tell application process "Notes"
set frontmost to true
keystroke "," using command down
delay 1
tell window "Preferences"
#click static text "Sort notes by:" of group 1
#set winstuff to entire contents of every group
delay 0.5
click pop up button 3 of group 1 of window "Preferences" of application process "Notes" of application "System Events"
delay 0.1
click menu item mySort of menu 1 of pop up button 3 of group 1 of window "Preferences" of application process "Notes" of application "System Events"
delay 0.1
keystroke "w" using command down
end tell
end tell
end tell