AppleScript stopped working after update to 10.13

I have the following script that worked fine under 10.12 and stopped working under 10.13. Now I have in my security and privacy panel, AppleScript and etc. activated, see pic. I found a post here that made me do this https://stackoverflow.com/questions/55917877/applescript-used-in-my-cocoa-mac-app-stopped-working-in-osx-10-14

The script runs and does nothing. Sometimes it looks like a window pops up but it is so fast I can to see if this is so or what it is.

I found that if I run the script form the editor 10 or more times in a row it all of a sudden works, once. But this is pretty inconsistent.

Any ideas?

tell application "VeraCrypt"
	activate
end tell
delay 2
tell application "VeraCrypt"
	activate
	tell application "System Events"
		tell process "System Preferences"
			delay 1
			repeat 20 times
				key code 126
			end repeat
			key code 125
			keystroke tab
			delay 1
			keystroke "/Volumes/Data/VC/file"
			key code 76
		end tell
	end tell
end tell

sorry forgot pic

https://ibb.co/sbwSCPY

You may try :

tell application "VeraCrypt"
	activate
end tell
tell application "VeraCrypt"
	activate
	tell application "System Events"
		tell process "System Preferences"
			set frontmost to true # ADDED
			delay 1
			repeat 20 times
				key code 126
			end repeat
			key code 125
			keystroke tab
			delay 1
			keystroke "/Volumes/Data/VC/file"
			key code 76
		end tell
	end tell
end tell

As I don’t own VeraCrypt, I can’t test.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 13 décembre 2019 14:17:29

Hi Yvan.

your script gives me the following error.

tell application “VeraCrypt”
activate
activate
end tell
tell application “System Events”
set frontmost of process “System Preferences” to true
→ error number -1728 from process “System Preferences”
Result:
error “System Events got an error: Can’t set process "System Preferences" to true.” number -10006 from process “System Preferences”

PS VeryCrypt is a brilliant open source application free to use.

Thanks KniazidisR

Is suppose you mean 10.13 with this?

Ok, not to me but I take your expertise here as given. One thing is it worked fine till I moved form 10.12 to 10.13. So that is why it is hard for me to understand, as a novice, why it stopped working.

There is no clicking of the mouse, I open the script from the ‘S’ (script button in bar) and it does not work. The clicking I did in the editor, to see if I can find which step is faulthy, as described and to no avail.

Thanks.

That script opens VC and next my System Preferences (not sure why we would need that) and does nothing more. However the script hangs. so force quit in order.

Ok no errors, and no results. VC i up front when I run it. But otherwise nothing.

key code 126 is the arrow key up and it is not doing that to begin with. it is to set the position in the VC window to position 1 to prevent it loading in any other position.

see pic
https://ibb.co/7kffMmy

again no luck, and no real success. the ‘Replies’ field shows:

tell application "VeraCrypt"
	activate
end tell
tell application "System Events"
	exists window "VeraCrypt" of application process "VeraCrypt"
		--> true
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	click button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
	key code 125
	keystroke "	"
	keystroke "/Volumes/Data/VC/file"
	key code 76
end tell

Maybe this helps I checked for all the UI information of VC. I experiemented but my AS skill level is to low.

{group 1 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", value indicator 1 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button 1 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button 2 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button 3 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button 4 of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", group 2 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button "Create Volume" of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button "Volume Properties..." of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button "Wipe Cache" of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", group "Volume" of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", static text "Volume" of group "Volume" of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", image 1 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", combo box 1 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button 1 of combo box 1 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button "Select File..." of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", checkbox "Never save history" of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button "Volume Tools..." of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button "Select Device..." of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", group 4 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button "Mount" of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", group 5 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button "Mount All Devices" of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", group 6 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button "Dismount All" of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", group 7 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button "Close" of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button 11 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button 12 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", button 13 of window "VeraCrypt" of application process "VeraCrypt" of application "System Events", static text "VeraCrypt" of window "VeraCrypt" of application process "VeraCrypt" of application "System Events"}

Just for info, here is the content of your late message after a bit of cleaning.

group 1

scroll bar 1
	value indicator 1 of scroll bar 1
	button 1 of scroll bar 1
	button 2 of scroll bar 1
	button 3 of scroll bar 1
	button 4 of scroll bar 1

group 2

button "Create Volume"

button "Volume Properties..."

button "Wipe Cache"

group "Volume"
	static text "Volume" of group "Volume"

Image 1

combo box 1
	button 1 of 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"

All these UI elements belong to : window “VeraCrypt” of application process “VeraCrypt” of application “System Events”

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

Rebuilt the UI structure

Yvan thank you! it helps me see what is reported there. Learning all the time.

Here is what I am trying but get stuck:

tell application "VeraCrypt"
	tell application "System Events"
		tell process "System Preferences"
			try
				tell window "VeraCrypt" of application process "VeraCrypt" of application "System Events" of group 1 of scroll bar 1 of value indicator 1 of scroll bar 1 of value indicator 1 of scroll bar 1
					delay 0.2
					select (button 1 of scroll bar 1)
				end tell
			on error
				tell window "VeraCrypt" of application process "VeraCrypt" of application "System Events" of group 1 of scroll bar 1 of value indicator 1 of scroll bar 1 of value indicator 1 of scroll bar 1
					delay 0.2
					select (button 1 of scroll bar 1)
				end tell
			end try
		end tell
	end tell
end tell

I get error:

error “System Events got an error: Can’t get application "System Events" of group 1 of scroll bar 1 of value indicator 1 of scroll bar 1 of value indicator 1 of scroll bar 1 of process "System Preferences".” number -1728 from application “System Events” of «class sgrp» 1 of «class scrb» 1 of «class vali» 1 of «class scrb» 1 of «class vali» 1 of «class scrb» 1 of «class prcs» “System Preferences”

Means it hangs on the select button line.

To make sure I understand. you are saying you think VC is not bale to have the window selected without mouse movement? that is why to recommend using cliclick?

thanks KniazidisR.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 14 décembre 2019 11:37:30

Hi Yvan,

I get an error:

error “System Events got an error: Can’t get scroll bar 1 of group 1 of window "VeraCrypt" of process "VeraCrypt". Invalid index.” number -1719 from scroll bar 1 of group 1 of window “VeraCrypt” of process “VeraCrypt”

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 14 décembre 2019 18:19:48

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