Ich arbeite an einem GUI-Scripting-AppleScript, das für das geöffnete FileMaker Pro Advanced-Dokument zum Menü „Datei“ geht und das Dialogfeld „Dateioptionen“ auswählt und dann einige Kontrollkästchen/Optionsfelder und Feldwerte festlegt.
Das Dialogfeld sieht folgendermaßen aus:
Ich möchte, dass mein Skript Folgendes tut:
Ich habe es geschafft, das Dialogfeld zu öffnen, aber ich komme nicht über das Setzen des Kontrollkästchens hinaus - dies ist mein erstes Mal mit GUI-Skripting. Ich verwende OS X Yosemite 10.10.3.
Hier ist mein Skript:
-- check that GUI Scripting is available
GUIScripting_status()
-- bring FileMaker Pro Advanced to the front
tell application "FileMaker Pro Advanced"
activate
end tell
setfmFileOptions()
on click_button(app_name, button_name)
try
tell application app_name
activate
end tell
tell application "System Events"
tell process app_name
click button button_name of front window
end tell
end tell
return true
on error error_message
end try
end click_button
on do_menu(app_name, menu_name, menu_item)
try
-- bring the target application to the front
tell application app_name
activate
end tell
tell application "System Events"
tell process app_name
tell menu bar 1
tell menu bar item menu_name
tell menu menu_name
click menu item menu_item
end tell
end tell
end tell
end tell
end tell
return true
on error error_message
return false
end try
end do_menu
on setfmFileOptions()
-- choose the Developer Utilities menu item from the Tools menu of FileMaker Pro Advanced
do_menu("FileMaker Pro Advanced", "File", "File Options...")
-- click the "Log in using" checkbox:
if (exists checkbox "Log in using:" of window 1) is true then
click checkbox "Log in using:" of window 1
end if
end setfmFileOptions
on GUIScripting_status()
-- check to see if assistive devices is enabled
tell application "System Events"
set UI_enabled to UI elements enabled
end tell
if UI_enabled is false then
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.universalaccess"
display dialog "This script utilizes the built-in Graphic User Interface Scripting architecture of Mac OS x which is currently disabled." & return & return & "You can activate GUI Scripting by selecting the checkbox \"Enable access for assistive devices\" in the Universal Access preference pane." with icon 1 buttons {"Cancel"} default button 1
end tell
end if
end GUIScripting_status
Es wird nicht kompiliert und gibt diesen Fehler zurück. Die Zeile " if (exists checkbox "Log in using:" of window 1) is true then":
versuchen Sie diese kleine Syntaxänderung:
on setfmFileOptions(app_name)
-- choose the Developer Utilities menu item from the Tools menu of FileMaker Pro Advanced
do_menu(app_name, "File", "File Options...")
-- click the "Log in using" checkbox:
tell application "System Events"
tell process app_name
repeat until (exists checkbox "Log in using:" of tab group 1 of window 1)
delay 1
end repeat
click checkbox "Log in using:" of tab group 1 of window 1
end tell
end tell
end setfmFileOptions
Sie können Fenster 1 nicht verwenden, ohne mitzuteilen, in welchem Prozessfenster 1 sich befindet. Sie müssen jetzt app_name als Parameter angeben.
Also so:
setfmFileOptions("FileMaker Pro Advanced")
Benutzer982124
William T. Froggard
Benutzer982124
William T. Froggard
tell application "System Events" to get checkboxes of window 1 of process "FileMaker Pro Advanced"
Sehen Sie sich die ggf. zurückgegebenen Kontrollkästchen an, wenn Sie nicht finden, wonach Sie suchen, versuchen Sie Folgendes: Fügen Sie dann weitertell application "System Events" to get checkboxes of UI elements of window 1 of process "FileMaker Pro Advanced"
hinzuof UI elements
,checkboxes
bis Sie erhalten das gesuchte Kontrollkästchen. Dies ist eine einfache Methode zum Crawlen der Ansichtshierarchie. Tun Sie dies jedoch in einem separaten Skript.William T. Froggard
Benutzer982124
checkbox "Log in using:" of tab group 1 of window 1
- danke, dass Sie mich in die richtige Richtung gewiesen haben. Ich lerne im Laufe der Zeit mehr über die AppleScript-Syntax.Benutzer982124
checkbox "Log in using:" of tab group 1 of window 1
William T. Froggard