Applescript/Bashscript激活后台运行的匿名google chrome
我知道如何在Incogito模式下打开google chrome:Applescript/Bashscript激活后台运行的匿名google chrome,bash,macos,applescript,Bash,Macos,Applescript,我知道如何在Incogito模式下打开google chrome: /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --incognito 我还发现了如何关闭匿名谷歌浏览器: tell application "Google Chrome" close (every window whose mode is "incognito") end tell 也来自 使用上述脚本,我尝试了以下操作: tell ap
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --incognito
我还发现了如何关闭匿名谷歌浏览器:
tell application "Google Chrome"
close (every window whose mode is "incognito")
end tell
也来自
使用上述脚本,我尝试了以下操作:
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
但这并没有激活不知名的google chrome,而是激活了正常模式的google chrome
我在运行普通和匿名的Chrome。
(incognito正在播放歌曲,并使用普通chrome)
在运行正常模式google chrome时,我们如何激活匿名google chrome
更新
借鉴
我明白了:
tell application "System Events" to tell process "Google Chrome"
perform action "AXRaise" of window 2
set frontmost to true
end tell
但这杀死了第二个谷歌浏览器,我需要激活隐姓埋名,
即使可能有多个正常的谷歌色度在运行
相关链接:
我希望在理解了以下内容后,能够正确地解释您的情况:
- 你正在运行一个单一的Google Chrome实例,它有几个打开的窗口,其中至少有一个处于匿名模式李>
- 您希望将应用程序焦点切换到Google Chrome,但您尝试的方法通常将普通窗口置于前台,而将匿名窗口置于后台李>
- 你希望切换到Google Chrome,本质上是做相反的事情,那就是把匿名的窗口放在前面,让普通的窗口保持打开,但在后面
tell application "Google Chrome"
activate
set index of (every window whose mode is "incognito") to 1
end tell
系统信息:AppleScript版本:“2.7”,系统版本:“10.13.6”
activate
命令实现了您所期望的功能,并将焦点转移到了Google Chrome的普通窗口上。下一行将每个匿名窗口的索引设置为1,将前面的索引替换为后面的索引。因此,这一过程的自然结果是,普通车窗最终位于后部
令人惊讶的是,Google Chrome以无缝方式(在常规条件下)执行这两个命令。因此,没有可观察到的闪烁或可见的窗口重新排列:在Google Chrome进入前台的同时,出现在最前面的“隐姓埋名”窗口
我不会保证所有系统都会出现这种情况,或者有大量打开的窗口。但是,在我相当低规格的Macbook 12“上,当用4个普通窗口和4个不知名窗口测试时,开关是流动的
我认为incognito窗口的顺序最终与原来相反,但是如果保持相对顺序很重要,那么您可以简单地执行两次set index…
命令,这将颠倒顺序。然而,当我们从前面的incognito切换时,这确实会产生最小的可见转换把窗户放在后面
tell application "Google Chrome"
activate
set index of (every window whose mode is "incognito") to 1
end tell