Force show (not toggle) hidden characters and threads in script

I have been working on a script to show all the extras (for the most part). I can turn on rulers and frame edges from the DOM, but can not Show Hidden Characters or Show Text Threads from the DOM. I've been working on using menuActions, but there two is a hitch. It seems that the menuActions are only available if the menu has been accessed during the current session? Not 100% on that. There is a good comment (#10) that touches on this a bit at Indiscripts :: How to Create your Own InDesign Menus.
This method works, but again only if the menu has been previously accessed... so it's not reliable:
// locale-independent (should work on non-english versions of InDesign)
// Show Hidden Characters
// FIX/TODO - Only seems to work if the Show/Hide Characters has been toggled within this session?!
var showHiddenChars = app.menuActions.item("$ID/HideHiddenCharactersCmdStr"); //The 'hide' ID String only valid when characters are hidden
var areCharsHidden = (showHiddenChars.isValid);
if (areCharsHidden == true) {
    try {showHiddenChars.invoke()} catch (givenError){alert(givenError.toString())};
else {
        //alert("Hidden characters are already shown!")
I also have a less desirable version of Showing Hidden Characters, which relies on English name property of the Menu Action. It suffers from the same issue.
//~     var acID = acID||
//~             ((t=app.menuActions.item("$ID/ShowHiddenCharactersCmdStr")).isValid&&t.id)||
//~             ((t=app.menuActions.item("$ID/HideHiddenCharactersCmdStr")).isValid&&t.id);
//~     var showHiddenChars = app.menuActions.itemByID(acID);
//~
//~     //if the name property for the menuAction is currently "Hide Hidden Characters", the characters are hidden.
//~     var areCharsHidden = (showHiddenChars.name == "Hide Hidden Characters");
//~     if (areCharsHidden == true) {
//~         try {showHiddenChars.invoke()} catch (givenError){};
//~         }
//~     else {
//~         //alert("Hidden characters are already shown!")
//~         }
Any suggestion on how to force show characters (show threads works the same way) with out having to have had accessed a menu before hand?
Thanks,
Kevin

When you have found a menu action you can remember its ID and use menuActions.itemByID() later on to retrieve it. Most action IDs are hard wired, bound to their implementing plugin. Of course there is an exception for dynamically allocated actions, e.g. script actions.
My first attempt following you is to retrieve the action name - that should trigger the internal method to update the whole action state including checked, enabled (not applicable in this case). Of course it failed, would someone please file a bug? The translated versions of strings that you'd use for the comparison are available via app.translateKeyString().
Btw you are using the wrong string - cmd strings are used for command history as seen in the undo menu. Menu strings usually have an ampersand character to indicate the underline / Alt+Key combo in Windows.
$.writeln(app.menuActions.itemByID(0x1d301).name==app.translateKeyString("$ID/Show Hidden Characters"));
$.writeln(app.menuActions.itemByID(0x1d301).name==app.translateKeyString("$ID/Hide Hidden Characters"));
app.translateKeyString("$ID/Show Hidden Characters")
Ergebnis: Verborgene Zeic&hen einblenden
app.translateKeyString("$ID/Hide Hidden Characters")
Ergebnis: &Verborgene Zeichen ausblenden
// failed test
$.writeln(app.menuActions.itemByID(0x1d301).name);
app.menuActions.itemByID(0x1d301).invoke();
$.writeln(app.menuActions.itemByID(0x1d301).name);
// output should change after invoke
Verborgene Zeichen ausblenden
Verborgene Zeichen ausblenden
As you found command strings, I also had a look at the undo history - it remained empty.
$.writeln(app.activeDocument.undoHistory.length);
Probably the setting is not persisted in the document any more, someone should have removed the command strings.
Then I realized that the output of the previous lines around the invoke had changed as it was expected originally. And I had not touched the menu since restart … but I had activated the application.
One can do that with scripting too - app.activate();
A couple of restarts later this is definitely leading somewhere.
Regarding the command, I also had a second look with a debug build of InDesign: the command is still executed, but there is a flag that binds its undo to the previous command - left as an exercise to verify.
Hmm. It is stored in the persistent document preferences in a structure internally called kDocWorkspaceBoss / ITextOptions, thus should also be exposed for scripting. Back to scripting: set a breakpoint, browse thru tons of document sub-objects, and here we are:
app.activeDocument.textPreferences.showInvisibles
Happy programming,
Dirk
Edit: when comparing the strings, you also have to strip the extra ampersand.

Similar Messages

  • Finding hidden characters and overriden styles

    Hello,
    I'm struggling with the following things:
    I need to check a document to see if it contains any hidden characters. Do i have to create a loop and check each of the characters? Because with a big document it is impossible to do. Or is there an easier way to do it?
    2nd question is that i need to check if any of the character styles have been overriden, i have yet to find a way to do this so any help would be highlyappreciated.

    ~ Trevor ~ wrote:
    I think I've come up with a nice technique here if I say so myself it can be utilized for umpteen properties.  To find them very quickly
    I actually think this is one of the best scripts I've written (by far no the most complicated but I think very efficient)
    Blah, Blah, Blah
    Drat, Drat, Drat!!! Darn! Egg on face!!!
    I was sure that using
    myOverRiddenStyleFlags = doc.stories.everyItem().textStyleRanges.everyItem().styleOverridden;
    while (l--) (myOverRiddenStyleFlags[l]) ? myOverRiddendTextStyleRanges.push(myTextStyleRanges[l]) : 0;
    would be a lot quicker than using
    while (l--) (myTextStyleRanges[l].styleOverridden) ? myOverRiddendTextStyleRanges.push(myTextStyleRanges[l]) : 0;
    well it's not. It is actually slower.
    On a nearly 600 page document with several thousand overrides the script took about 74 seconds to run (including making an array of the contents but not displaying it) when not using the flags and about 100 second when using them
    So this is not one of the best scripts that I have written at all and my newly discovered technique is pretty rubbish.
    Oh well, back to the drawing board.
    Anyway here's the boring old script using the good old convectional methods.
    // Script by Trevor to make an array quickly of Overridden Text Styles
    // http://forums.adobe.com/message/4853747#4853747
    #target indesign
    app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "List Overridden Text Styles");
    function main()
        var startTime = new Date().getTime(); // removable if the time alert below is removed
        var doc = app.activeDocument, myOverRiddendTextStyleRanges = [], l,
            //myOverRiddenStyleFlags = doc.stories.everyItem().textStyleRanges.everyItem().styleOverridden;
         myTextStyleRanges = doc.stories.everyItem().textStyleRanges.everyItem().getElements();
        l = myTextStyleRanges.length;
        while (l--) (myTextStyleRanges[l].styleOverridden) ? myOverRiddendTextStyleRanges.push(myTextStyleRanges[l]) : 0;
        // For the Sake of the Alert but not neaded otherwise
        l = myOverRiddendTextStyleRanges.length;
        var overRiddenContents = [];
        while (l--) overRiddenContents.push(myOverRiddendTextStyleRanges[l].contents);
        alert ("Script  took "+(new Date().getTime()-startTime)/1000+" seconds"); // removable
       // alert (overRiddenContents) // if there are a very lot of overRiddenContents this line can be problematic that's why it's escaped.

  • Show not selected anchor points (and connect)

    Hello.
    Every now and then I have the problem in Illustrator that I want to connect two anchor points with the pen tool. The two anchor points belong to different objects. Is there any way to always show all anchor points. Today I have to select one of the object to see the first anchor point I want to connect. And then hovering the point over the plaece where I presume the second anchor point is located until the mouse icon indicates that I have the pointer at an anchor point.
    A second question: Is there any way to connect more than two “lines” to an anchor point? I.e intersect and connect an anchorpoint in the middle of a line with a third anchor point.

    Almost.
    My thought was that if I could see all anchorpoints of all objects, without selecting the objects. Ie. se all "white" anchor points,  when I select them they will become "filled/blue".

  • TS5185 When I receive a text or phone call, only the number shows not their names. And it have missing contacts. Help. This just started 2 days ago.

    My phone no longer displays the names of my incoming messages or phone calls. It only shows the number. Some of my contacts are missing also. I tried to deactivate iMessage and nothing changed. Please help.

    Are you syncing contacts over the air on your iPhone with an Apple iCloud account or with another email account that supports the same?

  • Show hidden files and folders

    Is there a way to show all the hidden files and folders in Finder? Thanks in advance.

    Hi, Jon.
    The freeware application TinkerTool will permit you to enable or disable the display of hidden or invisible files.
    Be careful when working with hidden and invisible files: they are hidden and invisible for a reason!
    Good luck!
    Dr. Smoke
    Author: Troubleshooting Mac® OS X

  • How to toggle hidden files

    With the new Mountain Lion, my previous keyboard short cut to toggle "show hidden files" doesn't work anymore.  There was also a widget that you could download to do the same thing, but stored on mobileme, which is shut down.
    What can I do so I have a key stroke combo, or widget/app that toggles between showing or hiding hidden files?

    Open the Script Editor or AppleScript Editor in one of the subfolders of Applications and run the following:
    tell application "Finder" to quit
    if (do shell script "defaults read com.apple.finder AppleShowAllFiles") is "1" then
    do shell script "defaults write com.apple.finder AppleShowAllFiles 0"
    else
    do shell script "defaults write com.apple.finder AppleShowAllFiles 1"
    end if
    delay 2
    tell application "Finder" to run
    If you change your mind later, run the script again.
    (68271)

  • Dialog box type showing up as special characters

    I am not sure what I did but almost all of my dialog boxes in osx show up as special characters and therefore unreadable. Any help in fixing this would be awesome.
    heres a screen shot.

    Back up all data.
    Launch the Font Book application and validate all fonts. You must select the fonts in order to validate them. See the built-in help and this support article for instructions. If Font Book finds any issues, resolve them, then boot in safe mode to rebuild the font caches. Boot again as usual and test.
    Note: If FileVault is enabled on some models, or if a firmware password is set, or if the boot volume is a software RAID, you can’t boot in safe mode. In that case, ask for instructions.

  • Find Hidden Characters-in downloaded file

    All,
    I have a file interface that downloading file to SANS server using open dataset. But recently we are getting some hidden characters in the file. These are getting from a long text.
    Now my requirement is to find these hidden characters and display in the screen and user can correct then go for download.
    Currently i am using Notepad++ or using this link for finding the hidden characters
    http://string.online-toolz.com/tools/string-functions.php
    Now user wanted to use the same functionality with in SAP using ABAP.
    Any input on this appreciated.

    Similar functionality can be achieved by JavaScript. You can pass the entire Text and create your function in JS to find out the Hidden Characters. If you are successful finding the JS which can do this job for you, you can use [JS Engine|http://help.sap.com/saphelp_nw04/helpdata/en/49/a8e3c8d59811d4b2e90050dadfb92b/frameset.htm] available in ABAP.
    Refer to [ABAP & JavaScript|http://help-abap.zevolving.com/2011/10/javascript-in-abap/] to see the simple JS usage.
    Regards,
    Naimesh Patel

  • INSERT key does not toggle INSERT/REPLACE mode

    The INSERT key does not toggle between Insert and Replace mode. The enterabled items are always in insert mode. Does anyone know how to fix this?
    I'm using Forms 6i 6.0.8.17.1, web-deployed on Solaris 2.6 (64 bit).

    You can use a pluggable Java Component to do this and there is an example in the Forms 9i demos.

  • PC to Mac hidden characters

    Having problems displaying hidden characters and guides when opening a document created on a PC (CS3) on a Mac. Any tricks, suggestions?

    It has nothing to do with Windows/Mac. The document is likely in a
    preview mode.
    Bob

  • "show hidden characters" is not working

    InDesign CC. Neither the show/hide grid nor the show/hide hidden characters works.

    Maybe you're in the wrong screen mode. Try View -> Screen Mode; invisibles like gridlines and hidden characters will appear in Normal, but IIRC not in Preview.

  • Re: Qosmio G - Hidden files and folders not showing

    Hi folks, I have some hidden files and folders, which I was able to access before, and I used to click on the 'organise tab', view, Advanced Settings, show hidden files and folders, in order to hide or show the files.
    Unfortunately there seems to be a problem, I just can't access my hidden files and folders any more, even when I go through this method.
    someone help me out please, ASAP....
    THANKS

    Hi aaz911,
    First of all it would be nice from you if you post more informations about your notebook model and operating system. This should be done always to get a detailed answer.
    Anyway, I never heard about such a problem but make sure that every files will be displayed:
    Start Windows Explorer > Tools > Folder Options > View and enable the following options:
    -Hidden files and folders: Show hidden files and folders
    -Hide protected operating system files (this should be disabled > without mark).
    Furthermore can you find these missing files using Windows search?
    If not I assume the files are deleted from somebody or due a virus. :(

  • Hidden Characters is not displayed properly

    Hi Friends,
    I am a user of Adobe Indesign CS4 (6.0.6). lately, I upgraded my MAC OS X to 10.6.4 version. I found out the Hidden Characters in Indesign becomed to be not displayed correctly. I captured a screenshot as below for reference. All Hidden Characters such as forced line break, table are displayed as rectangle box in total like below screenshot.
    But when i transfered to Mac OS X 10.4.11, all instances were fine.
    If anyone occurred this issue before, kindly please tell how to resolve it.
    Thanks in advance.
    L1on

    Typically I tend to advocate installing Mac OS X on a new hard drive and migrating the profile over. It's a huge timesaver and issues located to profiles are rare and generally easy to diagnose.
    This time around though I've had a couple of machines have runaway directory processes, which made me curse Bob for being right again.
    I'd still say it is a good idea beyond doing a fresh install to keep your last OS in a bootable format until you are wholly content with it. Migrating back a version of Mac OS X is not for the feint of heart. I had to do it do to printing and application incompatibility and it roached a good half day to get everything back on track on version back.

  • Type Show Hidden Characters doesn't display hidden chars, what to do?

    When I select Type > Show Hidden characters, the display does not change and the hidden characters stay hidden. Is there something additional that I need to do to see the hidden characters?

    Under View, change your Screen Mode to Normal. In any other mode, guides and hidden characters won't show.

  • Songs transferred to Ipod will not play in Itunes and don't show in Ipod

    I have had a nano for a good 6+ months and have yet to be able to fill it up with music. Under 200 songs it is a crap shoot whether or not the songs will show up after I eject it. If I load 200+ songs to the Ipod one of two things happen. 1. After ejecting the Ipod none of the songs i loaded show up on it, and after linking it back to the computer, itunes tells me that it must be restored. 2. a good number of songs will not play but are skipped over. The album art shows for a split second and goes to the next song. The next time I plug it into my computer it says that It does not recognize it and forces me to restore it again.
    I have done the following among other things.
    1. Repeatedly restored my ipod, this does not help.
    2. Re-installed Itunes and Quicktime.
    3. Loaded only AAC files.
    4. Turned off Spy Sweeper while before plugging in my Ipod and load songs.
    5. Disabled Norton Anti-virus.
    6. Confirmed how I am ejecting it.
    6. Replaced my Ipod once.
    7. Bought a new computer HP Pavillion a1630n.
    8. Invested well over 40 hours of my time trying to get this thing to work.
    I have over 200GB of music which and I cannot get much more than 2GB on my 4GB Ipod without a problem. As of this writting I have restored it 6 times, after each time I drag my songs to the Ipod icon, when it is done loading, I press the eject icon next to the IPod and each time I click English-->Music-->Artists--> and after that all I get is All-->All-->Nothing. I plug it back into the computer and have to restore it and start over. I have had the same problem on two Ipods, and two Computers. I want this to work so bad. Help Help Help.

    The exact message that I get each time I plug my Ipod back in states, "iTunes cannot read teh contents of the iPod "MILOPOD." Go to the summary tab in iPod preferences and click Restore to restore this iPod to factory settings."
    I am continually restoring my Ipod over and over again reducing the number of songs on it over and over until I get lucky enough for the songs to stick. Only about 100 or so will regularly stick. I am now restoring it for the 7th time.

Maybe you are looking for

  • IPhone 5 Battery is a Bust and the Fixes Won't Help

    You can setup your new iPhone 5 as a new phone, and it's not going to solve the problem of battery drain. I tried both ways. First, I restored by 3Gs backup to the new iPhone 5, and then I wiped the new iPhone 5 and set it up as a new phone. There ar

  • Type conflict in function module parameters

    Hi All, i hve to pass dynamic field <dyn_field> into function module parameters but  it's giving a dump for type conflict. where VALUE2  data type in 'AUTHORITY_CHECK' is UST12-VON but if i define <dyn_field> type UST12-VON . then it'll give dump in

  • Reading client-posted data via Tomcat servlet

    Hi, I'm doing some simple client/servlet communication using Tomcat, using POST's via an HttpURLConnection. I'm seeing my data at the servlet side via getInputStream(), but I can't decode it to a String, even by using InputStreamReader (which is supp

  • Error in SBWP

    Hi, When iam attaching any document in SBWP its giving me an error saying: Read eeor during pC upload Try again?? Plz help...... Regards, Ramesh Bhatt

  • I have got a i phone still on contract and my ear phones are broke can i get an other pair free

    I have4 got an iPhone still on contract and my headphones have broken already, would it be possible to get a new pair free?