AppleScript:在Safari Windows之间切换?

发布于 2025-01-22 13:55:34 字数 381 浏览 3 评论 0原文

如果我打开了两个Safari Windows,则每个标签只有一个选项卡,如何将AppleScript随意切换到任何一个Windows?或换句话说,在它们之间切换。

我尝试过,激活窗口1(或第一个窗口),激活窗口2(或第二个窗口),只能激活第一个窗口。

我尝试了打开窗口1等,不存在打开。

我尝试使用系统事件,单击菜单栏1选项,以为菜单栏2是窗口2,而无效。

我尝试在特定的选项卡上显示do javaScript,该页面无法正常工作。

最终,我确实弄清楚了我可以使用键盘快捷键,但是我想看看是否有更多的“香草” applescript方式。

If I have two safari windows open, just one tab in each, how do I get applescript to switch to either of the windows at will? Or in other words, toggle between them.

I tried, activate window 1 (or, the first window), and activate window 2 (or the second window), only ever activates the first window.

I tried open window 1 etc, open doesn't exist.

I tried using the system events, click menu bar 1 option, thinking maybe menu bar 2 was for window 2, didn't work.

I tried making do javascript on a specific tab show that page, couldn't get that to work.

Ultimately I did figure out I could use a keyboard shortcut, but I wanted to see if there was a more 'vanilla' applescript way.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

卸妝后依然美 2025-01-29 13:55:34
  • 如果窗口不是全屏(在不同的空间中),只需更改窗口的index

     告诉应用程序“ Safari”
          设置窗口2到1的索引
      结束
     
  • 如果窗口在不同的空间中,则必须通过使用执行键盘来切换空格。系统事件。美国键盘上的默认值是⌃←

     告诉应用程序“系统事件”
          密钥代码123使用(控制)
      结束
     

    和⌃→

     告诉应用程序“系统事件”
          密钥代码124使用(控制)
      结束
     
  • If the windows are not full screen (in different spaces) just change the index of the window

      tell application "Safari"
          set index of window 2 to 1
      end tell
    
  • If the windows are in different spaces you have to switch the spaces by executing the keystrokes with System Events. The default values on the US keyboard are ⌃←

      tell application "System Events"
          key code 123 using (control down)
      end tell
    

    and ⌃→

      tell application "System Events"
          key code 124 using (control down)
      end tell
    
烟酉 2025-01-29 13:55:34

当我这样做时,

tell application "Safari"
  set index of window 2 to 1
end tell

出现的新窗口被冻结了。我这样解决了这个问题

    tell application "Safari"
    set theWindows to windows
    set win2 to item 2 of theWindows
    tell win2
        set visible to false
        set visible to true
        set index to 1
    end tell
    activate
end tell

When I do just this

tell application "Safari"
  set index of window 2 to 1
end tell

The new window that shows up is frozen. I fixed this by doing this

    tell application "Safari"
    set theWindows to windows
    set win2 to item 2 of theWindows
    tell win2
        set visible to false
        set visible to true
        set index to 1
    end tell
    activate
end tell
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文