Sitemap

Amicuk Programming Answers

[JS  CS3] Apply Italics with scripting

-0001-11-30   Views:0

Advertisement

There's a keyboard shortcut called "Apply Italics", which by default is [cmd]+[shift]+[i] on Mac, and  [ctrl]+[shift]+[i] on Windows. I use it often because it will change text to the correct italic style. For instance text with the style "

There's a keyboard shortcut called "Apply Italics", which by default is [cmd]+[shift]+[i] on Mac, and  [ctrl]+[shift]+[i] on Windows. I use it often because it will change text to the correct italic style. For instance text with the style "85 Heavy" will change to "86 Heavy Italic" or "Semibold Display" to "Semibold Display Italic".
Is there any way to access "Apply Italics" with scripting? The action is not available in any menu as far as I know.

The replay answer
Advertisement
I made this script which will change all text with the character style "I" into proper italics, and creates corresponding character styles. "I" is just a character style with no properties. It gets applied when I import content into InDesign.
I will end up with styles called "I 37 Thin Condensed Oblique", "I Italic Display" and so on according to the various fonts.
function applyItalic(){ // Finds all text with Character Style "I" applied in the current document and changes it to proper italic character styles
     var mySelection = app.selection;
     var myDoc = app.activeDocument;
     var myRanges = myDoc.stories.everyItem().textStyleRanges.everyItem().getElements(); // gets every textStyleRange in the document;
     var italicStyle = myDoc.characterStyles.itemByName ("I"); // this character styles has no attributes;
     if (italicStyle == null){
          return;
     var myRange;
     var myFont;
     var newStyle;
     var newStyleName;
     var n;
     for (n=0; n<myRanges.length; n++){
          myRange = myRanges[n];
          if (myRange.appliedCharacterStyle==italicStyle){
               app.select(myRange);
               app.menuActions.itemByID(119611).invoke(); // apply italics - same as [cmd]+[shift]+[i]
               myFont=myRange.appliedFont;
               newStyleName="I "+myFont.fontStyleName;
               newStyle=myDoc.characterStyles.itemByName(newStyleName); // if the style is created
               if (newStyle==null){
                    newStyle=myDoc.characterStyles.add({name: newStyleName, fontStyle: myFont.fontStyleName}); // if the style does not exist yet
               myRange.appliedCharacterStyle=newStyle;
     app.select(mySelection); // restores the original selection
applyItalic();

Go to See the other 12 answers

[JS  CS3] Apply Italics with scripting

Category:DefaultRelease time:-0001-11-30Views:130

There's a keyboard shortcut called "Apply Italics", which by default is [cmd]+[shift]+[i] on Mac, and  [ctrl]+[shift]+[i] on Windows. I use it often because it will change text to the correct italic style. For instance text with the style "[More]

Problems applying preboot imaging script bundle w/ 11.3.2

Category:DefaultRelease time:-0001-11-30Views:130

Hi all, Just wondering if its just me with these issues. I had our preboot imaging script bundle assigned to the Workstation folder within the ZCC, but since the update to 11.3.2 when attempting to apply the imaging script bundle to a device within t[More]

Update Script Problem CS2 to CS3 ( Time/Date/Year Script NOT WORKING IN CS3?

Category:DefaultRelease time:2015-10-11Views:130

The below script works in CS2 but not in CS3? WHY? //DESCRIPTION: Use to insert date/time into document. if (app.documents.length == 0) { exit() } insertDTs(app.documents[0]); function insertDTs(aDoc) { var curPrefs = aDoc.characterStyles[0].extractL[More]

[JS CS3] Preflight info through scripting

Category:DefaultRelease time:2015-10-11Views:130

Hi! Is it possible to generate the preflight information text from a javascript in InDesign CS3? I know it's possible to generate the preflight text (file) by exporting a package (document.packageForPrint), but what about the separate "Preflight"[More]

[JS] CS3 Apply document defaults to insertion point

Category:DefaultRelease time:-0001-11-30Views:130

Is there any way to apply the document defaults to an insertion point? I have a script that is looping through a whole bunch of text files, formatting them (with thinks like tab stops and indents). The thing is I don't want any of the tab stops, inde[More]

CS3 JS fonts example script

Category:DefaultRelease time:-0001-11-30Views:130

I've been changing the fonts example script and would like to apply the font type as the script creates the string of font names. I've added the line  myString.appliedFont = app.fonts.item(myFontNames[myCounter]); which should apply the font type but[More]

How to get certain applied styles using script?

Category:DefaultRelease time:-0001-11-30Views:130

Hi All, I need to know how to get certain applied styles using ID Scripting. I don't have much experience in InDesign so need some help. Here is a screenshot with a sample text with the said styles applied and highlighted. I need to know what texts i[More]

Apply Nested Styles Script not working for me anymore

Category:DefaultRelease time:-0001-11-30Views:130

//DESCRIPTION: Applies nested styles as directly applied character styles.         WARNING: This script will override any character styles which are directly applied to the text with the nested styles applied, and formatting might change! (function()[More]

GPO apply user Logon script or GPP who Wins

Category:DefaultRelease time:-0001-11-30Views:130

hi i have 2 GPO's linked to a OU1 GPO with precedence 1 has a GPP setting which applies a Value  the 2nd GPO has a Logon script which applies a value that is different that the 1st GPO How does Precedence take place if both have conflicting settings.[More]

Applying my apple script to a filetype

Category:DefaultRelease time:-0001-11-30Views:130

I got help making the below applescript. There's someone who uses Windows and sends me .url files that I need. I want to be able to double-click these files and have them open in Firefox on Snow Leopard. The below script does the heavy lifting but I[More]

Apply Find & Replace Script to .INDB?

Category:DefaultRelease time:-0001-11-30Views:130

Hi Chaps, Is there a way to apply a Find and Replace-type script to an InDesign Book (CS4 > .indb)? I have a .indb file that my have a number of documents, each with the term "EURO" in a number of tables. I want to change this to "GBP&qu[More]

Hot
My ipod touch lost all its data due to my computer crashing and having to be rebooted. This resulted in all software being wiped - including iTunes. Therefore, I lost all my music, apps etc on my library on the computer. I then synced my iPod into th [More]
Every time I sync my iTouch I get the following message - "iTunes could not back up the iPod because the backup was corrupt or not compatible with the iPod.  Delete the backup for this iPod, then try again."  However, when I follow these instruc [More]
All of my TV Shows have movie poster sized artwork.  The Apple TV displays movie poster art for Movies, but it displays square CD-style artwork for TV Shows.  Is there any way to get the Apple TV to display movie poster sized artwork for TV Shows?  S [More]
I have a MacBookPro 2Ghz running on OSX.4.8, and I can't seem to get Garritan Personal Orchestra to run in Logic. Is it due to the new Pentium processor? If so, is there a way to at least get the Garritan sounds into Logic, if not the actual player i [More]
Ok today I called Best Buy service and was surprised to say  the experience was exceptional. They were helpful and knowledgeable and got me a new part ordered and Service called booked in about Minis. For those of you with a Sony rear projection TV y [More]
i got my ps3 & xbox to connect it was easy but when i go to connect my iphone it doesnt even let me put my password in it just says"cant connect"? PLEASE HELP.How is the router configured? What is the security mode in the router? Does any ot [More]
Dear experts, I get an error Another user modified table (NNM1) when trying to add a numbering series to any of the document. i have recently upgraded to 2007 B PL 10. only after this i face this problem. Please help me.. thanks and regards, Yeshwant [More]
Now my ipod touch 4 need to be connect to itune but when I connect USB it doesn't appear in itune and I can do nothing on my ipodDevice Not Recognised  For PC  >  http://support.apple.com/kb/TS1538 For Mac  >  http://support.apple.com/kb/ts1591Read [More]
I accidently recorded 3 vocal tracks in stereo. Is there a way to change them to mono without having to re-record them? They only come out of 1 speaker now no matter what I do. I'm in GB3. Thanks in advance RandyFirst, I didn't mean to be rude, hence [More]
Hello. I have a Vivitar 3 in 1 Mini Digital Camera. It does not show picture on my MacBook. It is a Still Camera, a Video Camera, and a Webcam. I've tried to use macam to get the webcam picture, and it recognizes the Camera, but it just won't display [More]