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