Sign in to follow this  
Followers 0
roboz

AutoIt and Adobe InDesign scripting

13 posts in this topic

#1 ·  Posted (edited)

Hi there,

I'm writing a lot of scripts in VBScript for Adobe InDesign 2. For scripting everything else I always use AutoIt :) . Now I was wondering if it's possible to use VBScript in AutoIt to access InDesign but also make use of all the other AutoIt features like GUI etc. I'm not a real programmer but I already read a lot about the COM support in the latest help file and in the forum. Also the postings about how to use VBScript in AutoIt sound very promising, although I'm still not sure if it can be done what I'm looking for. I thought the best way would be probably to post this little InDesign VBscript as an example and someone might be able to tell me if this is possible through AutoIt or not.

Thanks very much in advance!

Dim MyIndesign
Set MyIndesign = CreateObject("InDesign.Application.2.0") 
Set myDocument = myInDesign.ActiveDocument

Set myLayers = mydocument.Layers
For Each Layer In myLayers
Layer.Locked = False
Layer.Visible = True
Next

SelectionCount = 0
Set MySelectionRange = myInDesign.Activewindow.ActiveSpread
For Each Frame In MySelectionRange.TextFrames
    If Frame.Characters.Count = 0 Then
        myInDesign.Select Frame, True
        SelectionCount = SelectionCount + 1
    End If
Next

If SelectionCount > 0 Then
   MsgBox (SelectionCount & " empty Text Frames found and selected")
   Else MsgBox ("No empty Text Frames found")
End If
Edited by roboz

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Don't know much VB but i think it should look somthing like this.

Line 14 has me stumped though. maybe somebody else knows how to fix line 14.

Dim $MyIndesign
$MyIndesign = ObjCreate("InDesign.Application.2.0") 
$qmyDocument = $myInDesign.ActiveDocument

$myLayers = $mydocument.Layers
For $Layer In $myLayers
$Layer.Locked = 0
$Layer.Visible = 1
Next

$SelectionCount = 0
$MySelectionRange = $myInDesign.Activewindow.ActiveSpread
For $Frame In $MySelectionRange.TextFrames
    If $Frame.Characters.Count = 0 Then
        $myInDesign.Select Frame, True; I Don't under this line. Sorry :-(
        $SelectionCount = $SelectionCount + 1
    EndIf
Next

If $SelectionCount > 0 Then
   MsgBox (0,"",$SelectionCount & " empty Text Frames found and selected")
   Else 
MsgBox (0,"","No empty Text Frames found")
EndIf
Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

Thank you so much SolidSnake!

Apart from line it's all working so far. But I'm sure we can figure that out as well.

This also gives me an idea of how things work with VBS in AutoIt. Wow, that'll open whole new possibilities for my InDesign scripts! Finally I can turn all my script ideas into reality :)

Share this post


Link to post
Share on other sites

Thank you so much SolidSnake!

Apart from line it's all working so far.  But I'm sure we can figure that out as well.

This also gives me an idea of how things work with VBS in AutoIt. Wow, that'll open whole new possibilities for my InDesign scripts! Finally I can turn all my script ideas into reality :)

<{POST_SNAPBACK}>

Your welcome. :evil: I will try and work on that line that gives me trouble. if i figure it out i will tell you.

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi SolidSnak, maybe you can help me with that. This is the VBS code:

mySelection.Move = Array($myX1, $myY2_store)

Now I'm not quite sure what to do with this array:

$mySelection.Move = ???

Any idea how to write that in AutoIt?

Thanks

Edited by roboz

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hi SolidSnak, maybe you can help me with that. This is the VBS code:

mySelection.Move = Array($myX1, $myY2_store)

Now I'm not quite sure what to do with this array:

$mySelection.Move = ???

Any idea how to write that in AutoIt?

Thanks

<{POST_SNAPBACK}>

Maybe this would work:

#Include<Array.au3>
$mySelection.Move = _ArrayCreate($myX1, $myY2_store)
Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

Maybe this would work:

#Include<Array.au3>
$mySelection.Move = _ArrayCreate($myX1, $myY2_store)

<{POST_SNAPBACK}>

Yes, that's working. Thanks again!

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Yes, that's working. Thanks again!

<{POST_SNAPBACK}>

No Problem.

Also just wondering did you ever get the problem with line 14 solved. still has me stumped. :)

Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

No Problem.

Also just wondering did you ever get the problem with line 14 solved. still has me stumped.  :evil:

<{POST_SNAPBACK}>

I'm getting there:

$myInDesign.Select ($Frame, True)

This line selects at least the last created empty text frame, although it's supposed to add all empty text frames. But I'm getting closer :)

A completely unrelated question: I'm using Scite for coding and with the VBS stuff I'm always get an error message popup when I hit F5. The code is still working it just doesn't like this line:

...ERROR: ObjCreate(): undefined function.

$MyIndesign = ObjCreate("InDesign.Application.2.0")

You don't know by any chance how to turn off the error messages in Scite? I just couldn't find an option for that.

Thanks

Share this post


Link to post
Share on other sites

I'm getting there:

$myInDesign.Select ($Frame, True)

This line selects at least the last created empty text frame, although it's supposed to add all empty text frames. But I'm getting closer :)

A completely unrelated question: I'm using Scite for coding and with the VBS stuff I'm always get an error message popup when I hit F5. The code is still working it just doesn't like this line:

...ERROR: ObjCreate(): undefined function.

$MyIndesign = ObjCreate("InDesign.Application.2.0")

You don't know by any chance how to turn off the error messages in Scite? I just couldn't find an option for that.

Thanks

<{POST_SNAPBACK}>

Thanks for the reply.

About your problem with Scite and VBS. I don't think scite supports VBS. Not the version we Autoit users use anyway.


HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Try using Alt+F5 - That will force Scite to use the beta version of AutoIT if it is installed to run the script rather than the standard version. I assume you have the beta version as the standard version doesn't support COM handling very well. :think:

Once you figure all this out, please consider making a UDF for your InDesign stuff if it's applicable to other users. I'm considering taking on a similar project for FrameMaker 7.1

Edited by thefluxster

“Efficiency is doing things right; effectiveness is doing the right things.”-Peter F. Drucker

Share this post


Link to post
Share on other sites

Try using Alt+F5 - That will force Scite to use the beta version of AutoIT if it is installed to run the script rather than the standard version. I assume you have the beta version as the standard version doesn't support COM handling very well. :D

Once you figure all this out, please consider making a UDF for your InDesign stuff if it's applicable to other users. I'm considering taking on a similar project for FrameMaker 7.1

I am having a full toolbar for FM7.1.

I know it works on FM8.0 also. Haven't tried.

What do you want to do with FM?

Is it COM based? I never heard of that!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0