AppleScript stopped working after update to 10.13

here is the history:

It selects the Apple logo top Left side of the bar and stops there.

I had to put cliclick here: /usr/local/bin/cliclick
I had no permission to the folder you suggested. I adjusted the script.

Not sure if you need a screen shot at this point.

Oops, I’m an ass.
I made typos now corrected in message #48.
I also use your location for the CLI.
If the slot 2 is not selected by the edited version, the report and the screenshot would be useful.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 décembre 2019 20:48:54

Taking care of the values reported in your message, I re-edited message #48 at 21:08:07

Edited again after testing the set of instructions upon a Numbers window. 21:18:29 in France

Morning Yvan, not sure if you are an as, I think more of an hero.

anyway works mostly. here is the report:


[quote]
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
	get position of window "VeraCrypt" of application process "VeraCrypt"
		--> {402, 183}
	get position of window "VeraCrypt" of application process "VeraCrypt"
		--> {402, 183}
	(*402, 183*)
	get position of every group of window "VeraCrypt" of application process "VeraCrypt"
		--> {{402, 205}, {402, 502}, {418, 552}, {418, 665}, {569, 665}, {720, 665}, {871, 665}}
	(*402, 205, 402, 502, 418, 552, 418, 665, 569, 665, 720, 665, 871, 665*)
	get size of every group of window "VeraCrypt" of application process "VeraCrypt"
		--> {{636, 297}, {636, 237}, {604, 103}, {151, 58}, {151, 58}, {151, 58}, {151, 58}}
	(*636, 297, 636, 237, 604, 103, 151, 58, 151, 58, 151, 58, 151, 58*)
	get position of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> {1005, 223}
	get size of scroll bar 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> {15, 261}
	(*1005, 223, 
, 15, 261*)
	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"
end tell
tell current application
	do shell script "/usr/local/bin/cliclick c:435,247"
		--> ""
end tell

[/quote]

what happens is it takes slot 1.

set slots to {h, 2 * h, 3 * h, 4 * h, 5 * h, 6 * h, 7 * h, 8 * h, 9 * h, 10 * h, 11 * h, 12 * h, 13 * h, 14 * h, 15 * h, 16 * h, 17 * h, 18 * h, 19 * h, 20 * h}

if I take away h, 2 * it takes slot 2.

however it now does not put in the location and hits the ‘Mount’ button. I tried to fix this as it worked in an earlier script, but do not get it to work.

Good news.

I edited message #37 accordingly.
I changed the offset added to wTop.
I disabled the return which urged the script to exit after trying to select the slot.
If everything works, it would be a goo idea to test again after setting slotNum to 19.
Maybe it would not select slot19 but slot18.

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

Hi Yvan,

succes!

Thanks a milion!

set slotNum to 2 # ADDED to select slot 2, may be 1 thru 20

Changing the number here allows me to use different slots so that is brilliant as we sometimes have 3 or 4 VC disks loaded.

Brilliant and thanks again for helping me out here. I am trying to understand all you do/did and will take some quiet time in the weekend to see if I can follow what you did. Learning all the time. And I must say this was definitely beyond my skill level.

For now I am extremely happy and grateful.

@ KniazidisR
I see your posts disappeared, pity as I would have liked to reread for my education, but also thanks for chipping in it was helpful too.

Have you tried to run it after setting slotNum to 19?
It would be useful to check that the value 18 given to h is the correct one.

When I will be sure of the required value, I will edit message #37 with a code which click button 4 only the needed number of times.

Just for info, below is the script which I used to test the scheme with Numbers.

(*
test with Numbers
*)
use AppleScript version "2.4"
use scripting additions

tell application "Numbers" to activate
tell application "System Events"
	tell application process "Numbers"
		set frontmost to true
		tell window 1
			set {wLeft, wTop} to its position
			-- get class of UI elements --> {scroll area, button, scroll area, button, button, scroll area, button, button, radio group, UI element, button, button, static text, scroll area, button, button, button, menu button, toolbar, tab, static text, static text}
			-- get position of scroll areas --> {{1065, 142}, {1112, 114}, {1065, 1081}, {1897, 323}}
			-- get class of UI elements of scroll area 1 --> {scroll bar, scroll bar}
			tell scroll bar 2 of scroll area 1
				if class of UI elements contains value indicator then --> {value indicator, button, button, button, button}
					set oldPos to item 2 of (get position of value indicator 1) --> 963
					-- get subrole of buttons --> {"AXIncrementArrow", "AXDecrementArrow", "AXIncrementPage", "AXDecrementPage"}
					repeat
						click button 4 --> the "AXDecrementPage" one
						set newPos to item 2 of (get position of value indicator 1)
						if newPos = oldPos then exit repeat
						set oldPos to newPos
					end repeat
				end if
			end tell # scroll bar 1
		end tell # window  1
	end tell # process Numbers
	--set {x, y} to {wLeft + 33, wTop + 46} # used for "VeraCrypt"
	set {x, y} to {wLeft + 190, wTop + 176}
	set h to 20 # was 18 for "VeraCrypt"
	set slotNum to 15 #  may be 1 thru 20
	tell me to do shell script "/usr/local/bin/cliclick c:" & x & "," & (y + slotNum * h)
end tell # Application System Events
--tell application "Numbers" to activate

Here I disabled the instructions which I used to get useful infos.

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

Edited to take care of table small enough so that there is no value indicator in the scroll bar.

It runs with 17-18-19-20-21 that is all the testing I did. it does not run with 16.

The numbers script does not run for me, but not important I think.

Which value were you changing, slotNum or h ?
At first thought, I guess that you changed h but I am not sure.

I borrowed h = 18 from your screenshot so, it’s not guaranteed to be the good value.
I wish to know what you get with : slotNum = 19 and h = 18.
Maybe it select Slot18 or Slot19 or Slot20.

OK, I tested with a large table so there was a value indicator in the scroll bar.
I will edit my original message to get rid of that.

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

set h to 18 # EDITED not sure that it's the correct value, may be 19 or 20
set slotNum to 19 -- change as needed # ADDED to select slot 2, may be 1 thru 20

--this does not work.  it takes no further than slot 12 and 13.  these are the ones (1-13) that are visable in the window when VC opens.  

set h to 20 # EDITED not sure that it's the correct value, may be 19 or 20
set slotNum to 12 -- change as needed # ADDED to select slot 2, may be 1 thru 20 

-- this works too but again not more than 13.

set h to 21 # EDITED not sure that it's the correct value, may be 19 or 20
set slotNum to 12 -- change as needed # ADDED to select slot 2, may be 1 thru 20 

-- with this it selects slot 13.  if I do 13 instead of 12 it does not work.

OK.
I added some instructions in message #37.
Now, if I understand well it’s supposed to work quite well with slotNum in the range 1 thru 20.
I’m not sure that setting slotNum to 15 would really select slot15.
It may be ruled by editing the instruction : set slotNum to slotNum - 9 # MAYBE must be slotNum -8 or -10
If it selects slot14 try with : set slotNum to slotNum - 8
If it selects slot16 try with : set slotNum to slotNum - 10

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

Morning Yvan,

all in all it works like I would like it to work.

I ran some experiments this AM and up to

set slotNum to 8

it ran as expected.

9 did not do anything. 10 gives 9. 11 gives 14. 12 gives 15. after that it changes more and some numbers do not work. but with a bit of trial and error you can fined the number that selects the slot.

However with it working up to slot 8 I am more than happy with it.

Thank you.

I edited again message #37.
Now it’s supposed to work well with slotNum in the range 1 thru 13.
For greater values, make tests.

As I am really curious, I wish to get a screenshot of the window when the script is triggered with the variable slotNum set to 18.

set {x, y} to {wLeft + 33, wTop + 46} # MOVED
set slotNum to 18 #  MOVED. as is select slot ??, allowed range : 1 thru 20

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

works a dream

pic here https://ibb.co/JdgQhxw

Thank you.

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

well really it is me who has (and wants) to say THANK YOU! Thanks you!

On your late screenshot I see that the app may display many more slots.
What is the higher number?
I see that clicking button 3 once reveal slots 13 thru 25.
What would reveal clicking it twice ? slots 26 thru 38 or slots 25 thru 37 ?
Knowing that it seems that it would be easy to enhance the script, so that it may treat every value :wink:

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

well as far as I am concerned we are there. however if you feel like an other challenge, are you sitting, it has 64 slots.

After numerous test with the Numbers version I made several changes.
The main one replace

set {wLeft, wTop} to its position #
set {x, y} to {wLeft + 33, wTop + 46}

by

set {wLeft, wTop} to position of scroll area 1
set {x, y} to {wLeft + 33, wTop + 9}

which, at least with Numbers is more precise.

With that and the new values given to lim2, lim3, lim4 & lim5 the version dedicated to Numbers selects the correct slot in every case.

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

Nope, I get:

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
	get position of scroll area 1 of window "VeraCrypt" of application process "VeraCrypt"
		--> error number -1719 from scroll area 1 of window "VeraCrypt" of application process "VeraCrypt"
Result:
error "System Events got an error: Can’t get scroll area 1 of window \"VeraCrypt\" of application process \"VeraCrypt\". Invalid index." number -1719 from scroll area 1 of window "VeraCrypt" of application process "VeraCrypt"

Oops, I’m really an ass.

There is a scroll area in Numbers, not in VeraCrypt.
I will make the scheme able to treat both cases.
The edited code will be available soon.

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

The edited version dated 2019/12/20 09:35 is available