How can I automate application installations that have dialog boxes that need input? - applescript

I am trying to install the downloaded application programatically, hence I am using apple script for the same since am working on Mac.
Here I've downloaded the Adobe AIR Installer app from adobe site which is in downloads folder and am trying to install the same with the below applescript code. Here when the Adobe AIR setup dialog box opens, I need to click on "I Agree" button to install the app.
With the below code am not able to click on the "I Agree" button, even i dont have Xcode Accessibility Inspecter do inspect the element. Pls guide me the script to handle the "I agree" button.
try
tell application "Finder"
activate
open application file "Adobe AIR Installer.app" of folder "Applications" of startup disk
set this_image to open this_file
delay 5
tell application "System Events"
click button "I Agree" of window "Adobe AIR Setup"
end tell
end tell
end try

You could try GUI scripting the commands with delays in-between clicks, but it's a little bit of work. Since the Adobe installer doesn't support clicking from applescript, you will need to download ExtraSuite and follow along with this previous MacScripter post.
To get pixel coordinates, start up the installer without AppleScript and type '⌘ + shift + 4' to get the crosshairs with pixel location (usually used for taking screenshots). Write down the coordinates for the first button and then hit 'esc' and move to the next button.
This is a pretty painful way to get the job done but there aren't many other alternatives that I know of.

It looks like the Adobe installers don't use Cocoa and aren't scriptable. You might have better luck with Sikuli. It's based on matching bitmaps and doesn't depend on any underlying framework.

Related

How to get current playing song on mac by command line tools?

I can only find some applescripts on Google with specific music app(like itunes, spotify, etc) to get current playing song.
But now I'm using Netease Music which not supporting to be controled by applescript, I wonder if there is any universal way to get current playing song info via mac media center?
Applescript and other command line tools both ok.
I made a cli tool that lets you read properties from the private MediaRemote framework.
https://github.com/kirtan-shah/nowplaying-cli
Since it uses private APIs, it may break with future macOS updates but is currently working on Ventura 13.1.
Here is an example that will retrieve the song name:
This following AppleScript code uses UI scripting to retrieve the currently playing media.
tell application "System Events" to tell process "Control Center"
click menu bar item "Control Center" of menu bar 1
set currentlyPlaying to value of static text 3 of window "Control Center"
key code 53 -- press 'esc' key
end tell
activate
display dialog currentlyPlaying with title "Currently Playing" buttons ¬
{"OK"} default button 1 giving up after 3

OSX Photos video play/pause Applescript shortcut

There is currently no keyboard shortcut to play videos in the new Mac Photos application.https://discussions.apple.com/thread/6996731?start=0&tstart=0
Rather than be frustrated in manually clicking the "play" button hundreds of times, I would like to run an Applescript to play/pause with a keyboard shortcut. I tried with no success:
tell application "photos"
"play" video
end tell
Any help advice on this would be appreciated.
Thanks
Just to update Paul's response, in Photos 2.0 (3150.4.120), you need to hit TAB twice, then spacebar will start playback. Similarly you need to hit TAB twice once you are done playing it, and then (and only then) spacebar will take you back to the grid view of your thumbnails.
If you do not mind a slightly time-consuming workaround, you can enslave Automator to create a Service that will subsequently respond to a keyboard shortcut. You can find the instructions here.
Since your goal is to use the keyboard, there's a better option for you. After selecting a video with cursor keys or mouse, press space to maximize the video, and then press TAB. Then space will start the video playing, left and right arrows will move frame-by-frame. Hitting TAB again will allow the space bar to return the video to its normal size.
Apparently this changes the focus to the pane with the movie so that space can start it, or perhaps it changes focus to the movie controls? IMHO, whatever it does, it's not very intuitive and badly needs to documented and preferably fixed.
More info at:
https://discussions.apple.com/thread/6996731?start=0&
2020 / Photos 6.0:
You can now toggle playback with Option + Space
or do it manually via "Image" -> "Start Playback".
Autoplay Script
repeat while application "Photos" is running
delay 1
try
tell application "System Events"
tell process "Photos"
click menu item "Start Playback" of menu "Image" of menu bar 1
end tell
end tell
end try
end repeat
Save it as autoplay.scpt and run it with osascript autoplay.scpt.
The script exits when you close the Photos application.

AppleScript to Launch 1Password mini

I use 1Password to store my passwords, and fluid.app to create a few site-specific apps/browsers
While 1Password integrates well with Chrome, Safari and other browsers, it doesn't play nicely with Fluid apps, which is where my troubles lie.
I have therefore created a shortcut (with Keyboard Maestro) to run an applescript to open the mini, when I am in Fluid apps. However, I can't seem to get the applescript to launch the mini. Here are my attempts:
tell application "1Password mini" to launch does nothing, though AppleScriptEditor doesn't report any errors
tell application "1Password mini" to open nothing, though AppleScriptEditor doesn't report any errors
tell application "1Password mini" to activate is pointless, as 1Password mini is already activated
tell application "1Password" to open opens the main 1Password application, not the mini, which is what I need.
Interestingly, when I run (1), (2), and (3), AppleScriptEditor automatically replaces 1Password mini with 2BUA8C4S2C.com.agilebits.onepassword-osx-helper, which doesn't clarify things for me at all.
Does anybody have any clue how this can be solved?
I'm on OSX 10.10.2 (Yosemite), if it matters
I work for AgileBits, the developer of 1Password.
Looks like you found a solution, but here's another option for you:
open location "x-onepassword-helper://search/"
That AppleScript will open 1Password mini ready to search.
And if you're able to get the current website's domain from Fluid, you could even open 1Password Mini with a search term already filled in:
open location "x-onepassword-helper://search/twitter.com"
I hope that helps!
The solution was quite simple, with a little UI scripting:
tell application "System Events" to tell process "1Password mini"
tell menu bar item 1 of menu bar 1 to click
end tell

How to check the checkbox of Adobe Installer with the Aplescript?

am trying to Install Adobe Flash Player, I want to check the check box and need to click on Install button, Whem am trying to get the entire contents of window thru UIElementInspector, am unable to get the contents of checkbox and Install buttons..
I just tried myself with the below script to click the checkbox, but did not succeed, error saying unable to get the checkbox.. Pls suggest how to check..
tell application "System Events"
tell process "Adobe Flash Player Install Manager"
set frontmost to true
click the checkbox "I have read and agree to the terms of the Flash Player License Agreement" of window "Adobe Flash Player 11.5 Installer."
end tell
end tell
Pls check the below link to view the image of the Adobe Flash Player Installer.
https://docs.google.com/document/d/1yzyBTrvi94QxjlEAlcbudOBpXiTGPEI2LA3D1iEo8Gw/ edit
Download this S/w:
http://pfiddlesoft.com/uibrowser/downloads/UIBrowser222.dmg
Install it.
You can simply use this tool to read the name of checkboxes and all.
For ex: if you attach a application which is having a window and a checkbox within it you can check that checkbox simply by following script:
tell aplication "system events"
click checkbox 1 of window 1
end tell
Just remember to keep the window on front most amongst other windows.
You can attach your process by clicking target pop-up button present in the UI Browser app.
Then click on Switch to screen reader option.
Now you can just see the names of the buttons, controls, checkbo

AppleScript code that clicks a button in NSAlert

I have an mac application that once opened (in awakeFromNib) shows the user an NSAlert with two buttons, one with "Option1", the other with "Option2". I would like to automate the following flow:
Open the application from the Applications folder.
Choose "Option2" by clicking the button in the NSAlert
So far I've managed to do only the first part:
tell application "Finder"
activate
make new Finder window to startup disk
open application file "My Application.app" of folder "Applications" of startup disk
close Finder window 1
end tell
Can anybody help me with the code? I understand that I can use the System Events commands to catch this click event, but can't manage to find any help online for clicking a button in an NSAlert, and not in a regular Window.
You might try this...
tell application "My Application" to activate
delay 5
tell application "System Events"
tell process "My Application"
click button "option 2" of window 1
end
end
How many windows do you have open? It's probably getting confused.
If you need to the program UI Browser can generally find the proper terms for GUI Scripting. I'm not sure it's worth buying just for this but you can run the program in demo mode for a month and use it to find the proper terms.
http://pfiddlesoft.com/uibrowser/

Resources