I've searched a lot for this, but all answers talk about how bringing a whole window (or dialogue.. which is still a window really) into focus via
But I couldn't find any way of detecting if a specific UI element was selected, in focus etc.
I'm wrote an apple script that automatically jumps to alfred create custom web search, but the script failed when the features tab wasn't selected by default.. so this is what my code looks like:
tell application "System Events" keystroke "," using command down delay delay_time tell process "Alfred Preferences" delay delay_time -- hack: to ensure that the the "Default results" button isn't selected -- by default, we select another tab first, then select the "features" tab click button "Appearance" of toolbar 1 of window 1 click button "Features" of toolbar 1 of window 1 delay delay_time UI elements of scroll area 1 of window 1 -- bring the left menu to focus first (see hack above, without hack this would work sometimes only) keystroke tab
I'd much rather not do this nasty hack (which causes the app to flicker rapidly between tabs whenever i call the shortcut).. i'd rather make a simple if else statement.. ideas?