Adjust Finder column width to fit tags

I would like to script Finder’s List View columns to set a width that fits the length of text of multiple Finder file tags.
The following script changes the size of the column to a static number, designated as the variable ColumnWidth.

on AdjustColumnWidthTo:ColumnWidth
	tell application "Finder"
		set current view of Finder window 1 to list view
		set width of column id label column of list view options of Finder window 1 to ColumnWidth
	end tell
end AdjustColumnWidthTo:

I would like to have the script configure its own column width based upon the space occupied by the longest set of tags in files listed in that Finder window.

Finder provides a keyboard shortcut, accessed by mousing over the View Options bar at the top of the window. When the mouse cursor overlaps the vertical delimiter, Finder changes its shape from a leftward arrow to a cross. Manually clicking Finder’s cursor cross at that position accomplishes the desired task of calling Finder to calculate an appropriate column width to fit the contents of the Tags column.

What are possible methods for applescript to command this Finder Window event?

Here’s the problem I’m stuck on … Maybe someone will understand - I just can’t understand what I’m doing wrong … For some reason, a double click does not occur where I’m pointing. (It is assumed that some folder is already open and there is a Tags column in the window):


my set_View_To_ListView()
my setColumnWidth()
my refresh_Finder_window()

on setColumnWidth()
	tell application "Finder" to activate
	tell application "System Events" to tell application process "Finder"
		tell scroll area 1 of splitter group 1 of splitter group 1 of window 1
			tell outline 1
				set theTagsColumn to first column whose value of attribute "AXIdentifier" is "label"
			end tell
		end tell
		set {x, y} to position of theTagsColumn
		set y to y + 11
	end tell
	set {x, y} to {x as string, y as string}
	do shell script "/usr/local/bin/mousetools -x" & (x as string) & " -y" & (y as string) & " -doubleLeftClick" -- Double Click At Coordinates
end setColumnWidth

on set_View_To_ListView()
	tell application "Finder"
		activate
		tell window 1
			set currentView to current view
			if currentView is not list view then set current view to list view
		end tell
	end tell
end set_View_To_ListView

on refresh_Finder_window()
	tell application "Finder"
		activate
		set the_Target to target of Finder window 1
		close the_Target
		open the_Target
	end tell
end refresh_Finder_window

Wow! It seems, MouseTools can’t move cursor in the Finder window. It clicks for some reason only on current cursor position. Interestingly, was it always or did it come with new updates?

OK, I GOT IT work fine.

Was founded 2 problems:

  1. MouseTools for some reason didn’t move the pointer in the Finder window.
  2. I forget to add offset (the current width of Tags column, to click on right position.

NOTE: Refreshing the window works only on real folders, not Recents, or Smart folders.

So. Working code is this:


my set_View_To_ListView()
my setColumnWidth()
my refresh_Finder_window()

on setColumnWidth()
	tell application "Finder" to activate
	tell application "System Events" to tell application process "Finder"
		tell scroll area 1 of splitter group 1 of splitter group 1 of window 1
			tell outline 1
				set theTagsColumn to first column whose value of attribute "AXIdentifier" is "label"
				set the_Bounds to value of attribute "AXFrame" of theTagsColumn
				set old_Width to (item 3 of the_Bounds) - (item 1 of the_Bounds)
			end tell
		end tell
		set {x, y} to position of theTagsColumn
		set {x, y} to {x + old_Width, y + 11}
	end tell
	set {x, y} to {x as string, y as string}
	do shell script "/Users/123/UnixBins/cliclick dc:" & x  & "," & y -- Double Click At Coordinates
end setColumnWidth

on set_View_To_ListView()
	tell application "Finder"
		activate
		tell window 1
			set currentView to current view
			if currentView is not list view then set current view to list view
		end tell
	end tell
end set_View_To_ListView

on refresh_Finder_window()
	tell application "Finder"
		activate
		set the_Target to target of Finder window 1
		close the_Target
		open the_Target
	end tell
end refresh_Finder_window

UPDATE.
I improved somewhere my script above:

  1. removed unneeded on refresh_Finder_window handler, and other handlers
  2. removed third-party ClickClick utility
  3. now user can choose target folder from script.

NEW VERSION:


use AppleScript version "2.5"
use scripting additions
use framework "CoreGraphics"

property |⌘| : a reference to current application
property updateMouseCursorPosition : true
property buttonCount : 1 -- left mouse button number
property mouseButtonDown : true -- mouse button pressed?

set aPoint to |⌘|'s CGPointZero
set theFolder to choose folder

tell application "Finder"
	activate
	open folder theFolder
	tell window 1 to if (current view) is not list view then set current view to list view
	tell application "System Events" to tell application process "Finder"
		tell scroll area 1 of splitter group 1 of splitter group 1 of window 1 to tell outline 1
			set theTagsColumn to first column whose value of attribute "AXIdentifier" is "label"
			set the_Bounds to value of attribute "AXFrame" of theTagsColumn
			set old_Width to (item 3 of the_Bounds) - (item 1 of the_Bounds)
		end tell
		set {x, y} to position of theTagsColumn
		set aPoint to {x + old_Width, y + 11}
	end tell
	mouseLeftClick of me at aPoint
	delay 0.1
	mouseLeftClick of me at aPoint
	activate
end tell

on mouseLeftClick at aPoint
	|⌘|'s CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonCount, mouseButtonDown)
	|⌘|'s CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonCount, not mouseButtonDown)
end mouseLeftClick

Thank you.

Your code let me write a piece of code listing the visible columns in the way they are ordered in the window.

tell application "System Events" to tell application process "Finder"
	set frontmost to true
	tell scroll area 1 of splitter group 1 of splitter group 1 of window 1 to tell outline 1
		set colIDs to value of attribute "AXIdentifier" of every column
	end tell
end tell
return colIDs
--≤ {"name", "dateModified", "size", "kind", "label", "version", "comments", "dateCreated", "dateLastOpened", "dateAdded"}

Caution, in Xcode help, one may read about CGPostMouseEvent : This function is not recommended for general use because of undocumented special cases and undesirable side effects. The recommended replacement for this function is CGEventCreateMouseEvent, which allows you to create a mouse event and customize the event before posting it to the event system.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 13 septembre 2019 14:19:12

@KniazidisR

Hello, as I am curious I tried to run your script.
At first try I got : → error “Il est impossible d’obtenir CGPointZero.” number -1728 from CGPointZero

So I typed a try error block and retried.
This time I got : → error “Il est impossible de poursuivre CGPostMouseEvent.” number -1708

I retried after adding some use instructions borrowed from an other of your proposals.
I got the same results.
As the column “label” isn’t always available, I made a little change. but the final behavior is the same error.

So that you may test on your side, here the late state of the used script.

# KniazidisR
use AppleScript version "2.5"
use scripting additions
use framework "Foundation" # ADDED
use framework "ApplicationServices" # ADDED
use framework "Quartz" # ADDED
use framework "AppKit"

property |⌘| : a reference to current application
property updateMouseCursorPosition : true
property buttonCount : 1 -- left mouse button number
property mouseButtonDown : true -- mouse button pressed?

try # ADDED
	set aPoint to |⌘|'s CGPointZero --> error "Il est impossible d’obtenir CGPointZero." number -1728 from CGPointZero
on error # ADDED
	set aPoint to {0.0, 0.0} # ADDED
end try # ADDED

set theFolder to choose folder

tell application "Finder"
	activate
	open folder theFolder
	tell window 1 to if (current view) is not list view then set current view to list view
	tell application "System Events" to tell application process "Finder"
		tell scroll area 1 of splitter group 1 of splitter group 1 of window 1 to tell outline 1
			set columnLabels to value of attribute "AXIdentifier" of every column --> {"name", "dateModified", "dateCreated", "size", "kind", "label", "version", "dateAdded"} # ADDED
			repeat with i from 1 to count columnLabels
				set found to columnLabels's item i = "label"
				if found then exit repeat
			end repeat
			if not found then error "There is no label column"
			set theTagsColumn to column i
			set the_Bounds to value of attribute "AXFrame" of theTagsColumn
			set old_Width to (item 3 of the_Bounds) - (item 1 of the_Bounds)
		end tell
		set {x, y} to position of theTagsColumn
		set aPoint to {x + old_Width, y + 11}
	end tell
	mouseLeftClick of me at aPoint
	delay 0.1
	mouseLeftClick of me at aPoint
	activate
end tell

on mouseLeftClick at aPoint
	|⌘|'s CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonCount, mouseButtonDown) --> error "Il est impossible de poursuivre CGPostMouseEvent." number -1708
	|⌘|'s CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonCount, not mouseButtonDown)
end mouseLeftClick

Would be interested to read your comments.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 18 décembre 2019 14:31:10

I tried your code as is. It stil works fine on Mojave. I can’t understand why you get error on that simple instruction. Try this equivalent instruction and tell me what happens on your machine:

set aPoint to |⌘|'s CGPointMake(0, 0) 

If all go fine, you should get at result record {x:0.0,y:0.0}

Oh, I found what was a problem. It is from framework Core Graphics. Try add this framework and tell me if code works on your machine. Remove all other frameworks. I updated my last script.

NOTE: Thanks to Akim for idea. It is very useful script, which allows me to reset automatically the width of some important columns in the Finder.

Thanks but here it continue to issue the same error.
I tested with :

# KniazidisR
use AppleScript version "2.5"
use scripting additions
use framework "CoreGraphics" # ADDED

(* Behaves the same with:
use scripting additions
use framework "Foundation"
use framework "ApplicationServices"
use framework "Quartz"
use framework "AppKit"
use framework "CoreGraphics" # ADDED
*)

property |⌘| : a reference to current application
property updateMouseCursorPosition : true
property buttonCount : 1 -- left mouse button number
property mouseButtonDown : true -- mouse button pressed?

set aPoint to |⌘|'s CGPointZero --> error "Il est impossible d’obtenir CGPointZero." number -1728 from CGPointZero

Remember that as ChangeAgent I don’t use Mojave (10.14) but High Sierra (10.13.6)

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 18 décembre 2019 16:56:04

There’s no need to add CoreGraphics. The issue is one of converting a C struct to AppleScript, which appears to be problematic in this case under macOS 10.13.

The AppleScript bridge converts structs to AppleScript records. In this case, it’s simpler (and quicker) to create your own:

set aPoint to {x:0.0, y:0.0}

Also, on 64-bit systems a CGPoint is just another name for an NSPoint.

Thank you Shane.

I edited the script as :

# KniazidisR
use AppleScript version "2.5"
use scripting additions
use framework "Foundation" 

property |⌘| : a reference to current application
property updateMouseCursorPosition : true
property buttonCount : 1 -- left mouse button number
property mouseButtonDown : true -- mouse button pressed?

try # ADDED
	set aPoint to |⌘|'s CGPointZero --> error "Il est impossible d’obtenir CGPointZero." number -1728 from CGPointZero
on error # ADDED
	set aPoint to {x:0.0, y:0.0} # ADDED for system older than 10.14
end try # ADDED

set theFolder to choose folder

tell application "Finder"
	activate
	open folder theFolder
	tell window 1 to if (current view) is not list view then set current view to list view
	tell application "System Events" to tell application process "Finder"
		tell scroll area 1 of splitter group 1 of splitter group 1 of window 1 to tell outline 1
			set columnLabels to value of attribute "AXIdentifier" of every column --> {"name", "dateModified", "dateCreated", "size", "kind", "label", "version", "dateAdded"} # ADDED
			repeat with i from 1 to count columnLabels
				set found to columnLabels's item i = "label"
				if found then exit repeat
			end repeat
			if not found then error "There is no “label” column"
			set theTagsColumn to column i
			set the_Bounds to value of attribute "AXFrame" of theTagsColumn
			set old_Width to (item 3 of the_Bounds) - (item 1 of the_Bounds)
		end tell
		set {xx, yy} to position of theTagsColumn # EDITED for system older than 10.14
		set {x, y} to {xx + old_Width, yy + 11} # ADDED for system older than 10.14
		set aPoint to {x:x, y:y} # ADDED for system older than 10.14
	end tell
	mouseLeftClick of me at aPoint
	delay 0.1
	mouseLeftClick of me at aPoint
	activate
end tell

on mouseLeftClick at aPoint
	|⌘|'s CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonCount, mouseButtonDown) --> error "Il est impossible de poursuivre CGPostMouseEvent." number -1708
	|⌘|'s CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonCount, not mouseButtonDown)
end mouseLeftClick

Alas it continue to issue : → error “Il est impossible de poursuivre CGPostMouseEvent.” number -1708.

Not a huge problem for me, I may do the job with a script using cliClick.
I mainly wanted to pointed the fact that an other asker, ChangeAgent, wasn’t playing fool when he wrote that : set aPoint to |⌘|'s CGPointZero
failed on its machine running High Sierra.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 19 décembre 2019 11:03:26

I wondered if, under High Sierra and older systems, it’s required to replace:

set aPoint to {x:x, y:y} # ADDED for system older than 10.14

by

set aPoint to |⌘|'s NSMakePoint(x, y)

Alas, after this change, the script continue to issue the infamous error message.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 19 décembre 2019 13:19:52

Yvan, Shane Stanley already sad you what to do. I am not pleased when someone constantly repeats that my working script is not working. Better move your brains too:


use AppleScript version "2.5"
use scripting additions
use framework "CoreGraphics"

property |⌘| : a reference to current application
property updateMouseCursorPosition : true
property buttonCount : 1 -- left mouse button number
property mouseButtonDown : true -- mouse button pressed?

set aPoint to {x:0.0, y:0.0}
set theFolder to choose folder

tell application "Finder"
	activate
	open folder theFolder
	tell window 1 to if (current view) is not list view then set current view to list view
	tell application "System Events" to tell application process "Finder"
		tell scroll area 1 of splitter group 1 of splitter group 1 of window 1 to tell outline 1
			set theTagsColumn to first column whose value of attribute "AXIdentifier" is "label"
			set the_Bounds to value of attribute "AXFrame" of theTagsColumn
			set old_Width to (item 3 of the_Bounds) - (item 1 of the_Bounds)
		end tell
		set {x, y} to position of theTagsColumn
		set aPoint to {x + old_Width, y + 11}
	end tell
	mouseLeftClick of me at aPoint
	delay 0.1
	mouseLeftClick of me at aPoint
	activate
end tell

on mouseLeftClick at aPoint
	|⌘|'s CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonCount, mouseButtonDown)
	|⌘|'s CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonCount, not mouseButtonDown)
end mouseLeftClick

NOTE: the documentation of Apple for CGPointZero says that it should work for all OS 10+. I jumped High Sierra because of some similar its issues. For example, I can’t copy my movies with size 2-4 Gbyte from hard disk to my FAT32 USB disk.

If you have read my message you would know that I took care of Shane’s advice

try # ADDED
   set aPoint to |⌘|'s CGPointZero --> error "Il est impossible d’obtenir CGPointZero." number -1728 from CGPointZero
on error # ADDED
   set aPoint to {x:0.0, y:0.0} # ADDED for system older than 10.14
end try # ADDED

After that I tested with the instructions embedded in your late message which are your original ones and I got the infamous : → error “Il est impossible de poursuivre CGPostMouseEvent.” number -1708
This is why I made other attempts which gave the same result.

I repeat that there is an oddity in your script if the selected folder has no “label” column.
I already posted the corrected code.

Running your very last proposal, I got :

# Don't click Open this Scriplet in your Editor:

tell application "Script Editor"
	choose folder
		--> alias "SSD 1000:Users:**********:Desktop:activate Wi-Fi:"
end tell
tell application "Finder"
	activate
	open folder (alias "SSD 1000:Users:**********:Desktop:activate Wi-Fi:")
	get current view of window 1
		--> list view
end tell
tell application "System Events"
	get column 1 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window 1 of application process "Finder" whose value of attribute "AXIdentifier" = "label"
		--> column 5 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "activate Wi-Fi" of application process "Finder"
	get value of attribute "AXFrame" of column 5 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "activate Wi-Fi" of application process "Finder"
		--> {1569, 270, 1684, 552}
	get position of column 5 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "activate Wi-Fi" of application process "Finder"
		--> {1569, 270}
end tell
tell application "Script Editor"
	CGPostMouseEvent({1684, 281}, true, 1, true)
		--> error number -1708
Résultat :
error "Il est impossible de poursuivre CGPostMouseEvent." number -1708

I would be glad to be able to post : Bingo, the KniazidisR’s script behaves flawlessly!
It’s not my fault if your script doesn’t behave as you wrote.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 19 décembre 2019 18:36:59

As far as ASObjC is concerned, that means absolutely nothing. It’s a C-style function, not a method, and ASObjC support for them has been patchy. It also involves a struct, the bridging of which has also varied.

Move outside methods and commonly bridged types and there are no guarantees.

Thank you Shane.
Now I know that there is no hope.
Maybe KniazidisR will be fair enough to add a test at the beginning of the script:

if (system attribute "sys2") < 14 then error "The script requires 10.14 or higher."

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 20 décembre 2019 09:23:36

Hi again. I don’t tested my script on other systems. Only on Mojave. Who has Catalina can share his observations. I would also be interested to know both with Yosemite and Capitan. As I said, I did not like High Sierra because of some important bugs. Not Sierra, but High Sierra.

Yvan, can you try in your last script this:

|⌘|'s CGPostMouseEvent({x:1684.0, y:281.0}, true, 1, true) 
-- or
|⌘|'s CGPostMouseEvent({1684.0, 281.0}, true, 1, true)
-- instead of
CGPostMouseEvent({1684, 281}, true, 1, true) -- as you have?

This function should get record of real values, and not integers

@ KniazidisR

In fact I already made test coercing the passed values as real.

set aPoint to {(x + old_Width) as real, (y + 11) as real}

The behavior is the same.

tell application "Script Editor"
	choose folder
		--> alias "SSD 1000:Users:yvankoenig:Desktop:activate Wi-Fi:"
end tell
tell application "Finder"
	activate
	open folder (alias "SSD 1000:Users:yvankoenig:Desktop:activate Wi-Fi:")
	get current view of window 1
		--> list view
end tell
tell application "System Events"
	get column 1 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window 1 of application process "Finder" whose value of attribute "AXIdentifier" = "label"
		--> column 5 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "activate Wi-Fi" of application process "Finder"
	get value of attribute "AXFrame" of column 5 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "activate Wi-Fi" of application process "Finder"
		--> {1569, 270, 1684, 552}
	get position of column 5 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "activate Wi-Fi" of application process "Finder"
		--> {1569, 270}
end tell
tell application "Script Editor"
	CGPostMouseEvent({1684.0, 281.0}, true, 1, true)
		--> error number -1708
Résultat :
error "Il est impossible de poursuivre CGPostMouseEvent." number -1708

I also tested with:

set aPoint to {x:(x + old_Width) as real, y:(y + 11) as real}

This said the problem was perfectly explained by Shane.

It’s clear and simple, some C-style functions aren’t bridged in ‘old’ systems. Some struct object are bridged different ways.

We faced the same kind of problems when ASObjC appeared. Some functions wheren’t bridged. In 10.12 or 10.13 they are bridged.
The problem is not to know that you dislike High Sierra, it’s that numerous machines can’t host 10.14 or 10.15.
It would be fair to insert an instruction playing the same role that ‘use use AppleScript version “2.5”’ wich prevent the use of a script with an ‘old’ system for which some functions weren’t bridged.
This instruction, which I already posted, is really simple :

if (system attribute "sys2") < 14 then error "The script requires 10.14 or higher."

I didn’t wrote that your script doesn’t work. I wrote that this script doesn’t work under 10.13. It would have been better to write that this script doesn’t work under systems older than 10.14.

I assume that it’s the same for the two other scripts which you posted using CGPostMouseEvent and CGPointZero.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 20 décembre 2019 14:12:39

The cliclick version of the script is simpler. For those who have AsObjC version of my script does not work.

Although, GUI-scripting all exactly involves consideration of a specific OS. UI elements may be different in your OS, so you may have to adjust the script. This is one of those reasons why I do not want to generalize the script further:


set theFolder to choose folder

tell application "Finder"
	activate
	open folder theFolder
	tell window 1 to if (current view) is not list view then set current view to list view
	tell application "System Events" to tell application process "Finder"
		tell scroll area 1 of splitter group 1 of splitter group 1 of window 1 to tell outline 1
			set theTagsColumn to first column whose value of attribute "AXIdentifier" is "label"
			set the_Bounds to value of attribute "AXFrame" of theTagsColumn
			set old_Width to (item 3 of the_Bounds) - (item 1 of the_Bounds)
		end tell
		set {x, y} to position of theTagsColumn
		set {x, y} to {(x + old_Width) as string, (y + 11) as string}
	end tell
	do shell script ("/usr/local/bin/cliclick -r dc:" & x & "," & y)
	activate
end tell

NOTE: to test what the script does, attach one or more tags to Finder item or items of chosen folder. Better with long values. Tag’s column should be present. Set tag’s column width to minimum, then run the script.

With a enhancement :


set theFolder to choose folder

tell application "Finder"
	activate
	open folder theFolder
	tell window 1 to if (current view) is not list view then set current view to list view
	tell application "System Events" to tell process "Finder" # no need to prefix process with application
		tell scroll area 1 of splitter group 1 of splitter group 1 of window 1 to tell outline 1
			try
				set theTagsColumn to first column whose value of attribute "AXIdentifier" is "label"
			on error errMsg number errNbr
				error "error #" & errNbr & ",  It seems that there is no “label” column" & linefeed & errMsg
				(*
--> error "error #-1719,  It seems that there is no “label” column
Erreur dans System Events : Il est impossible d’obtenir column 1 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window 1 of application process \"Finder\" whose value of attribute \"AXIdentifier\" = \"label\". Index non valable." number -2700 from «script» to item
*)
			end try
			set the_Bounds to value of attribute "AXFrame" of theTagsColumn
			set old_Width to (item 3 of the_Bounds) - (item 1 of the_Bounds)
		end tell
		set {x, y} to position of theTagsColumn
		set {x, y} to {(x + old_Width) as string, (y + 11) as string}
	end tell
	tell me to do shell script ("/usr/local/bin/cliclick -r dc:" & x & "," & y)
	activate
end tell

I post it mostly to point a “funny” detail. It seems that AppleScript if not sure of which error is striking. -1719 or -2700, we have to choose :rolleyes:

This alternate version returns a more legible message.

set theFolder to choose folder

tell application "Finder"
	activate
	open folder theFolder
	tell window 1 to if (current view) is not list view then set current view to list view
	tell application "System Events" to tell process "Finder" # no need to prefix process with application
		tell scroll area 1 of splitter group 1 of splitter group 1 of window 1 to tell outline 1
			set colNames to value of attribute "AXIdentifier" of columns --> {"name", "dateModified", "dateCreated", "size", "kind", "dateAdded"}
			if colNames does not contain "label" then error "There is no “label” column"
			set theTagsColumn to first column whose value of attribute "AXIdentifier" is "label"
			set the_Bounds to value of attribute "AXFrame" of theTagsColumn
			set old_Width to (item 3 of the_Bounds) - (item 1 of the_Bounds)
		end tell
		set {x, y} to position of theTagsColumn
		set {x, y} to {(x + old_Width) as string, (y + 11) as string}
	end tell
	tell me to do shell script ("/usr/local/bin/cliclick -r dc:" & x & "," & y)
	activate
end tell

Without the ‘tell me to’ prefix, the events log report:

tell application "Finder"
	do shell script "/usr/local/bin/cliclick -r dc:782,627"
		--> error number -10004
end tell
tell current application
	do shell script "/usr/local/bin/cliclick -r dc:782,627"
		--> ""
end tell

With it, it report the cleaner :

tell current application
	do shell script "/usr/local/bin/cliclick -r dc:1090,837"
		--> ""
end tell

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 20 décembre 2019 17:39:12