Applescript 显示 Apple 菜单栏项目 [英] Applescript to show Apple menu bar items

查看:41
本文介绍了Applescript 显示 Apple 菜单栏项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Applescript 新手.我想知道 Applescript 以显示来自任意应用程序的 Apple 菜单栏项目(但原始应用程序应保留许多栏).

I am an Applescript newbie. I want to know Applescript to show the Apple menu bar items from an arbitrary application (but the many bar should remain for the orginal application).

我尝试了以下脚本,将 Finder 用作一种虚拟应用程序,但没有奏效.

I tried the following script, using Finder as a kind of dummy app, but it did not work.

tell application "System Events"
    tell process "Finder"
        tell menu bar 1
            click menu bar item "Apple"
        end tell
    end tell
end tell

有人可以帮忙吗?

PS-1:我想知道这是因为 Control-F2 将焦点移动到菜单栏通常不起作用,如以下链接中所述:https://apple.stackexchange.com/问题/12723/control-f2-move-focus-to-menu-bar-only-works-occasionally

PS-1: I want to know this because Control-F2 to move focus to menu bar often does not work, as reported in the following link: https://apple.stackexchange.com/questions/12723/control-f2-move-focus-to-menu-bar-only-works-occasionally

PS-2:我尝试发布图片,但不允许.

PS-2: I tried to post an image, but not allowed.

推荐答案

process 1 where frontmost is true 获取最前面的进程:

tell application "System Events" to tell (process 1 where frontmost is true)
    click menu bar item 1 of menu bar 1
end tell

尽管在全屏窗口中单击菜单栏项不起作用.如果系统事件几分钟没有使用,它会自动关闭,再次打开时会有短暂的延迟.

Clicking menu bar items doesn't work in full screen windows though. And if System Events is not used for a few minutes, it closes automatically, and there's a short delay when it's opened again.

这篇关于Applescript 显示 Apple 菜单栏项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆