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
Hi All, Can you please give me idea for the following The idea is to having, some users will enter data in Input Schedule and save it as excel. This is ok The problem here is how can we notify to the Manager that the excel is ready to review? after t [More]
Hi all, i am trying to store blob type data using entity bean, The corresponding field in the Entity bean is defined with data type byte[ ] , and i'm getting error while creating entity bean, could anyone please help me! This is the error: [6/7/06 11 [More]
Hello. I have purchased the full version of VMware Fusion 1.1.2 and installed it on my MacBook running Mac OS X 10.5.2. I also have Windows XP SP2 installed via Boot Camp, which works fine. When I open VMware Fusion, in the list box labelled "Virtual [More]
I have upgraded and installed Internet Explorer 9.  Firstly, the webpagse cannot convert into pdf files.  After reading the microsoft website and installed an updated printer driver for my Adobe Acrobat 9 Pro, the webpage can be converted into pdf fi [More]
Hi, WSUS post installation failed with the below error log. Any Suggestions pls.  2015-02-04 09:47:03  Postinstall started 2015-02-04 09:47:03  Detected role services: Api, UI, WidDatabase, Services 2015-02-04 09:47:03  Start: LoadSettingsFromParamet [More]
I’m trying to understand the Event-Handling in Java. Take for example a button: How does this button -while the program is running- send Events to the Listener ? And how does it know that a Listener exists and “listen” to its Events ? Which method, s [More]
I hava a table A and table B which is a copy of A. I want to create a trigger to record the changes of A in B. So every time inserting/updating/deleting A I record the row inserted/updated/deleted in B, But I can't find a effiencial way to get the la [More]
I am trying to work out how, in SP 2013 Designer to get a very simple approval process to work and I am not having any luck. I have a form that adds a list item for requesting the use of our corporate credit card. Steps: 1) Fill out form with require [More]
I am new to the Mac world. I am just finding out that iweb is no longer avaliable as part of ilife. what can be used in it's place?iWeb still is available as part of iLife. However, MobileMe and its attendant server service, iDisk, are no longer avai [More]
Post Author: GavinS CA Forum: Administration Just a brief question about the Import Wizard.  One of the option it presents during the course of the wizard is about importing "Repository Objects".  This may seem a silly question, but what is a &q [More]