As the title says-
Is there a way to detect what slide is showing in a keynote presentation (using applescript)?
And yes, I am aware of how to change slides with applescript, I just need to detect what slide is already active.
SOLVED! >>> SEE BELOW
(Don't have enough reputation to answer my own question, so I'll just stick it here.)
I found a way round it thanks to this guy's script: http://code.google.com/p/keynotetweet/
For each slide in Keynote you get the option to attach invisible notes (not the yellow stickies, its a text box at the bottom of the page. Change the view to "Show Presenter Notes"). Here you can store a trigger string, ie "action". So create a keynote and put "action" in the notes of one slide. Start up the applescript then the slideshow, and when the slide with "action" in the notes is visible, the applescript will pick up it up and do whatever you set it to do.
repeat
tell application "Keynote"
set slideNotes to get notes of current slide of first slideshow
if text of slideNotes is equal to "action" then
say "Is this the slide you're looking for?"
end if
end tell
end repeat
Enjoy!
tell application "Keynote"
tell slideshow 1
get current slide
end tell
end tell
gives you
slide 3 of document "Untitled" of application "Keynote"
Related
The following script will open a track in iTunes
use application "iTunes"
property trackURL : "itmss://itunes.apple.com/us/album/brahms-violin-concerto-in-d-major-op-77-iii-allegro/145533236?i=145533044&uo=4"
open location trackURL
Now, asking "iTunes" to play it does not work because the track is highlighted but not properly selected, i.e., it requires a manual mouse click to select it and play it.
How can I select the highlighted track? Or how could I ask "iTunes" to play the song?! Alternatively, is there a way to add a music to my library from an URL directly?
Disclaimer: I don't have the Apple Music subscription, so the UI on my end may not be exactly the same as yours. However, if I click the "Play" button, I get the little advertisement asking me to sign up for the service, which I assume would just play the music if you had the service. So, these are the steps I've been able to follow to get that box to pop up:
The first, and most convenient from AppleScript, thing to try is just to hit the space bar to start the music playing. This actually works great if I've selected the item manually by clicking on it. However, after open location, it doesn't work, and this appears to be because even though the row is highlighted in the viewer, the actual keyboard focus seems to be on the page itself (the iTunes Store and Apple Music appear to have their entire UI presented as web pages rendered by WebKit). You can verify this by tapping the up and down arrow keys on the keyboard; the page scrolls up and down instead of you switching to adjacent tracks.
My opinion is that this is actually a bug in iTunes; I'd consider the true solution to the problem to be to report this to Apple via the bug reporter. Using open location really should set the keyboard focus to the track you navigated to.
With that said, we can work around it in the short term by simulating a click on the "Play" button. Note that you'll probably need to add your app in System Preferences > Security and Privacy > Accessibility. Note also that this is incredibly fragile, and if Apple ever changes anything in the layout of the web pages they're serving, this whole thing will break. Finally, please note that this code is extremely ugly; the whole thing gives me hives just by looking at it, but it's the only thing I was able to get to work. Side effects of reading this code may include nausea, headaches, and suicidal thoughts. Do not read this code immediately after eating. Consult your doctor before reading this code if you have a history of depression or obsessive-compulsive disorder.
property trackURL : "itmss://itunes.apple.com/us/album/brahms-violin-concerto-in-d-major-op-77-iii-allegro/145533236?i=145533044&uo=4"
property trackTitle : "III. Allegro giocoso, ma non troppo vivace"
tell application "iTunes"
activate
open location trackURL
delay 1 -- give the page a second to load
end tell
tell application "System Events"
tell process "iTunes"
set theRows to the rows of table 1 of UI element 1 of scroll area 1 of group 1 of group 1 of front window
-- "repeat with eachRow in theRows" isn't working. I don't know why. Freaking AppleScript
repeat with i from 1 to the number of theRows
set eachRow to item i of theRows
if exists group 2 of UI element 2 of eachRow then
if value of static text 1 of group 1 of group 2 of UI element 2 of eachRow is trackTitle then
tell group 1 of UI element 2 of eachRow to click
end if
end if
end repeat
end tell
end tell
If Apple ever fixes the bug, of course, we should be able to just:
tell application "iTunes"
activate
open location trackURL
delay 1 -- give the page a second to load
end tell
tell application "System Events" to keystroke space
I need a simple AppleScript that will cause PowerPoint to move to a specified slide number. I unfortunately am not familiar enough with AppleScript to properly interpret the information in the Applescript Library for PowerPoint. I think if someone can get me started I can take it from there.
The script just needs to reference the active presentation. If I could speak to my computer I just need to tell it to "go to slide #5" or "go to slide #2", etc.
The script needs to work while in Slideshow mode as the presentation will be running on a separate screen. Thanks so much for the help, I haven't been able to find this anywhere.
my gotoSlide(2)
on gotoSlide(whichSlide)
-- whichSlide is the integer position of the slide
tell application "Microsoft PowerPoint"
activate
tell active presentation
set theView to view of document window 1
go to slide theView number whichSlide
end tell
end tell
end gotoSlide
I've successfully managed to get AppleScript to manipulate the background colors in my Numbers document by refering to the background color property. However, I would like to set the borders of a selection or range of cells as well.
I've looked in the Dictionary in AppleScript Editor for a command or property that could help me out here, but I haven't found anything. Is it the case that it's not possible to create borders in Numbers with AppleScript?
There is nothing in the AppleScript dictionary to allow this functionality (which is awful, IMO, but perhaps Apple will add this in the future if enough people complain).
You can use SystemEvents to interact with the interface of Numbers to add the borders:
-- Set the selection range
tell application "Numbers"
make new document
tell front document to tell active sheet to tell table 1
set selection range to range "A3:C6"
end tell
end tell
-- Asks System Events to interact with the interface
tell application "System Events" to tell application process "Numbers"
-- Asks the main window to click on the button called 'Cell' (the name depends of your system language)
tell window 1
click radio button "Cell" of radio group 1
-- Scroll area 4 is the inspector area
tell scroll area 4
-- The first incrementor of the inspector is the borders' one.
increment incrementor 1
end tell
end tell
end tell
If you want to manipulate other elements of the interface, I recommend using the Accessibility Inspector app that comes with Xcode.
I'm trying to resize the slideshow window using Applescript and Powerpoint 2011 for Mac.
In the past I've used VBA to do the job, but here it seems impossible to do with Applescript.
The script is:
tell application "Microsoft PowerPoint"
set show type of slide show settings of active presentation to slide show type speaker
set theSSW to run slide show slide show settings of active presentation
set height of theSSW to 300
set width of theSSW to 400
end tell
(the script above is directly copied from Applescript Reference)
The problem is that the slideshow window is cropped but not resized.
That is making me crazy.
Any idea?
EDIT: Definitely there are 2 ways to launch and open a PPT file on Mac with Applescript:
In "speaker mode" the window shrinks but only a portion of the presentation is shown. the presentation is not resized but I can advance on mouse click.
In "window mode" the presentation is resized. I can view all the slide but I cannot advance on mouse click. (If I set the "window mode" manually, the mouse click works even if I THEN resize it with Applescript)
If I work on Windows this problem doesn't exist.
Flying completely blind here, but what do you get if you do:
tell application "Microsoft PowerPoint"
set ssw to slide show window of it
properties of ssw
end tell
or
tell application "Microsoft PowerPoint"
set ssw to slide show window 1
properties of ssw
end tell
What I'm looking for are the window properties that hopefully can be changed. I'm hoping to get either height and width or (as is more commonly the case) the bounds of the slide show window. I'm just not clear on the syntax for PowerPoint (don't have it).
[edit] well, I see from the pdf docs that bounds is read-only. Hm. I'd have to get my hands on the sw to test.
This (in VBA) will give you a window that displays the entire slide:
With ActivePresentation
With .SlideShowSettings
.showType = ppShowTypeWindow
.ShowScrollbar = msoFalse ' might or might not need this
.Run
End with
With .SlideShowWindow
.Height = 300
.Width = 400
End With
End with
Your presentation will need some means of advancing itself (as you've noticed).
You'd want to manually or programmatically add an advance button to each slide.
Translation to Applescript is left to the discretion of the reader.
I want to run PowerPoint slide show for only a particular slide.
After my research, I tried following but I did not get expected result.
Both of the scripts, starts slide show but from the first slide.
1)
`tell application "Microsoft PowerPoint"
activate
open "/Users/sanjeev/pppp.ppt"
set slideShowSettings to slide show settings of active presentation
set starting slide of slideShowSettings to 4
set ending slide of slideShowSettings to 4
run slide show slideShowSettings
end tell`
2)
`tell application "Microsoft PowerPoint"
activate
open "/Users/sanjeev/pppp.ppt"
set slideShowSettings to slide show settings of active presentation
run slide show slideShowSettings
go to slide slide show view of slide show window 1 number 4
end tell`
The second script gives an error also:
error "Microsoft PowerPoint got an error: slide show view of slide show window 1 doesn’t understand the go to slide message." number -1708 from slide show view of slide show window 1
I saw a question Want Applescript to change a Keynote presentation to a particular slide
But I think that works only for KeyNote.
Can anyone help?
Thanks
This seems to work. It looks buggy to me. When the script is run the screen goes black, then flashes the slide then goes black then finally displays the slide. I don't know if this is due to the script or the implementation of Applescript/ppt from Microsoft. I say the latter.
tell application "Microsoft PowerPoint"
set temp to active presentation's slide show settings
set temp's starting slide to 2
set temp's ending slide to 2
set temp's range type to slide show range
set temp's advance mode to slide show advance manual advance
run slide show temp
end tell