UI Access to Filemaker Pro's Data Viewer Window

In FileMaker Pro, my goal is to assign a keyboard shortcut to click the button “+” (add expression) at the bottom of the “Data Viewer” window, which is activated via Filemaker’s menu item “Tools” on its menu bar.
I have been unable to access the window “Data Viewer”, via System Preferences UI values for FileMaker Pro.

tell application "System Events"
	set FMP to first process whose name contains "Filemaker Pro"
	tell FMP
		set w to window "Data Viewer"
		--> System Events got an error: Can’t get window "Data Viewer" of application process "FileMaker Pro".
	end tell
end tell

The script errors with

System Events got an error: Can’t get window “Data Viewer” of application process “FileMaker Pro”.

The “Data Viewer” window, however, is available via UIElementInspector’s Accessibility Inspector as

<AXApplication: “FileMaker Pro”>
<AXWindow: “Data Viewer”>
<AXTabGroup>
<AXButton: “”>

Attributes:
AXEnabled: “1”
AXFrame: “x=607 y=938 w=27 h=24”
AXDescription: “Add Expression”
AXParent: “”
AXSize: “w=27 h=24”
AXFocused (W): “0”
AXRole: “AXButton”
AXTopLevelUIElement: “<AXWindow: “Data Viewer”>”
AXHelp: “Add Expression”
AXPosition: “x=607 y=938”
AXTitle: “”
AXWindow: “<AXWindow: “Data Viewer”>”
AXRoleDescription: “button”
AXIdentifier: “_NS:296”

Actions:
AXPress - press

UI Browser, for some reason, fails to detect the Data Viewer window.

What methods would you recommend to detect the Data Viewer window’s UI element, so that I can assign a keyboard shortcut to its “+” (add expression) button?

I think your syntax is a little fuzzy.

Begin by determining the screen location of the target button (assuming it’s visible). While I would guess —based on your readout— that the button can be clicked around the range of {612, 943}, do this to first to confirm.

Type ⌘⇧4 (i.e. screen shot of selected area) and move the mouse pointer so it hovers over the button. You should see the xy coordinates of the pointer. Use those to then run this script:

tell application "System Events"
	set xy to click at {612, 943}
end tell

It should return the object in question like so. I’ve used the minimize button for a firefox window as an example.

button 3 of window "UI Access to Filemaker Pro's Data Viewer Window - Scripting Forums / AppleScript | Mac OS X - MacScripter" of application process "firefox" of application "System Events"

Now you can edit the script like this:

tell application "Firefox Nightly"
	tell application "System Events"
		
		-- set xy to click at {612, 943}
		set xy to button 3 of window "UI Access to Filemaker Pro's Data Viewer Window - Scripting Forums / AppleScript | Mac OS X - MacScripter" of application process "firefox" of application "System Events"
		
		tell application process "firefox"
			perform action "AXPress" of xy
		end tell
	end tell
end tell
--> action "AXPress" of button 3 of window "UI Access to Filemaker Pro's Data Viewer Window - Scripting Forums / AppleScript | Mac OS X - MacScripter" of application process "firefox" of application "System Events"

The script should click the button and return the above result. If you need to force the filemaker window to the fore then add an activate line after the first tell statement.

The window is dismissed when FMP is not frontmost. Try this:

tell application "FileMaker Pro Advanced" to activate
tell application "System Events"
	tell (first process whose name contains "Filemaker")
		if not (exists (window 1 whose name contains "visu")) then
			click menu item 3 of menu 1 of menu bar item 10 of menu bar 1
		end if
		set w to window 1
		click radio button 2 of tab group 1 of w
		click button 3 of tab group 1 of w
	end tell
end tell

Maybe you will need to add some delays here and there. Depends on your configuration velocity.

Mockman, thanks for your ideas.The however did not work for me.

As the window is frequently expanded or contracted by the user depending upon the number of lines of data is it is viewing, or as the window is frequently moved by the user to view underlying FMP scripts, coordinate clicking will work, after any changes in window size or position.

My attempt at using your idea of window “UI Access to Filemaker Pro’s Data Viewer Window” yielded the same error, as in my script attempt.

Ionah, Thanks for your help, but I when I ran your suggesting, the script erred with

System Events got an error: Can’t get menu bar item 10 of menu bar 1 of process 1 whose name contains “Filemaker”. Invalid index.

I thought that a possible solution would be to understand the visibility of this Data Viewer window to UIElementInspector’s Accessibility Inspector, but not to UI Browser or to ApplesScript. Somehow this window is hidden from both UI Browser and ApplesScript.

Which version of FMP are you using?
What is your macOS version?

Have you added some delays as I suggested?

Ionah,
I am using
FMP FileMaker Pro 19.4.2,
OS 13.1 (22C65)
I have added delays, but the Data Viewer window UI is not identifiable. The Data Viewer window appears to be configured differently than the other FMP windows.

tell application "System Events"
	tell (first process whose name contains "Filemaker")
		set UIElementList to its UI elements's description
-> {"standard window", "standard window", "dialog", "menu bar"}
	end tell
end tell

The two standard windows represent FMP layout windows, and the dialog pane a dialog. No UI element, however, is identified for the “Data Viewer” window.

This error is about the menu, not the window.
Can you make a screenshot of your Filemaker menu bar with the Tools menu unfolded?

@akim
The structure of the menu and the window are visually unchanged.
The script should not error. It’s working well here with FMP 19 and Monterey on an Intel MacPro.

Do you have several versions of FileMaker Pro installed?

If it’s yes, try the following:

tell application id "FM19" to activate -- this line is indispensable
tell application "System Events" 
	tell (first process whose creator type = "FM19")
		if not (exists (window 1 whose name contains "visu")) then
			click menu item 3 of menu 1 of menu bar item 10 of menu bar 1
		end if
		set w to window 1
		click radio button 2 of tab group 1 of w
		click button 3 of tab group 1 of w
	end tell
end tell

If it’s no, then I’m out of idea.

Ionah,
Your script works quite well! I am not sure why I was not able to make your first script work. I’m thankful for you help.
My attempt to find the UI path to window 1 resulted in identifying the window of FMP’s first open database. When I attempted to view the window’s UI properties, although I found tab group 1, I could not find any identification of any button UI element in that tab group. For my education, might you explain the method by which you were able to decipher or structure the UI path to the “Data Viewer” window, and from there, to its buttons?

The point you’re missing is that UI scripting can’t operate on an element if its not displayed on screen at frontmost.

In your case there’s 2 problems:

  • the Data viewer window is dismissed when FMP is not frontmost.
  • the Watch tab button must be clicked to unveal elements from this particular tab.

First, you need to know how to target the application you want to manipulate: this is most of the time done by calling the process by its name.
But sometimes the process name is not identical to the app name. Or if you have several versions of the same app, it can be duplicated.
In those cases, you need to find the best discriminant: the bundle identifier, the creator type, the path, etc.

Second, keep in mind that UI scripting is is a bit dysfunctional: in example, entire contents of window 1 may not always return the same values; click at {x,y} may not work at all on particular systems.

Finally, I have no secret ingredient to navigate on a window or menu bar structure. I’m using UI Browser and Script Debugger.
Regarding UI scripting they both can have problems (often due to System Events misbehavior) but they are the best tools ever.