Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

madamimadam

macrumors 65816
Original poster
Jan 3, 2002
1,281
0
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?
 

ElectricMan5

macrumors regular
Jul 22, 2008
204
0
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...
 

madamimadam

macrumors 65816
Original poster
Jan 3, 2002
1,281
0
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
 

drumswithcats

macrumors newbie
Jun 24, 2011
1
0
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).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.