Applescript 显示 Apple 菜单栏项目

编程入门 行业动态 更新时间:2024-10-26 04:23:43
本文介绍了Applescript 显示 Apple 菜单栏项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我是 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/问题/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/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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-17 14:22:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/915932.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:菜单栏   项目   Applescript   Apple

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!