如何判断菜单项是否被“选中"? [英] How to tell if a menu item is 'checked'?

查看:24
本文介绍了如何判断菜单项是否被“选中"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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.

当限速处于活动状态时,菜单项变为已检查",但我不知道如何对此进行测试.传输应用程序的applescript 字典中没有任何内容.

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.

如何确定 Applescript 中的菜单项是否被选中"(它甚至显示实际的选中标记)?

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

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

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

推荐答案

我遇到了完全相同的问题,终于想出了如何检查传输的速度限制菜单项是否被选中(您可以轻松地修改它以检查菜单其他应用程序中的项目).这已经死了将近一年了,但希望这会有所帮助.

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

<小时>

附注:我从这里的 AppleScript 改编了这个:http://mac.softpedia.com/progDownload/Transmission-Auto-Speed-Limit-Download-60275.html

这篇关于如何判断菜单项是否被“选中"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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