AppleScript and InDesign CS6: minimum document size error? - applescript

Let's do an experiment. Using InDesign CS6, make a new document that is 1" x 1". No problem here, right?
Now run this script:
tell application "Adobe InDesign CS6"
set page width of document preferences of active document to 1
end tell
Should be easy, right? You're just telling InDesign to set the document size to a size it already has.
error "Adobe InDesign CS6 got an error: Data is out of range." number 30481
Just what in the blazes is going on here? I'm able to get applescript to set the page size down to 1.0139 inches -- but no smaller. Anyone have an idea?

Related

Change the text's font in current layer in Photoshop using AppleScript

I want to change the text's font in current layer in Photoshop using AppleScript, but I am new to AppleScript. By looking up the Photoshop's script dictionary, I know how to reach to the current layer so far:
tell application "Adobe Photoshop CC 2018"
tell current document
tell current layer
... <= What should I do next?
end tell
end tell
end tell
But I don't have clue what to do next, I can't find related properties in the dictionary to continue to reach the text in the layer. Could somebody shed some light on this? Thanks!
Finally I figured out the solution:
tell application "Adobe Photoshop CC 2018"
tell current document
tell current layer
if kind is text layer then
set font of text object to "<font-name>"
end if
end tell
end tell
end tell

Applescript to make the next tab the current document in Photoshop

I'm nearing the end of finishing an application that uses Google Vision to identify articles of clothing, and automatically crop to the article in Photoshop.
The first script I have goes through all of the open images and grabs their dimensions and file paths. Those are then passed to my application to do the rest of the magic.
I ran into an issue where it just kept cropping the same image over and over again. After a bit of debugging I realized that this is due to the fact that it will only crop the image that is "active" in photoshop.
So, I'm faced with the task of needing to call another script that sets the next tab as the active document in PS before hitting the crop function.
I was hoping for something easy like:
tell application "Adobe Photoshop 2020"
set currentDocs to documents
set currentDoc to next item of currentDocs
end tell
Well, that doesn't work...
tell application "Adobe Photoshop 2020"
set currentDocs to documents
-- set myList to {}
repeat with n from 1 to count of currentDocs
set currentDoc to item (n + 1) of currentDocs
end repeat
end tell
This works, but errors after the last tab because it goes out of bounds. (not sure how to stop that?) And the fact that it's in a loop doesn't help either. I just need a simple script that sets the currentDoc to the NEXT open image. Then I Can crop, move to the next image, crop, etc.
But it also needs to know the last tab so it doesn't go back through the images.
Use the repeat with loopVariable (in list) syntax instead.
Then set current document in each turn of the loop.
For example, the following loops over all open documents and crops them to 100 x 100 pixels:
tell application "Adobe Photoshop 2020"
repeat with doc in documents as list
set current document to doc
crop doc bounds {0, 0, 100, 100}
end repeat
end tell

Need an Applescript to go to a specific slide number in PowerPoint

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

Using applescript to change stroke weights conditionally in Illustrator CS6

I was trying to use this code.
tell application "Adobe Illustrator"
tell front document
set properties of every path item whose stroke weight is less than 0.2 to {stroke width:0.2}
end tell
end tell
I see no reason why it shouldn't work, but it gets hung up on the phrase "path item." I don't understand what else I should do! I'm trying to get this to work in Illustrator CS6.
Full disclosure: I'm doing this on CS4, but it really should be the same, although I suppose it is possible (unlikely) that "stroke width" changed to "stroke weight". I think you also need to specify the layer. Try something like (of course you'll have to specify the correct layer) this; it works for me:
tell application "Adobe Illustrator"
tell front document
set stroke width of (every path item of layer 1 of it whose stroke width is less than 0.2) to 0.2
end tell
end tell

Set bounds of Screen Sharing window no longer working in Lion

I use my Mac Mini to play movies and music on while working on my MBP. I like to keep screen sharing open but reduced in size in the upper right corner of my screen so that I can effectively have a "PIP". When I want to tag a song that is playing or change the movie, I use a key command to make the window full size, then another key command to shrink it back and position it in the upper right corner.
Since I updated to Lion, I've been getting the following error:
error "Screen Sharing got an error: Can’t set window 1 to {1191, 22,
1441, 185}." number -10006 from window 1
The code is below. Does anyone know what I'm doing wrong?
tell application "Screen Sharing"
activate
set the bounds of the first window to {1191, 22, 1441, 185}
end tell
I have also tried changing the code to use the wording "set the bounds of window 1..." but get the same error.
Any help would be much appreciated.
--Adam
If you look at the applescript dictionary for the application, it doesn't know those commands (e.g.. window or bounds). It only knows the GetURL command so it certainly won't work.
However there is another option. System Events knows about windows and it knows the size and position commands. So you can use that instead...
tell application "System Events"
set ssProcess to first process whose name is "Screen Sharing"
tell ssProcess
tell first window
set position to {0, 20}
set size to {605, 400}
end tell
end tell
end tell
tell application "Screen Sharing" to activate

Resources