Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Change Agent

macrumors regular
Original poster
Oct 24, 2018
153
11
As said, VeraCrypt script stopped working after I updated it to latest version of VeraCrypt (VeraCrypt 1.25.4), I presently use version 12.4 Update 8.

I have the following script that worked fine under the above mentioned version of VeraCrypt but stopped working when I upgrade VeraCrypt to the newer version (VeraCrypt 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 the posts in it. 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 somebody out there can help me out here.

Any ideas why it is no longer working? Is there anybody out there that uses VeraCrypt_1.25.4 and can help me to get it to work again?

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

The script hangs on the line:

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

The error message I get is:

AppleScript:
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"

I hope somebody can help me out here, because I am stuck with it.

Thanks.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.