I have a web app on my Mac I created via the new safari 'add to dock' that needs to get refreshed every X minutes (can be done via Command+r or via the menu options)
I can create a macro to do so every X minutes but thats very disruptive since I only know how to do so with focusing the app first.
Is there a way to send a command to the app without it being focused?
Insert Text by Typing action can send keystrokes to an app in the background. See the KM wiki action:Insert Text by Typing [Keyboard Maestro Wiki]
As noted in the wiki this may not work with all apps but it's worth giving it a try!
thx so much @tiffle !!
sounds promising but how would one send a
Command+r by typing (to refresh)
Just type it into the text box in the action
Oops - you can do that with the Type a Keystroke action.
Here's the action (remember to choose your background app!)
Type a Keystroke.kmactions (547 Bytes)
I did not know that action could be sent to a specific app like the keystroke action. This makes it possible to simplify several of my macros. Thanks for sharing!
thx guys and @tiffle
seems like this isnt really working for me
I set the target app and set the keystroke but when the app isnt focused and I try it it seems to do nothing. am I missing anything?
It sounds like when the app is focused it does work. Is that correct?
The KM wiki says
"Note that the system and many applications do not expect to see keystrokes in the background, so how well this solves any given problem will vary depending on the exact circumstances"
so maybe this is one of those times it just won't work?
I'm afraid I'm out of ideas now...
I just tried to do this with Safari and Safari does not respond to ⌘R sent by KM while Safari's in the background.
When I used Fluid to create an app from a web page, the app did respond to the refresh command while in the background.
Since I'm still on Ventura I don't have that "add to dock" function so I can't do further testing but it sounds like the app responds just like Safari when in the background - i.e. not at all.
thx @tiffle , appreciate you insights!
What about explicitly loading the current url of the front Browser? Will that work?
On my end, this has the effect of refresh in that it grabs the current URL and then opens it again in the front browser window in the background.