AppleScript: Clicking a button in a dmg file I am trying to figure out what code will send 2 clicks to open a file in an opened .dmg file using AppleScript in Script Editor.
I did create the .dmg file
I've been searching for ways to create a working code that will switch to the opened .dmg file and click on a file in the .dmg twice to open it wherever the .dmg has been placed on the screen/screens. Here's the harder part, I would like anyone to be able to use it. The (possible) good thing is that the code's script file that I want to execute will be in the .dmg (I don't officially know if that's a good thing or not).
Please be advised that I know little to none about code and this is my first time working with it.
The closest code I have found that &quot;might&quot; work is shown below:

The link for ^this^ code is shown below. It is on this website:
Using AppleScript to click radio buttons
If you need more detail or anything else, please ask me in the comments below! Help and advice are really appreciated! Thank you!
The code snippet you borrowed doesn't relate to what you're trying to achieve, so you can safely throw that away.
Try to avoid looking for solutions that involve simulating clicks or keypresses, as these sorts of scripts are really case-specific, liable to break easily and frequently, and prohibit any additional interaction between the user and the computer whilst it is running.
A .dmg file (or disk image) is an item on the filesystem, which means it can be manipulated using AppleScript.  You don't even have to have the .dmg window open.  It sounds like you already know the name of the file you wish to be opened.
Let's say that when you double-click your .dmg file to mount (open) it, the name of the disk that appears on your desktop (or in the sidebar of a Finder window) is &quot;my dmg&quot; (this may be different from the name of the .dmg file itself, but it may be the same).  Let's then say that there's a file called &quot;some file.txt&quot; contained within the disk image that you wish to open.  The path to this file will be located at: /Volumes/my dmg/some file.txt
Therefore, your entire AppleScript that will open the file (as if the user had double-clicked on it) will be:
tell application id &quot;com.apple.finder&quot; to open the ¬
        POSIX file &quot;/Volumes/my dmg/some file.txt&quot;

or alternatively:
tell application id &quot;com.apple.finder&quot; to open ¬
         file &quot;some file.txt&quot; of disk &quot;my dmg&quot;

Both of these scripts are essentially identical.
However...
A limitation of both the method I've outlined above, and of your original notion involving simulated clicks, is that you won't be able to dictate that the file being opened should appear on a different desktop/screen that isn't the one that is currently active.
Clicking on the file necessarily means that the active desktop/screen switches to the one on which the window containing the file is open.  You can perform a similar switch to in AppleScript, so that the desktop/screen on which the .dmg file is open becomes the active one:
tell application id &quot;com.apple.finder&quot;
    open disk &quot;my dmg&quot;
end tell

This would be incorporated into the previous code to produce a combined script that looks like this:
tell application id &quot;com.apple.finder&quot;
    tell disk &quot;my dmg&quot;
        open it
        tell its container window
            open file &quot;some file.txt&quot;
        end tell
    end tell 
end tell