0 Replies Latest reply on Jul 1, 2015 6:50 AM by fmdataweb

    AppleScript - GUI scripting to set the File Options dialog

    fmdataweb

      I'm working on an GUI scripting AppleScript that will, for the open FileMaker Pro Advanced document, go to the File menu and select the File Options dialog box, then set some checkbox/radio button and field values.


       

      I would like my script to do the following:

      1. tick the "Log in using:" checkbox if it is not already selected
      2. select the "Account Name and Password" radio button if it is not already selected
      3. Enter a value into the "Account:" field
      4. Enter a value into the "Password:" field
      5. Click the OK button

       

      I've got it opening the dialog box but I'm not able to get past setting the checkbox - this is my first time with GUI scripting. I'm using OS X Yosemite 10.10.3.


      Here's my script:


       

      -- 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


      It's throwing an error at the line "if (exists checkbox "Log in using:" of window 1) is true then" when I try and compile the script - I've played with this for a few hours to no avail. If anyone has experience with GUI scripting and can point me in the right direction that would be much appreciated.


      thanks,

      Steve