0

Recently, this started happening.

I need very fast switch sorting my notes between "Date Edit" and "Title" so I lot pressing key "cmd+," then "arrow down", choose with "enter", and "escape". Now that window open but it hasn't focus and I cannot switch setting with keyboard only. Combination with "tab" doesn't work too - cycle control with "tab" or switch from some hidden window with "cmd+tab" or "alt+tab". I have closed all applications so there is no interference with others.

So it came to mind - catch object who has that focus.

How can I detect currently active window in Apple MacOS ?

| improve this question | | | | |
  • In which application are your notes in? I can't find the ability to sort notes in macOS' Notes.app. – oa- Apr 6 '17 at 11:22
  • @oa #notes.app provide sorting in setting "Notes / Preferences / Sort notes by" – BG Bruno Apr 6 '17 at 12:18
0

I've found a solution. Change "mySort" accordingly:

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
| improve this answer | | | | |
  • Nice script @oa thank you - but Q1 how can I run it? - and still does not answer the origin question Q2 How can I detect currently active window? :-) – BG Bruno Apr 7 '17 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.