Thread overview |
---|
September 28, 2006 Windows COM objects accessability | ||||
---|---|---|---|---|
| ||||
Greetings! This has been brought up many times before, but I don't think we've come up with a solution, yet. Well, I haven't been around in a while, because of lack of time and lots of work. But I am trying to be use some COM objects and I want to use D instead of JSCript. Here is a JSCript sample of what I want to translate: function GetTextArt(file) { var appRef = w.CreateObject("Illustrator.Application.3"); docRef = appRef.Open(file); //w.Echo(appRef.Documents.Count); w.Echo("Found " + docRef.TextFrames.Count + " Text Frames... Extracting them..."); var phrases = new Array(); // Prepare file... if (docRef.TextFrames.Count == 0) { w.Echo("No phrase found..."); phrases.push(""); } else { numberOfWords = 0 tf = new Enumerator(docRef.TextFrames); for (; !tf.atEnd(); tf.moveNext()) { try { textArt = tf.item(); } catch (e) { docRef.Close(aiDoNotSaveChanges); return (new Array()); } try { textArtRange = textArt.TextRange; } catch (e) { docRef.Close(aiDoNotSaveChanges); return (new Array()); } phrases.push(textArt.Contents); w.Echo(textArt.Contents); numberOfWords += textArt.Words.Count; } w.Echo("There are " + numberOfWords + " words in the document."); } docRef.Close(aiDoNotSaveChanges); //appRef.Quit(); return phrases; } So, the question is, has anyone being able to access Windows COM objects? Any quick sample will do. thanks, josé |
September 28, 2006 Re: Windows COM objects accessability | ||||
---|---|---|---|---|
| ||||
Posted in reply to jicman | "jicman" <cabrera@wrc.xerox.com> wrote in message news:effj86$2u2v$1@digitaldaemon.com... > So, the question is, has anyone being able to access Windows COM objects? Any quick sample will do. > > thanks, > > jos There are two ways to go about this: 1) Early binding - download the Illustrator SDK, which should include the COM type library and C headers, which you'd then need to translate to D modules. 2) Late binding. Neither route is going to be as straightforward as JScript (which, incidentally, uses late binding behind the scenes). If you choose early binding, try running TlbImpD on the type library (http://www.paperocean.org/d/tlbimpd.zip). It attempts to generate a D module from the definitions in the library. If, on the other hand, you fancy a real challenge and choose the late binding method, I've put together some code that should help. http://www.paperocean.org/d/comtest.zip. The sample in the zip file shows how to automate an Internet Explorer instance. Here's a simplistic example for Illustrator: import com; void main() { // var app = w.CreateObject("Illustrator.Application.3"); auto app = coCreate!(IDispatch)("Illustrator.Application.3", CoClassContext.LocalServer); // var doc = app.Open("myfile.ai"); auto doc = com_cast!(IDispatch)(invokeCOMMember(app, "Open", DispatchFlags.InvokeMethod, "myfile.ai")); // var textFrames = doc.TextFrames; auto textFrames = com_cast!(IDispatch)(invokeCOMMember(doc, "TextFrames", DispatchFlags.GetProperty)); // var textFramesCount = textFrames.Count; int textFramesCount = com_cast!(int)(invokeCOMMember(textFrames, "Count", DispatchFlags.GetProperty)); // Clean up releaseCOMObject(textFrames); releaseCOMObject(doc); releaseCOMObject(app); } That should get you started. John. |
September 28, 2006 Re: Windows COM objects accessability | ||||
---|---|---|---|---|
| ||||
Posted in reply to JC | Thank you... This is great help! josé |
September 28, 2006 Re: Windows COM objects accessability | ||||
---|---|---|---|---|
| ||||
Posted in reply to JC | == Quote from JC (johnch_atms)'s article > "jicman" wrote in message > If you choose early binding, try running TlbImpD on the type library > (http://www.paperocean.org/d/tlbimpd.zip). It attempts to generate a D This I was able to download... > binding method, I've put together some code that should help. http://www.paperocean.org/d/comtest.zip. The sample in the zip but this one is not there. > That should get you started. > John. thanks again... |
September 28, 2006 Re: Windows COM objects accessability | ||||
---|---|---|---|---|
| ||||
Posted in reply to jicman | Ignore the last post. IE7 adds the . at the end of the URL, so it was looking for, http://www.paperocean.org/d/comtest.zip. instead of http://www.paperocean.org/d/comtest.zip and it was giving me a NOT FOUND. Or, could it be the newsclient? Which I love, by the way. thanks, josé == Quote from jicman (cabreraREM@VEwrc.xerox.com)'s article > == Quote from JC (johnch_atms)'s article > > "jicman" wrote in message > > If you choose early binding, try running TlbImpD on the type > library > > (http://www.paperocean.org/d/tlbimpd.zip). It attempts to generate > a D > This I was able to download... > > binding method, I've put together some code that should help. http://www.paperocean.org/d/comtest.zip. The sample in the zip > but this one is not there. > > That should get you started. > > John. > thanks again... |
September 28, 2006 Re: Windows COM objects accessability | ||||
---|---|---|---|---|
| ||||
Posted in reply to jicman | "jicman" <cabreraREM@VEwrc.xerox.com> wrote in message news:efgi30$n61$1@digitaldaemon.com... > > Ignore the last post. IE7 adds the . at the end of the URL, so it was looking for, > > http://www.paperocean.org/d/comtest.zip. > > instead of > > http://www.paperocean.org/d/comtest.zip > > and it was giving me a NOT FOUND. Or, could it be the newsclient? Which I love, by the way. > > thanks, > > jos Are you reading this on the web client? If so, it appears to include the full-stop in the link. |
October 06, 2006 Re: Windows COM objects accessability | ||||
---|---|---|---|---|
| ||||
Posted in reply to JC | == Quote from JC (johnch_atms@hotmail.com)'s article
> "jicman" <cabreraREM@VEwrc.xerox.com> wrote in message news:efgi30$n61$1@digitaldaemon.com...
> >
> > Ignore the last post. IE7 adds the . at the end of the URL, so it was looking for,
> >
> > http://www.paperocean.org/d/comtest.zip.
> >
> > instead of
> >
> > http://www.paperocean.org/d/comtest.zip
> >
> > and it was giving me a NOT FOUND. Or, could it be the newsclient? Which I love, by the way.
> >
> > thanks,
> >
> > jos
> Are you reading this on the web client? If so, it appears to include the full-stop in the link.
No. I am doing this from the new beautiful and colorful web client. :-)
Sorry, I was out for a bit...
|
October 07, 2006 Re: Windows COM objects accessability | ||||
---|---|---|---|---|
| ||||
Posted in reply to JC | JC wrote: > "jicman" <cabrera@wrc.xerox.com> wrote in message news:effj86$2u2v$1@digitaldaemon.com... >> So, the question is, has anyone being able to access Windows COM >> objects? Any quick sample will do. >> >> thanks, >> >> jos > > There are two ways to go about this: 1) Early binding - download the Illustrator SDK, which should include the COM type library and C headers, which you'd then need to translate to D modules. 2) Late binding. Neither route is going to be as straightforward as JScript (which, incidentally, uses late binding behind the scenes). > > If you choose early binding, try running TlbImpD on the type library (http://www.paperocean.org/d/tlbimpd.zip). It attempts to generate a D module from the definitions in the library. I was surprised that those zip's were still available there since the corresponding web pages (such as http://www.paperocean.org/d/tlibd/) had disappeared a while ago. Also, doesn't the Juno project (http://dsource.org/projects/juno) contain a newer version of tlbimpd anyway? -- jcc7 |
October 09, 2006 Re: Windows COM objects accessability | ||||
---|---|---|---|---|
| ||||
Posted in reply to Justin C Calvarese | "Justin C Calvarese" <technocrat7@gmail.com> wrote in message news:eg9ejm$2j9p$1@digitaldaemon.com...> > I was surprised that those zip's were still available there since the corresponding web pages (such as http://www.paperocean.org/d/tlibd/) had disappeared a while ago. Sadly I allowed my web host subscription to lapse and they deleted my site. I uploaded those zips files especially for you... > > Also, doesn't the Juno project (http://dsource.org/projects/juno) contain a newer version of tlbimpd anyway? No - the one on my website is the latest version. I need to sort out the dsource project stuff. Can anyone recommend a decent SVN client for Windows (apart from Tortoise)? > > -- > jcc7 |
October 09, 2006 Re: Windows COM objects accessability | ||||
---|---|---|---|---|
| ||||
Posted in reply to JC | == Quote from JC (johnch_atms@hotmail.com)'s article > "Justin C Calvarese" <technocrat7@gmail.com> wrote in message news:eg9ejm$2j9p$1@digitaldaemon.com...> > > I was surprised that those zip's were still available there since the corresponding web pages (such as http://www.paperocean.org/d/tlibd/) had disappeared a while ago. > Sadly I allowed my web host subscription to lapse and they deleted my site. ISP's are mean. > I uploaded those zips files especially for you... Thanks. > > > > Also, doesn't the Juno project (http://dsource.org/projects/juno) contain a newer version of tlbimpd anyway? > No - the one on my website is the latest version. I need to sort out the > dsource project stuff. > Can anyone recommend a decent SVN client for Windows (apart from Tortoise)? I like TortoiseSVN (http://tortoisesvn.tigris.org/) so I guess tastes vary. Have you tried RapidSVN (http://rapidsvn.tigris.org/)? I've installed just to see what it's like. It was okay when I tested it, but I prefer TortoiseSVN. Maybe you'd prefer it to TortoiseSVN since they do operate somewhat differently. I only tested it long enough to decide that I preferred TortoiseSVN, so you might hate it more than you hate TortoiseSVN. Or perhaps you'd prefer the SVN command line interface (http://subversion.tigris.org/)? More information about these SVN clients is available: http://www.dsource.org/site/svnclient There are probably more SVN clients out there, but these are the only ones that I've used at all. jcc7 |
Copyright © 1999-2021 by the D Language Foundation