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
Mail just crashed, and whern I restated, it went back to defaults and all my accounts except .Mac have disappeared. My mailboxes are intact, except all mail in my inbox has disappeared. I know this info has to be on my HD somewhere, where do I find i [More]
Any tips for using my connecting my Macbook to my telescope and using it as a monitor for my telescope images, I have a meade with a video out, but I'm new to Macs, and am not sure on where to even start on setting it up. Thanksno, the macbook won't [More]
I have a 2nd gen iPod Touch and after 3 weeks of frustration with a Droid-X, I returned the Droid and bought an iPhone 3GS. Both the iPhone and iPod are running on IOS4. I didn't think about multi-tasking on the iPhone until today when I discovered e [More]
Hi  All, Today in our office given demo of Office 365 usages and license details , but i am little bit confused on licensing. They told we can use Office 365 Pro Plus software into 15 Device ( 5 Windows PC + 5 MAC + 5 Mobile or Tablets). I refereed t [More]
Hello, We are a school that is trying to connect to our server from our house on both mac and pc. Macs work fine but pcs don't. We have an apple xserve running 10.4 that is connected to our network with an outside ip address. If someone can help it w [More]
I like the plastic caps that pop onto the connectors that plug directly into an iBook/Powerbook jack. I'll probably lose 'em, and I'd like to get replacement caps in bulk quantity (even a purchase of 100+ caps might be acceptable to me - I lose 'em T [More]
I have a 2 tables table like this: Employee Table emp_id  region  active_date A100    01      8/19/2009 A100    01      8/21/2009 A100    01      8/27/2009 A100    01      9/2/2009 A100    01      10/1/2009 A100    01      3/27/2010 Date_Lkp Table Da [More]
I want to change the email address listed under password and security so the reset email goes to a different email address. can't find how to do this anywhere. just keep unintentionally sending reset emails to my ex bf's address which is not amusing [More]
No wifi address and no wifi function button is visible but not responding iPhone 4S have tried network reset but still no change ... Appreciate your help Neeeeeeed wifiRead here: http://support.apple.com/kb/ts1559 If nothing works, make an appointmen [More]
Hi, I have more than 100 jobs scheduled in my work repository.Difficult to maintain a spreadsheet and keep track of scheduled jobs and their scheduled timings. Are there any database tables at back end which has list of all scheduled jobs and their c [More]