digitalmars.D.learn - Windows COM objects accessability
- jicman (58/58) Sep 27 2006 Greetings!
- JC (36/40) Sep 28 2006 There are two ways to go about this: 1) Early binding - download the
- jicman (2/2) Sep 28 2006 Thank you... This is great help!
- jicman (6/13) Sep 28 2006 a D
- jicman (11/24) Sep 28 2006 Ignore the last post. IE7 adds the . at the end of the URL, so it
- Justin C Calvarese (8/26) Oct 07 2006 I was surprised that those zip's were still available there since the
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é
Sep 27 2006
"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, josThere 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.
Sep 28 2006
== Quote from JC (johnch_atms)'s article"jicman" wrote in messageIf you choose early binding, try running TlbImpD on the typelibrary(http://www.paperocean.org/d/tlbimpd.zip). It attempts to generatea 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 zipbut this one is not there.That should get you started. John.thanks again...
Sep 28 2006
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 articlegenerate"jicman" wrote in message If you choose early binding, try running TlbImpD on the typelibrary(http://www.paperocean.org/d/tlbimpd.zip). It attempts toa 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 zipbut this one is not there.That should get you started. John.thanks again...
Sep 28 2006
"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, josAre you reading this on the web client? If so, it appears to include the full-stop in the link.
Sep 28 2006
== Quote from JC (johnch_atms hotmail.com)'s article"jicman" <cabreraREM VEwrc.xerox.com> wrote in message news:efgi30$n61$1 digitaldaemon.com...No. I am doing this from the new beautiful and colorful web client. :-) Sorry, I was out for a bit...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, josAre you reading this on the web client? If so, it appears to include the full-stop in the link.
Oct 05 2006
JC wrote:"jicman" <cabrera wrc.xerox.com> wrote in message news:effj86$2u2v$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. Also, doesn't the Juno project (http://dsource.org/projects/juno) contain a newer version of tlbimpd anyway? -- jcc7So, the question is, has anyone being able to access Windows COM objects? Any quick sample will do. thanks, josThere 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.
Oct 07 2006
"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
Oct 09 2006
== Quote from JC (johnch_atms hotmail.com)'s article"Justin C Calvarese" <technocrat7 gmail.com> wrote in message news:eg9ejm$2j9p$1 digitaldaemon.com...>ISP's are mean.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...Thanks.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. jcc7Also, 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)?
Oct 09 2006