AppleScript stopped working with VeraCrypt after update to VeraCrypt 1.25.4

ChangeAgent

Registered
I have the following script that worked fine under version 12.4 Update 8 but stopped working when I upgrade VeraCrypt to the newer version (1.25.4). I use OS 11 by the way and presently have reversed back to VeraCrypt 1.24 as I need the encrypted/decrypt files almost on a daily basis.

I found the original script a while ago on the MacScripter forum and must admit that I do not understand all the steps it makes, even after reading all the posts there. However, it worked so I used it ever since as it makes login into a file super easy.

As said, I am not very good at scripting and there could be no way I would be able to write this type of script on my own. I hope there is a wizard out there that can help me out here.

Thanks.

AppleScript:
use AppleScript version "2.4"
use scripting additions

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
delay 0.5
if not (exists window "VeraCrypt") then error "The window VeraCrypt is not available"
tell window "VeraCrypt"
set {wLeft, wTop} to its position
set {x, y} to {wLeft + 33, wTop + 46} # MOVED
# Edit this instruction to change the slot to select
set slotNum to 1 # MOVED. slotNum may be in the range : 1 thru 20
-- get its position # May be useful to check the values in the property slots
-- get position of groups # May be useful to check the values in the property slots
-- get size of groups # May be useful to check the values in the property slots
tell scroll bar 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
# slotNum = 1 -> select slot 1
# slotNum = 2 -> select slot 2
# slotNum = 3 -> select slot 3
# slotNum = 4 -> select slot 4
# slotNum = 5 -> select slot 5
# slotNum = 6 -> select slot 6
# slotNum = 7 -> select slot 7
# slotNum = 8 -> select slot 8
# slotNum = 9 -> select slot 9
# slotNum = 10 -> select slot 10
# slotNum = 11 -> select slot 11
# slotNum = 12 -> select slot 13
if slotNum > 13 then # EDITED so that it's supposed to behave well for slots 1 thru 13
click button 3 # moves a page down to display slots 8 thru 20
# slotNum = 14 -> supposed to select slot 14 but select slot ?
# slotNum = 15 -> supposed to select slot 15 but select slot ?
# slotNum = 16 -> supposed to select slot 16 but select slot ?
# slotNum = 17 -> supposed to select slot 17 but select slot ?
# slotNum = 18 -> supposed to select slot 18 but select slot ?
# slotNum = 19 -> supposed to select slot 19 but select slot ?
# slotNum = 20 -> supposed to select slot 20 but select slot ?
# It appears that for slots higher than 13 you will have
-- to make tests to learn what is returned for every value.
set slotNum to slotNum - 12 # DON'T EDIT THIS INSTRUCTION !!.
end if
end tell # scroll bar 1
end tell # window "VeraCrypt"
end tell # process Veracrypt

set h to 18 # EDITED not sure that it's the correct value, may be 19 or 20

tell me to do shell script "/usr/local/bin/cliclick c:" & x & "," & (y + slotNum * h)

-- 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/FileName" --Change as needed
end tell # combo box 1
click button "Mount"
end tell # window "VeraCrypt"
end tell # process VeraCrypt
end tell # Application System Events

delay 50

tell application "VeraCrypt" to quit

This is the line where I get the error when using the newer version:

AppleScript:
if class of UI elements contains value indicator then -- > {value indicator, button, button, button, button}

The error message I get is:

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

Hoping somebody can help me out here. Thanks.
 
Not a help, I'm afraid... but, you did post in another thread that you could not post that script without modifying a particular element. You might want to edit your post to reflect where you made those changes -- just so someone who can interpret that script will not get thrown off the path by a modification that you had to make from the original script, so you could post it.
Looks like there were four (4) different lines that you might have changed?

Code:
 -- > -- >  >-- > --

Just so you know, I could not post that character set without a space between the -- and the > so I see the same issue, but then it's and area where I don't have much experience.
 
hmm... OK, but I have a question for @Satcomer:
Just for a bit of clarification -- How would you change the above AppleScript to reflect a change in Swift, and why would that AppleScript involve Swift in the first place ( just curious why your reply went in that direction!)
 
Thanks folks.

@DelatMac. The change did not effect the script as the -- > is only used to reflect a comment.

Anybody have a solution to my script challenge here?
 
OK solved it in case anybody else looks for this.

AppleScript:
do shell script "open -a VeraCrypt --args '/Volumes/Path/ToFile/NameOfFile.xxx' /Volumes/NameOfFile"

And for that much more elegant.
 
Back
Top