I run the following code in Terminal:
osascript "/Users/Me/Desktop/Run this script on wake.scpt"
If the first dialog of my .scpt file is a
choose from list dialog, then this dialog will be unselected. That is, I cannot simply hit the enter key to press "OK"; I must first click anywhere on the dialog to make the top bar of the dialog change from white to grey, and only then can I hit enter to proceed.
To be clear, the dialog comes to the front just fine - it is simply not selected.
However, if the first dialog is a
display dialog or
display alert dialog, then the dialog is automatically selected. It just so happens that the initial dialog of my .scpt file is a
choose from list dialog.
I tried writing
activate me on the line above the
choose from list dialog, but this did not do anything.
When I run the "Run this script on wake.scpt" from within Script Editor, the
choose from list dialog is in fact selected. Hence, we know that the issue is related to
Does anyone have a workaround to force the
choose from list dialog to be automatically selected?
I've tried implementing a default selection by inserting the
default items parameter in the
choose from list command (even though I don't actually want a default item to exist in this case). I thought that doing this might force the dialog to be selected. But, still, the list dialog is unselected.
As a last resort, I suppose that I could use AppleScript to mouse-click the center of the screen (where the dialog is located). But, I'd prefer a more elegant solution, as AppleScript can be unreliable when it comes to mouse clicks.
If you are wondering why I am employing
osascript in the first place, it is because I am using SleepWatcher to automatically run an AppleScript when my computer wakes from sleep. (Here is a very helpful guide that I used to set up SleepWatcher.)
This is the full text of my .wakeup file:
#!/bin/bash osascript "/Users/Me/Desktop/Run this script on wake.scpt"
activate application "Terminal"NOT "me" (= osascript) …