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.