New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Operating System General OS operation information and support

OS 10.5 - Applescript - Detect if Dock Contextual Menu Item is Checked?


Post Reply New Thread Subscribe

 
Thread Tools
eclix

 
Member Since: Mar 26, 2009
Posts: 2
eclix is on a distinguished road

eclix is offline
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
File Type: png transmissiondock.png (39.4 KB, 7 views)
QUOTE Thanks
eclix

 
Member Since: Mar 26, 2009
Posts: 2
eclix is on a distinguished road

eclix is offline
No one? Okay good... at least I'm not a complete moron
QUOTE Thanks
Aptmunich

 
Aptmunich's Avatar
 
Member Since: Mar 09, 2004
Location: Munich
Posts: 9,075
Aptmunich has a brilliant futureAptmunich has a brilliant futureAptmunich has a brilliant futureAptmunich has a brilliant futureAptmunich has a brilliant futureAptmunich has a brilliant futureAptmunich has a brilliant futureAptmunich has a brilliant futureAptmunich has a brilliant futureAptmunich has a brilliant futureAptmunich has a brilliant future
Mac Specs: Aluminium Macbook 2.4 Ghz 4GB RAM, SSD 24" Samsung Display, iPhone 4, iPad 2

Aptmunich is offline
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.
QUOTE Thanks
JdLobo

 
Member Since: Dec 26, 2010
Posts: 1
JdLobo is on a distinguished road

JdLobo is offline
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
QUOTE Thanks

Post Reply New Thread Subscribe


« something went wrong with my UI help! | Keyboard Layouts (Japanese) »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
OnMyCommand - build your own Contextual Menu Item MacHeadCase OS X - Apps and Games 0 05-07-2007 12:19 PM
Menu Item to Open Close DVD tray CaptVijay OS X - Apps and Games 2 04-12-2007 12:30 AM
sometimes the left mouse button brings up contextual menu? silverr OS X - Operating System 4 10-07-2006 02:07 AM
Invisible Menu Bar Item roma0104 OS X - Operating System 2 06-02-2006 11:12 PM
modify contextual list menu mik4 Schweb's Lounge 0 12-30-2003 11:13 PM

All times are GMT -4. The time now is 08:17 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?