Je voulais automatiser le processus de modification de mon adresse IP en utilisant apple-script. J'ai donc écrit un script qui le fera automatiquement, mais j'ai des problèmes pour configurer l'adresse IP.Adresse IP de paramétrage Applescript
set ipAddress to "192.168.110.48"
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.network"
end tell
tell application "System Events"
tell process "System Preferences"
click checkbox "Click the lock to make changes." of window "Network"
tell application "System Events" to keystroke "p"
tell application "System Events" to keystroke "a"
tell application "System Events" to keystroke "s"
tell application "System Events" to keystroke "s"
tell application "System Events" to keystroke "w"
tell application "System Events" to keystroke "o"
tell application "System Events" to keystroke return
click button 11 of window "Network"
tell window "Network"
tell sheet 1
tell tab group 1
click radio button "TCP/IP"
set contents of text field 2 to ipAddress
end tell
end tell
end tell
end tell
end tell
Tout exécute bien, sauf pour cette déclaration
"set contents of text field 2 to ipAddress"
Je reçois l'erreur suivante:
error "System Events got an error: Can’t set contents of text field 2 of tab group 1 of sheet 1 of window \"Network\" of process \"System Preferences\" to \"192.168.110.48\"." number -10006 from contents of text field 2 of tab group 1 of sheet 1 of window "Network" of process "System Preferences" I checked the UI elements using UIBrowser so i am sure that i am using the correct elements. What is causing the problem? and Also can u tell a better way to write the same thing?