【发布时间】:2018-08-29 21:11:57
【问题描述】:
我知道如何在隐身模式下打开谷歌浏览器:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --incognito
我还找到了如何关闭隐身谷歌浏览器:
tell application "Google Chrome"
close (every window whose mode is "incognito")
end tell
同样来自this link
tell application "Google Chrome"
set incognitoIsRunning to the (count of (get every window whose mode is "incognito")) is greater than 0
end tell
if (incognitoIsRunning) then
say "Shh"
end if
使用上面的脚本我试过这个:
tell application "Google Chrome"
set incognitoIsRunning to the (count of (get every window whose mode is "incognito")) is greater than 0
end tell
if (incognitoIsRunning) then
tell application "Google Chrome" to activate
end if
但这并没有激活隐身谷歌浏览器,它正在激活正常模式的谷歌浏览器。
我正在运行普通和隐身 chrome。 (隐身正在播放歌曲,并在普通 Chrome 上工作)。
如何在正常模式下运行谷歌浏览器时激活incognito google chrome?
更新 借鉴this link的思路
我知道了:
tell application "System Events" to tell process "Google Chrome"
perform action "AXRaise" of window 2
set frontmost to true
end tell
但这会杀死第二个谷歌浏览器,我需要激活隐身, 即使可能有多个正常的谷歌浏览器正在运行。
相关链接:
How to check is Chrome is running in incognito mode using Applescript?
【问题讨论】:
标签: bash macos applescript