I have seen these two threads that touches what I want to do:
and they seem to indicate that you need to use GUI-scripting for the open/save dialogues. Is that really true??
I am trying to make Chrome upload a file. Opening the file chooser dialogue requires GUI-scripting¹ because of web related security concerns, but when the dialogue is open I expected it to be scriptable but, at least according to the threads linked above, it doesn’t seem to be the case. Can someone confirm this?
If it is not scriptable and I am left to use GUI-scripting - what is the best way to open a file?
I know about g-shift-cmd. If I list all UI elements of the sheet that appears after g-shift-cmd it has a lot of elements:
static text "/tmp/myfile.txt" of sheet 1 of sheet 1 of window "Google Chrome" of application process "Google Chrome"
button 1 of sheet 1 of sheet 1 of window "Google Chrome" of application process "Google Chrome"
text field 1 of sheet 1 of sheet 1 of window "Google Chrome" of application process "Google Chrome"
scroll area 1 of sheet 1 of sheet 1 of window "Google Chrome" of application process "Google Chrome"
The scroll area in turn has multiple levels of other UI elements.
I have tried to send a click to the button
and double click to the text field
and the static text
, but nothing (useful) happens (sometimes the focus seems to change when I send a click).
I have never really thought about this sheet before. It feels like it is missing something - at least two buttons, Open/Goto
, or something like that, and Cancel
. It feels like my system has a hiccup here - no buttons??
In the context of GUI-scripting, operating on a button or other element referring its name feels like a reasonably stable solution.
How do I g-shift-cmd to a file and then open the file by emulating a (double)click on an element, referring said element by its name?
¹ Does anyone know if it is possible to launch Chrome/Safari in an “unsafe mode” so you can perform certain actions that normally are forbidden? Or other workarounds?