Focus of Desktop

i have a scenario that i’m trying to automate

i have an application that have a refresh issue and it only refreshes its contents once it goes back to focus
so today we are clicking on the desktop (focusing finder) and then clicking back on the app to cause it to refresh

so i used applescript to do this and i assign it to a keyboard shortcut

Script:

tell application "Finder" to activate

tell application "Final Cut Pro" to activate

my problem is that if i have couple of finder windows open the script is putting them in focus causing them to popup on top on the app and when we do it manually the click on the desktop does not focus the finder windows and they are not popping up. is there a way to make applescript focus only on the desktop?

thanks in advance

Hi, lberezinski. Welcome to MacScripter.

I don’t know of a way to focus specifically on the desktop, but another way to take the focus off the currently frontmost application would be to save the script itself as an application so that it came briefly to the front when it ran. The script would look something like this:

tell me to activate -- This line may not be necessary.
tell application "Final Cut Pro" to activate

I don’t know how effective it would be for your purpose, but it seems worth a try.