Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 16, 2009, 11:28 AM   #1
ElectricMan5
macrumors regular
 
Join Date: Jul 2008
Applescript click window button help!

I'm using this script:

tell application "System Preferences" to activate

tell application "System Events"
tell process "System Preferences"
click button "Network" of window "System Preferences"
delay 1
end tell
end tell


It compiles well, but it doesn't run!

It comes up with the error:

System Events got an error: Canít get button "Network" of window "System Preferences" of process "System Preferences".


I want the script to automate opening up system preferences, then opening up sharing, then turning "web sharing" on and off.

Please help! Thanks.
__________________
21.5" 2012 iMac, 3.1 Ghz i7, 16GB RAM, 1TB HD; 13" Aluminum Unibody Macbook, 2 Ghz, 2 GB RAM, 160 GB HD ; 64 GB iPod Touch 4g; 8GB iPhone 3g; 32GB iPhone 4s
ElectricMan5 is offline   0 Reply With Quote
Old Mar 16, 2009, 12:56 PM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
This would be a better way to show the Sharing preference:
Code:
tell application "System Preferences"
    set current pane to pane id "com.apple.preferences.sharing"
end tell
Then after that you can use UI scripting.
kainjow is offline   0 Reply With Quote
Old Mar 16, 2009, 01:00 PM   #3
ElectricMan5
Thread Starter
macrumors regular
 
Join Date: Jul 2008
Quote:
Originally Posted by kainjow View Post
This would be a better way to show the Sharing preference:
Code:
tell application "System Preferences"
    set current pane to pane id "com.apple.preferences.sharing"
end tell
Then after that you can use UI scripting.
Thanks! What is UI Scripting, though?
__________________
21.5" 2012 iMac, 3.1 Ghz i7, 16GB RAM, 1TB HD; 13" Aluminum Unibody Macbook, 2 Ghz, 2 GB RAM, 160 GB HD ; 64 GB iPod Touch 4g; 8GB iPhone 3g; 32GB iPhone 4s
ElectricMan5 is offline   0 Reply With Quote
Old Mar 16, 2009, 01:21 PM   #4
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
It's accessing the controls (buttons, text fields, etc) of a program via AppleScript, which is what the "click" command is. You would only use it when there isn't a built-in way of doing what you want through AppleScript. Perfect example is above where System Preferences already supports showing a certain preference pane, but you were wanting to manually click the button instead.
kainjow is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Using Click in AppleScript rebello95 Mac Programming 3 Nov 8, 2011 06:09 AM
world of warcraft not playing after i click "play" button. please help! dsprimal Mac Applications and Mac App Store 2 Jul 7, 2010 07:22 AM
Xcode Applescript app button help lynkynpark86 Mac Programming 0 Mar 31, 2010 01:13 PM
Xcode Applescript Open Window With Button lynkynpark86 Mac Programming 0 Mar 30, 2010 08:45 AM
Applescript Pop up button help!! silly34 Mac Programming 0 Jul 22, 2005 03:08 PM


All times are GMT -5. The time now is 03:52 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC