0
votes

I am running apple script. My problem is that i am opening a safari window using apple script. After that I am hiding it using script tell application "System Events" to tell process "Safari" to set visible to false

Now I want that my leftover script should run on that safari window which is hidden, but when i hide safari window then the focus to the safari is lost and the script starts running on the application that has focus instead of safari window.

Can we do this? Please tell the solution if we can.Any help is appreciated.

Thanks.

3
Use a 'tell application "Safari" - block to talk to Safari.app - - user1804762
Can you give me an example. - UserNew
Basically it's this: put all the code that belongs to Safari in a 'tell application "Safari" ... [ your code ] end tell - block. - user1804762

3 Answers

0
votes

What are you trying to do with the window? If I hide Safari with an open window, I can still access the window using the normal tell block, like

tell application "Safari"
    set bounds of window 1 to {111, 222, 777, 666}
end tell

with no problem. But perhaps you are using System Events, which may not be necessary (and possibly bad practice) but it depends on what you're trying to do. Check Safari's dictionary, and post example code.

0
votes

try this

tell application "System Events" to set visible of process "Safari" to false
0
votes

This worked for me:

tell application "Safari"
activate
delay 1
tell application "System Events" to set visible of process "Safari" to false