Results 1 to 4 of 4
  1. #1
    Applescript - Detect if Dock Contextual Menu Item is Checked?

    Member Since
    Mar 26, 2009
    Posts
    2
    Unhappy Applescript - Detect if Dock Contextual Menu Item is Checked?
    I've made an applescript stay open application that checks if Transmission is open, and Safari is frontmost, it selects speed limit from Transmission's dock icon.
    It's SO **** useful, as my internet is fast and ready when I'm browsing, then if I'm not using it Transmission is free to take up the full bandwidth.

    However, I can't seem to find any way to detect whether menu item "Speed Limit" is checked or not. It shows a little tick next to it when it's activated (I've attached a picture), so there MUST be a way to detect that (I hope).
    Currently I'm using the property "transmissionLimited" to store whether or not my application has checked it automatically... but sometimes if I want to limit for other purposes it will then UN-LIMIT it when I open up Safari. Nightmare

    I've tried using "get ui elements" and "get properties" to no avail. Has anyone got any other ideas?

    Also I don't really use forums much. Is there a better forum to ask this question on? Macscripter.net?

    Thanks!



    Here's what I'm using so far...



    on checkTransmission()
    try
    if (isFrontmost("Safari")) and (isRunning("Transmission")) and (transmissionLimited is false) then
    tell application "System Events" to tell process "Dock"
    tell UI element "Transmission" of list 1
    perform action "AXShowMenu"
    click menu item "Speed Limit" of menu 1
    end tell
    end tell
    set transmissionLimited to true
    else if (isFrontmost("Safari") is false) and (isRunning("Transmission")) and (transmissionLimited) then
    tell application "System Events" to tell process "Dock"
    tell UI element "Transmission" of list 1
    perform action "AXShowMenu"
    click menu item "Speed Limit" of menu 1
    end tell
    end tell
    set transmissionLimited to false
    end if
    on error
    Growl("Auto Speed Limit Failed")
    end try
    end checkTransmission
    Attached Images Attached Images

  2. #2
    Applescript - Detect if Dock Contextual Menu Item is Checked?

    Member Since
    Mar 26, 2009
    Posts
    2
    No one? Okay good... at least I'm not a complete moron

  3. #3
    Applescript - Detect if Dock Contextual Menu Item is Checked?
    Aptmunich's Avatar
    Member Since
    Mar 09, 2004
    Location
    Munich
    Posts
    9,073
    Specs:
    Aluminium Macbook 2.4 Ghz 4GB RAM, SSD 24" Samsung Display, iPhone 4, iPad 2
    Does Transmission have it's own Applescript dictionary? If it does you might try accessing the speed commands that way instead of going the ui scripting route.

    If it doesn't you could also try running the command-line based version of transmission and then using a shell script command to throttle it.

  4. #4
    Applescript - Detect if Dock Contextual Menu Item is Checked?

    Member Since
    Dec 26, 2010
    Posts
    1
    Thank you very much, your script has help me a lot

    And I'm gonna help you!!

    What you need if a menu is "checked" is the attribute AXMenuItemMarkChar, something like:

    set isChecked to ((value of attribute "AXMenuItemMarkChar" of -themenuitem-) ≠ "")

    that because AXMenuItemMarkChar is the tick char, if there isn't the check it is just nothing

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VLC Appears Twice In Contextual Menu
    By derekeverett in forum OS X - Operating System
    Replies: 5
    Last Post: 11-04-2012, 07:34 PM
  2. Language Settings | Contextual Menu
    By zerimar3 in forum OS X - Operating System
    Replies: 4
    Last Post: 08-11-2011, 05:09 PM
  3. Contextual Menu access.
    By HKJ in forum OS X - Operating System
    Replies: 0
    Last Post: 12-02-2008, 10:10 PM
  4. OnMyCommand - build your own Contextual Menu Item
    By MacHeadCase in forum OS X - Apps and Games
    Replies: 0
    Last Post: 05-07-2007, 12:19 PM
  5. modify contextual list menu
    By mik4 in forum Schweb's Lounge
    Replies: 0
    Last Post: 12-30-2003, 11:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •