Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 3, 2009, 10:11 PM   #1
madamimadam
macrumors 65816
 
madamimadam's Avatar
 
Join Date: Jan 2002
AppleScript - Click Button of Window not working

I'm trying to automate the set up of VirtualBox on a large deployment of MacBooks.

One of the tasks is to add an existing hard drive image to a new virtual machine.

I could not see any key combination to access that button so I figured I'd just use the click button command.


Code reads:
tell application "System Events"
... [lots of unrelated code here]
tell process "VirtualBox"
click button "Existing..." of window "Create New Virtual Machine"
delay 1
click button "Add" of window "Create New Virtual Machine"
end tell
end tell

I used the Accessibility Inspector to check the aspects of the button and it says:
Application: "VirtualBox"
Window: "Create New Virtual Machine"
Button: "Existing..."


AppleScript error is:
System Events got an error: Can't get button "Existing..." of window "Create New Virtual Machine" of process "VirtualBox".


Any ideas?
__________________
"Type edit a:\"
"Edit a colon?????"
"No, edit a : ...... A :"
"A colon????"
"The letter a"
madamimadam is offline   0 Reply With Quote
Old Mar 16, 2009, 12:26 PM   #2
ElectricMan5
macrumors regular
 
Join Date: Jul 2008
Quote:
Originally Posted by madamimadam View Post
I'm trying to automate the set up of VirtualBox on a large deployment of MacBooks.

One of the tasks is to add an existing hard drive image to a new virtual machine.

I could not see any key combination to access that button so I figured I'd just use the click button command.


Code reads:
tell application "System Events"
... [lots of unrelated code here]
tell process "VirtualBox"
click button "Existing..." of window "Create New Virtual Machine"
delay 1
click button "Add" of window "Create New Virtual Machine"
end tell
end tell

I used the Accessibility Inspector to check the aspects of the button and it says:
Application: "VirtualBox"
Window: "Create New Virtual Machine"
Button: "Existing..."


AppleScript error is:
System Events got an error: Can't get button "Existing..." of window "Create New Virtual Machine" of process "VirtualBox".


Any ideas?

I get the error also, for "Sharing" on system preferences. This is the script I used:


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 with no errors, but it just doesn't run...
__________________
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, 11:55 PM   #3
madamimadam
Thread Starter
macrumors 65816
 
madamimadam's Avatar
 
Join Date: Jan 2002
Not sure the answer there, sorry, but luckily you could use a menu click


tell application "System Preferences" to activate

tell application "System Events"
tell process "System Preferences"
tell menu bar 1
tell menu bar item "View"
tell menu "View"
click menu item "Network"
end tell
end tell
end tell
end tell
end tell
__________________
"Type edit a:\"
"Edit a colon?????"
"No, edit a : ...... A :"
"A colon????"
"The letter a"
madamimadam is offline   0 Reply With Quote
Old Jun 24, 2011, 04:58 PM   #4
drumswithcats
macrumors newbie
 
Join Date: Jun 2011
I ran into similar problems with menu commands and button names like "Existing...". Turns out you have to use an actual ellipsis character rather than 3 periods in a row. Try replacing ... with … (option key + semicolon).
drumswithcats 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

Similar Threads
thread Thread Starter Forum Replies Last Post
Using Javascript | Applescript to click button in Safari o.rka Web Design and Development 4 Feb 18, 2014 05:15 PM
entire window moves when attempting to click and drag element in window HELP chlc MacBook Pro 0 Feb 10, 2014 05:08 PM
Applescript Safari how to click button redwgaontoy Mac Programming 1 Jun 12, 2013 12:12 AM
Keep a window always on top - can't find an app. How can I applescript this? Hippocrates04 Mac Basics and Help 0 Aug 5, 2012 10:36 AM
AppleScript To Click One Button Only If Another Button Is Unavailable JonHimself Mac Programming 2 Jul 4, 2012 01:16 PM

Forum Jump

All times are GMT -5. The time now is 08:32 AM.

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

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