Show Modify Table View by script?

I See there is a "modify" button to pick which fields to show in table view.

Is there no script step to show that dialog?
Or menu command?

I'll add a function for this: FM.ModifyTableView

3 Likes

It would be really nice if fmp had Script controls for all the UI components.

3 Likes

Especially the Layout Design controls.
I've yet to find a reliable way to get to the inspector panel.

I'm on Mac OS.

โŒ˜-I to show or hide the inspector panel.
โŒ˜-1 for the Position panel
โŒ˜-2 for the Styles panel
โŒ˜-3 for the Appearance panel
โŒ˜-4 for the Data panel

2 Likes

Can you get into any of those?

Something like.

  1. Select an item on the layout.
  2. โŒ˜-1 - Position panel
  3. Change the top, left, width and height.
  4. Back to layout - select next object.

I can see and select the position text fields with XCode > Accessiblity Inspector - have not worked out the Apple Script to select it yet.

I have started a way of doing this using Keyboard Maestro (KM). It's hard coded to my device but you can use it yourself by changing the mouse click, and maybe removing one tab as I have my Mac tabbing through every element on screen like a windows device.

FileMaker - Developer List - Position.kmmacros.zip (2.2 KB)

No, the focus remains in the main layout area. I have to mouse into the fields. Once I'm in a field I can tab through, and I do that for adjacent fields.

We could get a LOT more control over these using the UI Scripting via AppleScript and accessibility features of macOS. Especially if we combine that with Keyboard Maestro.
One example, which selects the "Left" coordinate (if the location panel is open in the Inspector):

tell application "System Events"
	tell application process "FileMaker Pro"
		set frontmost to true
		delay 0.5
		tell window 1
			set focused of text field 6 of scroll area 2 to true
		end tell
	end tell
end tell
2 Likes

Excellent. We really only need a few commands to give focus to a panel or a section of the panel and then we can use the tab key to progress.

Do you have any Apple Script to select a Layout Part?

If you mean selecting the little tab/button you can see in Layout Mode, I had trouble. The following seems like it should work (spoiler alert: it doesn't work):

tell application "System Events"
	tell application process "FileMaker Pro"
		set frontmost to true
		delay 0.25
		tell group 2 of group 1 of scroll area 1 of window 1 to perform action "AXPress"
		-- group 1 is Header, group 2 is Body (in my example)
	end tell
end tell

It looks like we would instead need to use properties of group 2 ofโ€ฆ to get the position of the button, and then use some other utility (Keyboard Maestro, cliclick, or something else) to click at those screen coordinates. As hacky as that seems, it's definitely saved me a lot of trouble over the years.

[EDIT: here's the link for cliclick, which can also be installed using Homebrew: GitHub - BlueM/cliclick: macOS CLI tool for emulating mouse and keyboard events ]

1 Like

I did get it to work, using some AppleScript helper code built in the past.
Here's my fork of a Github project, which I've been slowly bringing up-to-date:

But, I grabbed the relevant pieces and brought them together into a single file (as long as you have cliclick installed):

-- Click Part Handle in FileMaker Layout Mode

property posixCliClick : "/usr/local/bin/cliclick"

on run
	
	set partName to "Footer"
	
	tell application "System Events"
		tell application process "FileMaker Pro"
			set frontmost to true
			delay 0.25
			set bodyPartHandle to first group of group 1 of scroll area 1 of window 1 whose accessibility description contains partName
			my clickObjectByCoords(bodyPartHandle)
		end tell
	end tell
end run

on clickObjectByCoords(someObject)
	-- version 1.2 - simplified hack, 2025-03-21 ( danshockley )
	
	try
		tell application "System Events"
			set {xCoord, yCoord} to position of someObject
			set {xSize, ySize} to size of someObject
		end tell
		set objOffset to round (minNum({xSize, ySize}) / 2) rounding down
		
		set xClick to xCoord + objOffset
		set yClick to yCoord + objOffset
		
		return clickAtCoords(xClick, yClick)
	on error errMsg number errNum
		error "unable to clickObjectByCoords - " & errMsg number errNum
	end try
end clickObjectByCoords

on clickAtCoords(xClick, yClick)
	-- version 1.4 - 2025-03-21 ( danshockley ): hack to check for cliclick property 1st
	try
		try
			set clickCommandPosix to posixCliClick
		on error
			tell application "Finder" to set clickCommandPosix to POSIX path of (((container of container of (path to me)) as string) & "vendor:cliclick:cliclick")
		end try
		set xClick to round xClick rounding down
		set yClick to round yClick rounding down
		if xClick is less than 0 then set xClick to "=" & xClick
		if yClick is less than 0 then set yClick to "=" & yClick
		set shellCommand to quoted form of clickCommandPosix & " -r m:" & xClick & "," & yClick & " c:" & xClick & "," & yClick
		do shell script shellCommand
		return (xClick & "," & yClick) as string
	on error errMsg number errNum
		error "unable to clickAtCoords - " & errMsg number errNum
	end try
end clickAtCoords


on minNum(someList)
	-- version 2020-03-04-1535
	
	try
		if class of someList is not list then error "not a list." number -1703
		set smallestFound to item 1 of someList as number
		
		repeat with i in someList
			set oneValue to i's contents as number
			if oneValue < smallestFound then set smallestFound to oneValue
		end repeat
		
		return smallestFound
	on error errMsg number errNum
		error "unable to minNum - " & errMsg number errNum
	end try
end minNum
1 Like