To make sure I understand. you are saying you think VC is not bale to have the window selected without mouse movement? that is why to recommend using cliclick?
thanks KniazidisR.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 14 décembre 2019 11:37:30
Hi Yvan,
I get an error:
error “System Events got an error: Can’t get scroll bar 1 of group 1 of window "VeraCrypt" of process "VeraCrypt". Invalid index.” number -1719 from scroll bar 1 of group 1 of window “VeraCrypt” of process “VeraCrypt”
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 14 décembre 2019 18:19:48
Morning KniazidisR
sorry folks for delay, I was on the road.
Running your script I get:
Result:
error “Can’t get CGPointZero.” number -1728 from CGPointZero
Morning Yvan, yout script returns:
tell application "VeraCrypt"
activate
end tell
tell application "System Events"
set frontmost of process "VeraCrypt" to true
exists window "VeraCrypt" of process "VeraCrypt"
--> true
exists window "VeraCrypt" of process "VeraCrypt"
--> true
get class of every UI element of window "VeraCrypt" of process "VeraCrypt"
--> {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}
(*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*)
get class of every UI element of group 1 of window "VeraCrypt" of process "VeraCrypt"
--> {}
(**)
end tell
VC activates but that is all.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 16 décembre 2019 09:25:04
it loops
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 16 décembre 2019 09:44:05
OK here is what I get:
tell application "VeraCrypt"
activate
end tell
tell application "System Events"
set frontmost of process "VeraCrypt" to true
exists window "VeraCrypt" of process "VeraCrypt"
--> true
exists window "VeraCrypt" of process "VeraCrypt"
--> true
get class of every UI element of window "VeraCrypt" of process "VeraCrypt"
--> {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}
count every group of window "VeraCrypt" of process "VeraCrypt"
--> 7
(*group 1*)
get class of every UI element of group 1 of window "VeraCrypt" of process "VeraCrypt"
--> {}
(**)
(*group 2*)
get class of every UI element of group 2 of window "VeraCrypt" of process "VeraCrypt"
--> {}
(**)
(*group 3*)
get class of every UI element of group 3 of window "VeraCrypt" of process "VeraCrypt"
--> {static text}
(*static text*)
(*group 4*)
get class of every UI element of group 4 of window "VeraCrypt" of process "VeraCrypt"
--> {}
(**)
(*group 5*)
get class of every UI element of group 5 of window "VeraCrypt" of process "VeraCrypt"
--> {}
(**)
(*group 6*)
get class of every UI element of group 6 of window "VeraCrypt" of process "VeraCrypt"
--> {}
(**)
(*group 7*)
get class of every UI element of group 7 of window "VeraCrypt" of process "VeraCrypt"
--> {}
(**)
end tell
script runs till the end.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 16 décembre 2019 10:16:22
runs without errors, but selects nothing in the window.
Log window shows:
tell application "VeraCrypt"
activate
end tell
tell application "System Events"
set frontmost of process "VeraCrypt" to true
exists window "VeraCrypt" of process "VeraCrypt"
--> true
exists window "VeraCrypt" of process "VeraCrypt"
--> true
get class of every UI element of window "VeraCrypt" of process "VeraCrypt"
--> {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}
get class of every UI element of scroll bar 1 of window "VeraCrypt" of process "VeraCrypt"
--> {value indicator, button, button, button, button}
(*value indicator, button, button, button, button*)
end tell
Now we grab the names of the buttons.
Tell me which is the one to click.
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
end tell #window
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) lundi 16 décembre 2019 12:09:35
May you try this version which is supposed to achieve the wanted task ?
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
*)
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) lundi 16 décembre 2019 21:54:18
Yvan good morning! It works! What a nice thing to wake up to. Thanks. And also thanks to KniazidisR.
Some fine tweeting if we can and if I am not over-stretching you willingness to help. See pic
As you can see there are different slots. The green one is the one selected by me. The script however takes whatever slot was selected before. That is why I scrolled up and than down in my original script. I like to be able to define the slot. Reason be is that if I load more than one encrypted volume each one needs to be in its own slot.
Your script is complex for me, and looking at it I do not know where to insert, and how, such a command.
If it is easy to do great, if not I need to live with it, I am already very happy with this result as it makes mounting a volume so much easier compared to doing it manually.
That I know, I usually operate them from the bar.
Your answer does not answer my question though, I think you misunderstood. I want to select, lets say, position 2 in VC to load the encrypted volume in that position. Positioning is important in this as one volume can only occupy one position in VC. See pic in last post of mine.
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.
your first script returns:
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
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 125
keystroke " "
keystroke "/Volumes/Data/VC/file"
keystroke "
"
end tell
the second one goes al the way to hitting the Mount button
tell application "VeraCrypt"
activate
end tell
tell application "System Events"
set frontmost of process "VeraCrypt" to true
exists window "VeraCrypt" of process "VeraCrypt"
--> true
exists window "VeraCrypt" of process "VeraCrypt"
--> true
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 126
key code 125
keystroke " "
set value of attribute "AXFocused" of combo box 1 of window "VeraCrypt" of process "VeraCrypt" to true
set value of combo box 1 of window "VeraCrypt" of process "VeraCrypt" to "/Volumes/Data/VC/file"
click button "Mount" of window "VeraCrypt" of process "VeraCrypt"
--> button "Mount" of window "VeraCrypt" of application process "VeraCrypt"
end tell
Result:
button "Mount" of window "VeraCrypt" of application process "VeraCrypt" of application "System Events"
@ ChangeAgent
In fact you posted what is returned by my 2nd and 3rd scripts.
The 1st one was supposed to return infos about groups and buttons.
script #2
is supposed to move the cursor in the window to select the wanted slot,
then it’s supposed to ‘type’ the POSIX path “/Volumes/Data/VC/file” in the dedicated combo box,
at last it is supposed to ‘type’ a linefeed to activate the default button “Mount”.
script #3
is supposed to move the cursor in the window to select the wanted slot.
then it’s supposed to fill the dedicated combo box with the POSIX path “/Volumes/Data/VC/file”,
at last it is supposed to click the button “Mount”.
What you posted show that all the instructions are executed.
What isn’t clear is if they executed the wanted tasks.
Is the correct slot selected ?
Is the mount action executed ?
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 décembre 2019 14:37:02