AppleScript stopped working after update to 10.13

Morning KniazidisR

sorry folks for delay, I was on the road.

Running your script I get:

Result:
error “Can’t get CGPointZero.” number -1728 from CGPointZero

Morning Yvan, yout script returns:

tell application "VeraCrypt"
	activate
end tell
tell application "System Events"
	set frontmost of process "VeraCrypt" to true
	exists window "VeraCrypt" of process "VeraCrypt"
		--> true
	exists window "VeraCrypt" of process "VeraCrypt"
		--> true
	get class of every UI element of window "VeraCrypt" of process "VeraCrypt"
		--> {group, scroll bar, group, button, button, button, group, image, combo box, button, checkbox, button, button, group, button, group, button, group, button, group, button, button, button, button, static text}
	(*group, scroll bar, group, button, button, button, group, image, combo box, button, checkbox, button, button, group, button, group, button, group, button, group, button, button, button, button, static text*)
	get class of every UI element of group 1 of window "VeraCrypt" of process "VeraCrypt"
		--> {}
	(**)
end tell

VC activates but that is all.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 16 décembre 2019 09:25:04

it loops

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 16 décembre 2019 09:44:05

OK here is what I get:

tell application "VeraCrypt"
	activate
end tell
tell application "System Events"
	set frontmost of process "VeraCrypt" to true
	exists window "VeraCrypt" of process "VeraCrypt"
		--> true
	exists window "VeraCrypt" of process "VeraCrypt"
		--> true
	get class of every UI element of window "VeraCrypt" of process "VeraCrypt"
		--> {group, scroll bar, group, button, button, button, group, image, combo box, button, checkbox, button, button, group, button, group, button, group, button, group, button, button, button, button, static text}
	count every group of window "VeraCrypt" of process "VeraCrypt"
		--> 7
	(*group 1*)
	get class of every UI element of group 1 of window "VeraCrypt" of process "VeraCrypt"
		--> {}
	(**)
	(*group 2*)
	get class of every UI element of group 2 of window "VeraCrypt" of process "VeraCrypt"
		--> {}
	(**)
	(*group 3*)
	get class of every UI element of group 3 of window "VeraCrypt" of process "VeraCrypt"
		--> {static text}
	(*static text*)
	(*group 4*)
	get class of every UI element of group 4 of window "VeraCrypt" of process "VeraCrypt"
		--> {}
	(**)
	(*group 5*)
	get class of every UI element of group 5 of window "VeraCrypt" of process "VeraCrypt"
		--> {}
	(**)
	(*group 6*)
	get class of every UI element of group 6 of window "VeraCrypt" of process "VeraCrypt"
		--> {}
	(**)
	(*group 7*)
	get class of every UI element of group 7 of window "VeraCrypt" of process "VeraCrypt"
		--> {}
	(**)
end tell

script runs till the end.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 16 décembre 2019 10:16:22

runs without errors, but selects nothing in the window.

Log window shows:

tell application "VeraCrypt"
	activate
end tell
tell application "System Events"
	set frontmost of process "VeraCrypt" to true
	exists window "VeraCrypt" of process "VeraCrypt"
		--> true
	exists window "VeraCrypt" of process "VeraCrypt"
		--> true
	get class of every UI element of window "VeraCrypt" of process "VeraCrypt"
		--> {group, scroll bar, group, button, button, button, group, image, combo box, button, checkbox, button, button, group, button, group, button, group, button, group, button, button, button, button, static text}
	get class of every UI element of scroll bar 1 of window "VeraCrypt" of process "VeraCrypt"
		--> {value indicator, button, button, button, button}
	(*value indicator, button, button, button, button*)
end tell

Now we grab the names of the buttons.
Tell me which is the one to click.

tell application "VeraCrypt"
	activate
	tell application "System Events"
		tell process "VeraCrypt"
			set frontmost to true
			--repeat until exists window "VeraCrypt"
			--delay 0.1 # Don't forget that this loop fails
			--end repeat
			repeat 10 times
				if exists window "VeraCrypt" then exit repeat
				delay 0.1
			end repeat
			if not (exists window "VeraCrypt") then error "The window VeraCrypt is not available"
			tell window "VeraCrypt"
				--class of UI elements --> {group, scroll bar, group, button, button, button, group, image, combo box, button, checkbox, button, button, group, button, group, button, group, button, group, button, button, button, button, static text}
				# The same list with the names of UI elements
				--> {group 1, scroll bar 1, group 2, button "Create Volume", button "Volume Properties...", button "Wipe Cache", group "Volume", image 1, combo box 1, button "Select File...", checkbox "Never save history", button "Volume Tools...", button "Select Device...", group 4, button "Mount", group 5, button "Mount All Devices", group 6, button "Dismount All", group 7, button "Close", button 11, button 12, button 13, static text "VeraCrypt"}
				tell scroll bar 1
					--class of UI elements --> {value indicator, button, button, button, button}
					name of buttons -->
				end tell
			end tell #window
		end tell # process Veracrypt
	end tell # Application System Events
end tell # Application Veracrypt

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 16 décembre 2019 12:09:35

May you try this version which is supposed to achieve the wanted task ?

tell application "VeraCrypt"
	activate
	tell application "System Events"
		tell process "VeraCrypt"
			set frontmost to true
			--repeat until exists window "VeraCrypt"
			--delay 0.1 # Don't forget that this loop fails
			--end repeat
			repeat 10 times
				if exists window "VeraCrypt" then exit repeat
				delay 0.1
			end repeat
			if not (exists window "VeraCrypt") then error "The window VeraCrypt is not available"
			tell window "VeraCrypt"
				(*
				--class of UI elements --> {group, scroll bar, group, button, button, button, group, image, combo box, button, checkbox, button, button, group, button, group, button, group, button, group, button, button, button, button, static text}
				# The same list with the names of UI elements
				--> {group 1, scroll bar 1, group 2, button "Create Volume", button "Volume Properties...", button "Wipe Cache", group "Volume", image 1, combo box 1, button "Select File...", checkbox "Never save history", button "Volume Tools...", button "Select Device...", group 4, button "Mount", group 5, button "Mount All Devices", group 6, button "Dismount All", group 7, button "Close", button 11, button 12, button 13, static text "VeraCrypt"}
				tell scroll bar 1
					--class of UI elements --> {value indicator, button, button, button, button}
					name of buttons -->
				end tell # scroll bar 1
				*)
				tell combo box 1
					set value of attribute "AXFocused" to true
					-- delay 0.5 # may be useful here
					set its value to "/Volumes/Data/VC/file"
				end tell # combo box 1
				click button "Mount"
			end tell # window "VeraCrypt"
		end tell # process Veracrypt
	end tell # Application System Events
end tell # Application Veracrypt

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 16 décembre 2019 21:54:18

Yvan good morning! It works! What a nice thing to wake up to. Thanks. And also thanks to KniazidisR.

Some fine tweeting if we can and if I am not over-stretching you willingness to help. See pic

https://ibb.co/WgCgMZt

As you can see there are different slots. The green one is the one selected by me. The script however takes whatever slot was selected before. That is why I scrolled up and than down in my original script. I like to be able to define the slot. Reason be is that if I load more than one encrypted volume each one needs to be in its own slot.

Your script is complex for me, and looking at it I do not know where to insert, and how, such a command.

If it is easy to do great, if not I need to live with it, I am already very happy with this result as it makes mounting a volume so much easier compared to doing it manually.

That I know, I usually operate them from the bar.

Your answer does not answer my question though, I think you misunderstood. I want to select, lets say, position 2 in VC to load the encrypted volume in that position. Positioning is important in this as one volume can only occupy one position in VC. See pic in last post of mine.

OK, glad to see that it works.

Here is a stripped version which will return the position and the size of every group in the window so I will be able to know which is the group containing the slots.
It will also return the name and the position of every buttons.

script #1

tell application "VeraCrypt"
	activate
	tell application "System Events"
		tell process "VeraCrypt"
			set frontmost to true
			--repeat until exists window "VeraCrypt"
			--delay 0.1 # Don't forget that this loop fails
			--end repeat
			repeat 10 times
				if exists window "VeraCrypt" then exit repeat
				delay 0.1
			end repeat
			if not (exists window "VeraCrypt") then error "The window VeraCrypt is not available"
			tell window "VeraCrypt"
				
				--class of UI elements --> {group, scroll bar, group, button, button, button, group, image, combo box, button, checkbox, button, button, group, button, group, button, group, button, group, button, button, button, button, static text}
				# The same list with the names of UI elements
				--> {group 1, scroll bar 1, group 2, button "Create Volume", button "Volume Properties...", button "Wipe Cache", group "Volume", image 1, combo box 1, button "Select File...", checkbox "Never save history", button "Volume Tools...", button "Select Device...", group 4, button "Mount", group 5, button "Mount All Devices", group 6, button "Dismount All", group 7, button "Close", button 11, button 12, button 13, static text "VeraCrypt"}
				position of groups
				log result
				size of groups
				log result
				name of buttons
				log result
				position of buttons
				log result
				(*
				tell scroll bar 1
					--class of UI elements --> {value indicator, button, button, button, button}
					name of buttons -->
				end tell # scroll bar 1
				
				tell combo box 1
					set value of attribute "AXFocused" to true
					-- delay 0.5 # may be useful here
					set its value to "/Volumes/Data/VC/file"
				end tell # combo box 1
				click button "Mount"
				*)
			end tell # window "VeraCrypt"
		end tell # process Veracrypt
	end tell # Application System Events
end tell # Application Veracrypt

May you download the trial version of UI Browser from : https://pfiddlesoft.com/uibrowser/ ?
It’s supposed to work from 10.10 thru 10.15.
Running it would give infos about the area displaying the slots.

As now we know that the app doesn’t recognize the clause ‘until’, may you try the code below which just does what your old cod did but use an alternate scheme to check that the window Verascript is available.

script #2

tell application "VeraCrypt" to activate
tell application "System Events"
	tell application process "VeraCrypt"
		set frontmost to true
		(* now we know that VeraCrypt doesn't recognize the clause 'until'
		repeat until window "VeraCrypt" exists
			delay 0.1
		end repeat
		*)
		# Try this alternate one
		repeat 10 times
		if exists window "VeraCrypt" then exit repeat
		delay .1
		end repeat
		if not (exists window "VeraCrypt") then error "The window VeraCrypt is not available"
	end tell # process "VeraCrypt"
	# Move to top of the list of slots # EDITED, was 'the very bottom'
	repeat 20 times
		key code 126 # press up arrow # EDITED, was 'down arrow'
	end repeat
	# Move to second slot # EDITED, was 'the next to last'
	key code 125 # press down arrow # EDITED, was 'up arrow'
	# Select the slot
	keystroke tab
	delay 1 # If all works, try to reduce it to delay 0.5
	keystroke "/Volumes/Data/VC/file"
	--key code 76 # issue a linefeed
	keystroke linefeed
end tell # System Events

or

script #3

tell application "VeraCrypt"
	activate
	tell application "System Events"
		tell process "VeraCrypt"
			set frontmost to true
			--repeat until exists window "VeraCrypt"
			--delay 0.1 # Don't forget that this loop fails
			--end repeat
			repeat 10 times
				if exists window "VeraCrypt" then exit repeat
				delay 0.1
			end repeat
			if not (exists window "VeraCrypt") then error "The window VeraCrypt is not available"
			tell window "VeraCrypt"
				(*
				--class of UI elements --> {group, scroll bar, group, button, button, button, group, image, combo box, button, checkbox, button, button, group, button, group, button, group, button, group, button, button, button, button, static text}
				# The same list with the names of UI elements
				--> {group 1, scroll bar 1, group 2, button "Create Volume", button "Volume Properties...", button "Wipe Cache", group "Volume", image 1, combo box 1, button "Select File...", checkbox "Never save history", button "Volume Tools...", button "Select Device...", group 4, button "Mount", group 5, button "Mount All Devices", group 6, button "Dismount All", group 7, button "Close", button 11, button 12, button 13, static text "VeraCrypt"}
				tell scroll bar 1
					--class of UI elements --> {value indicator, button, button, button, button}
					name of buttons -->
				end tell # scroll bar 1
				*)
				# Move to top of the list of slots # EDITED, was 'the very bottom'
				repeat 20 times
					key code 126 # press up arrow # EDITED, was 'down arrow'
				end repeat
				# Move to second slot # EDITED, was 'the next to last'
				key code 125 # press down arrow # EDITED, was 'up arrow'
				# Select the slot
				keystroke tab
				delay 1 # If all works, try to reduce it to delay 0.5
				tell combo box 1
					set value of attribute "AXFocused" to true
					-- delay 0.5 # may be useful here
					set its value to "/Volumes/Data/VC/file"
				end tell # combo box 1
				click button "Mount"
			end tell # window "VeraCrypt"
		end tell # process Veracrypt
	end tell # Application System Events
end tell # Application Veracrypt

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 décembre 2019 12:01:06

EDITED some erroneous comments and add scripts numbering.

your first script returns:

tell application "VeraCrypt"
	activate
end tell
tell application "System Events"
	set frontmost of application process "VeraCrypt" to true
	exists window "VeraCrypt" of application process "VeraCrypt"
		--> true
	exists window "VeraCrypt" of application process "VeraCrypt"
		--> true
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 125
	keystroke "	"
	keystroke "/Volumes/Data/VC/file"
	keystroke "
"
end tell

the second one goes al the way to hitting the Mount button

tell application "VeraCrypt"
	activate
end tell
tell application "System Events"
	set frontmost of process "VeraCrypt" to true
	exists window "VeraCrypt" of process "VeraCrypt"
		--> true
	exists window "VeraCrypt" of process "VeraCrypt"
		--> true
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 126
	key code 125
	keystroke "	"
	set value of attribute "AXFocused" of combo box 1 of window "VeraCrypt" of process "VeraCrypt" to true
	set value of combo box 1 of window "VeraCrypt" of process "VeraCrypt" to "/Volumes/Data/VC/file"
	click button "Mount" of window "VeraCrypt" of process "VeraCrypt"
		--> button "Mount" of window "VeraCrypt" of application process "VeraCrypt"
end tell
Result:
button "Mount" of window "VeraCrypt" of application process "VeraCrypt" of application "System Events"

@ ChangeAgent

In fact you posted what is returned by my 2nd and 3rd scripts.
The 1st one was supposed to return infos about groups and buttons.

script #2
is supposed to move the cursor in the window to select the wanted slot,
then it’s supposed to ‘type’ the POSIX path “/Volumes/Data/VC/file” in the dedicated combo box,
at last it is supposed to ‘type’ a linefeed to activate the default button “Mount”.

script #3
is supposed to move the cursor in the window to select the wanted slot.
then it’s supposed to fill the dedicated combo box with the POSIX path “/Volumes/Data/VC/file”,
at last it is supposed to click the button “Mount”.

What you posted show that all the instructions are executed.
What isn’t clear is if they executed the wanted tasks.
Is the correct slot selected ?
Is the mount action executed ?

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 décembre 2019 14:37:02

no

yes

Thanks.
As the code supposed to select the correct slot failed try again with the scheme given by KniazidisR

Please, change nothing to the code below.
Grab it clicking upon the button [Open this Scriplet in your Editor:]


use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "ApplicationServices"
use framework "Quartz"
use framework "AppKit"
property updateMouseCursorPosition : true
property buttonCount : 1 -- left mouse button number
property mouseButtonDown : true -- mouse button pressed?
property slots : {60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300}

set aPoint to current application's CGPointZero

tell application "VeraCrypt" to activate
tell application "System Events"
	tell application process "VeraCrypt"
		set frontmost to true
		--repeat until exists window "VeraCrypt"
		--delay 0.1 # Don't forget that this loop fails
		--end repeat
		repeat 10 times
			if exists window "VeraCrypt" then exit repeat
			delay 0.1
		end repeat
		if not (exists window "VeraCrypt") then error "The window VeraCrypt is not available"
		--set w to window "VeraCrypt"
		tell window "VeraCrypt"
			set {x, y} to its position
			log (get position of groups) # May be useful to check the values in the property slots
			log (get size of groups) # May be useful to check the values in the property slots
			tell scroll bar 1
				log {its position, linefeed, its size} # May be useful to check the values in the property slots
				repeat 20 times
					click button 4
				end repeat
			end tell # scroll bar 1
		end tell # window "VeraCrypt"
	end tell # process Veracrypt
	-- Choose 2nd slot
	set aPoint to {x + 100, y + (item 2 of slots)} -- set the point coordinates on the screen
	mouseLeftClick of me at aPoint -- perform left click and move the cursor to new position
	-- Choose text field to keystroke the path
	tell application process "VeraCrypt"
		tell window "VeraCrypt"
			tell combo box 1
				set value of attribute "AXFocused" to true
				-- delay 0.5 # may be useful here
				set its value to "/Volumes/Data/VC/file"
			end tell # combo box 1
			click button "Mount"
		end tell # window "VeraCrypt"
	end tell # process Veracrypt
end tell # Application System Events
--tell application "VeraCrypt" to activate

on setPoint(xPos, yPos)
	set pt to current application's CGPointMake(0, 0)
	set pt to {xPos, yPos}
	return pt
end setPoint

on mouseLeftClick at aPoint
	current application's CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonCount, mouseButtonDown)
	current application's CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonCount, not mouseButtonDown)
end mouseLeftClick

I guess that it will change the selected slot but I’m not sure that it selects the good one.
This is why I urged the script to log some informations about size and locations of some UI elements.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 décembre 2019 16:14:25

get the following error Yvan:

Result:
error “Can’t get CGPointZero.” number -1728 from CGPointZero

I tested the bare:

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "ApplicationServices"
use framework "Quartz"
use framework "AppKit"
property updateMouseCursorPosition : true
property buttonCount : 1 -- left mouse button number
property mouseButtonDown : true -- mouse button pressed?
property slots : {60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300}

set aPoint to current application's CGPointZero

and got exactly what ChangeAgent reported.

I replaced ‘use AppleScript version “2.4”’ by ‘use AppleScript version “2.5”’
and got {x:0.0, y:0.0}
As I am pig headed, I reverted to ‘use AppleScript version “2.4”’ and this time I got:
{x:0.0, y:0.0}
So, I apologize.
There is a problem with your instruction.
As I don’t want to waste time, as long as I don’t have an explanation of this odd behavior, I will drop this scheme and will try to do the job with the good old cliclick.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 décembre 2019 18:14:01

all the frameworks exist.

use framework “Foundation”
use framework “ApplicationServices”
use framework “Quartz”
use framework “AppKit”

your basic version gives the same error as before:

Result:
error “Can’t get CGPointZero.” number -1728 from CGPointZero

the code I use is a straight past job form yours:

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "ApplicationServices"
use framework "Quartz"
use framework "AppKit"
property updateMouseCursorPosition : true
property buttonCount : 1 -- left mouse button number
property mouseButtonDown : true -- mouse button pressed?
property slots : {60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300}

set aPoint to current application's CGPointZero

tell application "VeraCrypt" to activate
tell application "System Events"
	tell application process "VeraCrypt"
		set frontmost to true
		--repeat until exists window "VeraCrypt"
		--delay 0.1 # Don't forget that this loop fails
		--end repeat
		repeat 10 times
			if exists window "VeraCrypt" then exit repeat
			delay 0.1
		end repeat
		if not (exists window "VeraCrypt") then error "The window VeraCrypt is not available"
		--set w to window "VeraCrypt"
		tell window "VeraCrypt"
			set {x, y} to its position
			log (get position of groups) # May be useful to check the values in the property slots
			log (get size of groups) # May be useful to check the values in the property slots
			tell scroll bar 1
				log {its position, linefeed, its size} # May be useful to check the values in the property slots
				repeat 20 times
					click button 4
				end repeat
			end tell # scroll bar 1
		end tell # window "VeraCrypt"
	end tell # process Veracrypt
	-- Choose 2nd slot
	set aPoint to {x + 100, y + (item 2 of slots)} -- set the point coordinates on the screen
	mouseLeftClick of me at aPoint -- perform left click and move the cursor to new position
	-- Choose text field to keystroke the path
	tell application process "VeraCrypt"
		tell window "VeraCrypt"
			tell combo box 1
				set value of attribute "AXFocused" to true
				-- delay 0.5 # may be useful here
				set its value to "/Volumes/Data/VC/file"
			end tell # combo box 1
			click button "Mount"
		end tell # window "VeraCrypt"
	end tell # process Veracrypt
end tell # Application System Events
--tell application "VeraCrypt" to activate

on setPoint(xPos, yPos)
	set pt to current application's CGPointMake(0, 0)
	set pt to {xPos, yPos}
	return pt
end setPoint

on mouseLeftClick at aPoint
	current application's CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonCount, mouseButtonDown)
	current application's CGPostMouseEvent(aPoint, updateMouseCursorPosition, buttonCount, not mouseButtonDown)
end mouseLeftClick

Result:
error “Can’t get CGPointZero.” number -1728 from CGPointZero