如何判断菜单项是否被“选中”?

发布于 2024-08-07 05:05:41 字数 694 浏览 6 评论 0原文

我正在构建一个 Applescript,它将每 X 分钟扫描一次我的网络,检查我家的 Xbox360 或 PS3,并在任一控制台在线时启用我的 Transmission BitTorrent 客户端限速模式。

目前我只能使用 applescript 暂停所有传输或恢复所有传输,因为启动/停止传输有单独的键盘命令。我希望它进入限速模式,而不是完全停止。

我的问题是,限速(海龟)模式与打开/关闭它的键相同。如果有人手动触及速度限制,它将不同步,并且当控制台上线时实际上会关闭速度限制。此外,如果一个控制台上线,速度限制将会开启,但如果另一台控制台上线,速度限制将关闭。

当速度限制处于活动状态时,菜单项会变为“选中”,但我不知道如何对此进行测试。 applescript 字典中没有传输应用程序的任何内容。

如何确定 Applescript 中的菜单项是否已“选中”(甚至显示实际的复选标记)?

[编辑:] 我目前正在尝试弄清楚如何通过 RPC 打开速度限制,而不是尝试使用 GUI 或键盘命令编写脚本,因为开发人员不提供任何 applescript 访问权限。 http://trac.transmissionbt.com/browser/trunk/doc/ rpc-spec.txt

I'm building an Applescript that will scan my network every X minutes, checking for my house's Xbox360 or PS3 and enabling my Transmission BitTorrent client Speed-Limit Mode when either console is online.

Currently I can only Pause all transfers or resume all transfers using applescript, as there are separate key-commands for start/stop transfer. I want it to go into speed-limit mode though, not stop completely.

My issue is that the Speed-Limit (Turtle) mode is the same key to turn it on/off. If anyone touches the speed-limit manually, it will be out of sync and will actually turn speed-limit off when the consoles come online. Also if one console comes online, the speed-limit will come on, but then if the other console comes on, the limit will be turned off.

The menu item becomes 'checked' when the speed-limit is active, but I do not know how to test for this. There was nothing in the applescript dictionary for the transmission app.

How can I determine whether a menu item is 'checked'(It even shows an actual check-mark) in Applescript?

[Edit:] I'm currently trying to figure out how to turn the Speed-Limit on via RPC, rather than trying to script it using the GUI or keycommands, since the developers don't provide any applescript access.
http://trac.transmissionbt.com/browser/trunk/doc/rpc-spec.txt

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

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

发布评论

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

评论(2

蹲在坟头点根烟 2024-08-14 05:05:41

我遇到了完全相同的问题,最后弄清楚如何检查是否选中了传输的速度限制菜单项(并且您可以轻松修改它以检查其他应用程序中的菜单项)。这已经死了快一年了,但希望这会有所帮助。

tell application "Transmission" to activate

tell application "System Events"
    tell process "Transmission"
        set speedLimitCurrentlyOn to (value of attribute "AXMenuItemMarkChar" of menu item "Speed Limit" of menu "Transfers" of menu bar 1 as string) ≠ ""

        display dialog "Speed Limit On: " & speedLimitCurrentlyOn
    end tell
end tell

附:
我从此处的 AppleScript 中改编了此内容: http:// mac.softpedia.com/progDownload/Transmission-Auto-Speed-Limit-Download-60275.html

I had the exact same issue, and finally figured out how to check if Transmission's Speed Limit menu item is checked (and you could easily modify this to check for menu items in other applications). This has been dead for almost a year now, but hopefully this helps.

tell application "Transmission" to activate

tell application "System Events"
    tell process "Transmission"
        set speedLimitCurrentlyOn to (value of attribute "AXMenuItemMarkChar" of menu item "Speed Limit" of menu "Transfers" of menu bar 1 as string) ≠ ""

        display dialog "Speed Limit On: " & speedLimitCurrentlyOn
    end tell
end tell

PS:
I adapted this from the AppleScript here: http://mac.softpedia.com/progDownload/Transmission-Auto-Speed-Limit-Download-60275.html

我爱人 2024-08-14 05:05:41

您能够通过 AppleScript 从任何给定应用程序中获取哪些信息完全取决于该应用程序的开发人员。如果 Transmission 没有定义任何方法来确定此状态,那么您将无法以任何程度的可靠性来确定此状态。

投资 40-50 美元购买具有服务质量控制功能的路由器会更有意义,该路由器允许您按端口或设备确定网络流量的优先级。

What information you are able to divine from any given application via AppleScript is entirely up to said application's developer. If Transmission doesn't define any way for you to determine this state, then you're not going to be able to do so with any degree of reliability.

It would make far more sense to invest $40-$50 in a router with quality of service controls that would allow you to prioritize your network traffic by port or by device.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文