Re: Python Windows Scripting Engine
Mark Hammond <[email protected]> Wed, 31 Jul 2024 10:01:05 -0400
| Newsgroups | gmane.comp.python.windows |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format. --===============3036380792552908061== Content-Type: multipart/alternative; boundary="------------wwDh4LxeSuzAJyzm0Hko8UGI" Content-Language: en-US This is a multi-part message in MIME format. --------------wwDh4LxeSuzAJyzm0Hko8UGI Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sorry, I can't explain that - running pyscript.py should register things and support for IActiveScriptParse is unconditional. You could try running `pyscript.py --debug` which might print some debug stuff, or even add print statements to client.py's QueryInterface function to make sure it's actually being called. Also, executing win32comext/axscript/test/testHost.py should try and exercise the engine. HTH, Mark On 2024-07-31 9:14 a.m., Valentin Abrutski wrote: > Hi Mark. Thank you for the idea. And appreciate your help. > > I tried it. And to be sure that I'm doing it right. I've tried to use > this approach to get not only IActiveScriptParse, but also IActiveScript > Still the same issue. I can get IActiveScript. But when try to get > IActiveScriptParse I get error code: |0x80004002| (|E_NOINTERFACE|) > > I've double checked GUID of IActiveScriptParse which is used in > QuearyInterface and it looks > correct: BB1A2AE2-A4F9-11cf-8F20-00805F2CD064 > > I'm thinking about is it possible that the way I registered Python > Script Engine is not correct? Is it possible that there are different > way to do that? > Just to remind you, I just run python pyscript.py > > > On Wed, Jul 31, 2024 at 12:58 AM Mark Hammond > <[email protected]> wrote: > > > On 2024-07-30 4:29 p.m., Valentin Abrutski wrote: >> Hi Mark. >> >> I double checked what I did with my previous attempt. And still >> can't get success. Probably you can give me an idea of what I'm >> doing wrong. >> >> I am working on an application(.Net) which provides scripting >> capabilities via AcriveScript Engine. With the ability to debug >> script step by step and etc. And we provide a standard set of >> languages VBScript and JScript. And now we want to provide Python >> support. >> >> Obviously I need to add a new ActiveScript Engine for Python. to >> system >> >> What I did. I installed python and installed the pywin32 package. >> Then I found this script >> Python311\Lib\site-packages\win32comext\axscript\client\pyscript.py >> and run it : >> python pyscript.py >> Requesting elevation and retrying... >> Registered: Python >> >> After that, I go to my application code and do the same we >> already do for Standard JScript or VBScript engines. >> For example, import of COM JScript class is defined >> [ComImport, Guid("F414C260-6AC0-11CF-B6D1-00AA00BBBB58")] >> public class JScript >> { >> } >> >> So I defined import class for Python using GUID from python class >> implementation >> [ComImport, Guid("DF630910-1C1D-11d0-AE36-8C0F5E000000")] >> public class PythonScript >> { >> } >> >> Then my expectation is that I can cast it to IAcriveScript and >> IActiveScripParse (like I do with standard languages) >> _engine = new PythonScript(); >> _iap = _engine as IActiveScriptParse; >> _ias = _engine as IActiveScript; >> >> But IActiveScriptParse still is null, IActiveScript - is good. >> I suppose that probably I did initialization in wrong way? or >> something like that? > > My best guess is that the "as" isn't working due to a lack of a > typelib for the engine - but a > QueryInterface(IID_IActiveScriptParse) on the IActiveScript > interface should work. > > HTH, > > Mark > > >> >> >> >> On Tue, Jul 30, 2024 at 10:54 PM Valentin Abrutski >> <[email protected]> wrote: >> >> Hi Mark >> >> Appreciate for fast response. I will look into it. Thank you. >> >> >> On Tue, Jul 30, 2024 at 5:56 PM Mark Hammond >> <[email protected]> wrote: >> >> IActiveScriptParse is supported - check out the >> com/win32comext/axscript directory. >> >> Cheers, >> >> Mark >> >> On 2024-07-30 10:14 a.m., Valentin Abrutski wrote: >>> Hello all, >>> >>> Hopefully somebody can help me. >>> >>> Microsoft provides implementations for Microsoft >>> Scripting Engine - VbScript and JScript. >>> I need to add Python Script Engine support. I see that >>> pywin32 already has a component for that(COM object). >>> But it exposes only the IActiveScript interface. For my >>> needs I also need IActiveScriptParse interface. >>> >>> please advise me if pywin32 implements it also and I >>> just missed something? or if you have an idea what to do >>> to get.. I will appreciate for your help. >>> >>> _______________________________________________ >>> python-win32 mailing list >>> [email protected] >>> https://mail.python.org/mailman/listinfo/python-win32 >> > > _______________________________________________ > python-win32 mailing list > [email protected] > https://mail.python.org/mailman/listinfo/python-win32 --------------wwDh4LxeSuzAJyzm0Hko8UGI Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <p>Sorry, I can't explain that - running pyscript.py should register things and support for IActiveScriptParse is unconditional. You could try running `pyscript.py --debug` which might print some debug stuff, or even add print statements to client.py's QueryInterface function to make sure it's actually being called. Also, executing win32comext/axscript/test/testHost.py should try and exercise the engine.</p> <p>HTH,</p> <p>Mark<br> </p> <div class="moz-cite-prefix">On 2024-07-31 9:14 a.m., Valentin Abrutski wrote:<br> </div> <blockquote type="cite" cite="mid:CADtR_MMNCHwxnSQQjF77OfiaBRoD2R-mVgO4MxSLRZNJEqt9Bg@mail.gmail.com"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <div dir="ltr">Hi Mark. Thank you for the idea. And appreciate your help. <div><br> I tried it. And to be sure that I'm doing it right. I've tried to use this approach to get not only IActiveScriptParse, but also IActiveScript <div>Still the same issue. I can get IActiveScript. But when try to get IActiveScriptParse I get error code: <code style="border-radius:4px;font-size:12px;padding:1px 3px">0x80004002</code><span style="font-size:13px;color:rgb(204,204,204);font-family:"Segoe WPC","Segoe UI",sans-serif;background-color:rgb(24,24,24)"> (</span><code style="border-radius:4px;font-size:12px;padding:1px 3px">E_NOINTERFACE</code><span style="font-size:13px;color:rgb(204,204,204);font-family:"Segoe WPC","Segoe UI",sans-serif;background-color:rgb(24,24,24)">)</span></div> <div><span style="font-size:13px;color:rgb(204,204,204);font-family:"Segoe WPC","Segoe UI",sans-serif;background-color:rgb(24,24,24)"><br> </span></div> <div>I've double checked GUID of IActiveScriptParse which is used in QuearyInterface and it looks correct: BB1A2AE2-A4F9-11cf-8F20-00805F2CD064</div> <div><br> </div> <div>I'm thinking about is it possible that the way I registered Python Script Engine is not correct? Is it possible that there are different way to do that? </div> <div>Just to remind you, I just run <span style="font-family:monospace">python pyscript.py </span></div> <div><br> </div> </div> </div> <br> <div class="gmail_quote"> <div dir="ltr" class="gmail_attr">On Wed, Jul 31, 2024 at 12:58 AM Mark Hammond <<a href="mailto:[email protected]" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a>> wrote:<br> </div> <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <div> <p><br> </p> <div>On 2024-07-30 4:29 p.m., Valentin Abrutski wrote:<br> </div> <blockquote type="cite"> <div dir="ltr">Hi Mark. <br> <br> I double checked what I did with my previous attempt. And still can't get success. Probably you can give me an idea of what I'm doing wrong. <div><br> </div> <div>I am working on an application(.Net) which provides scripting capabilities via AcriveScript Engine. With the ability to debug script step by step and etc. And we provide a standard set of languages VBScript and JScript. And now we want to provide Python support.</div> <div><br> </div> <div>Obviously I need to add a new ActiveScript Engine for Python. to system</div> <div><br> </div> <div>What I did. I installed python and installed the pywin32 package.</div> <div>Then I found this script Python311\Lib\site-packages\win32comext\axscript\client\pyscript.py and run it : <br> <font face="monospace">python pyscript.py </font></div> <div><font face="monospace">Requesting elevation and retrying...</font></div> <div><font face="monospace">Registered: Python</font></div> <div><font face="monospace"><br> </font></div> <div><font face="arial, sans-serif">After that, I go to my application code and do the same we already do for Standard JScript or VBScript engines.</font></div> <div><font face="arial, sans-serif">For example, import of COM JScript class is defined</font></div> <div><font face="monospace"> [ComImport, Guid("F414C260-6AC0-11CF-B6D1-00AA00BBBB58")]<br> public class JScript<br> {<br> }</font></div> <div><font face="monospace"><br> </font></div> <div><font face="arial, sans-serif">So I defined import class for Python using GUID from python class implementation</font></div> <div><font face="monospace"> [ComImport, Guid("DF630910-1C1D-11d0-AE36-8C0F5E000000")]<br> public class PythonScript<br> {<br> }<br> </font></div> <div><font face="monospace"><br> </font></div> <div><font face="arial, sans-serif">Then my expectation is that I can cast it to IAcriveScript and IActiveScripParse (like I do with standard languages)</font></div> <div><font face="monospace"> _engine = new PythonScript();<br> _iap = _engine as IActiveScriptParse;<br> _ias = _engine as IActiveScript;<br> </font></div> <div><font face="monospace"><br> </font></div> <div><font face="arial, sans-serif">But IActiveScriptParse still is null, IActiveScript - is good.</font></div> <div><font face="arial, sans-serif">I suppose that probably I did initialization in wrong way? or something like that?</font></div> </div> </blockquote> <p>My best guess is that the "as" isn't working due to a lack of a typelib for the engine - but a QueryInterface(IID_IActiveScriptParse) on the IActiveScript interface should work.</p> <p>HTH,</p> <p>Mark<br> </p> <p><br> </p> <blockquote type="cite"> <div dir="ltr"> <div><br> </div> <div> <br> </div> </div> <br> <div class="gmail_quote"> <div dir="ltr" class="gmail_attr">On Tue, Jul 30, 2024 at 10:54 PM Valentin Abrutski <<a href="mailto:[email protected]" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a>> wrote:<br> </div> <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <div dir="ltr">Hi Mark <div><br> </div> <div>Appreciate for fast response. I will look into it. Thank you. </div> <div><br> </div> </div> <br> <div class="gmail_quote"> <div dir="ltr" class="gmail_attr">On Tue, Jul 30, 2024 at 5:56 PM Mark Hammond <<a href="mailto:[email protected]" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a>> wrote:<br> </div> <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <div> <p>IActiveScriptParse is supported - check out the com/win32comext/axscript directory.</p> <p>Cheers,<br> </p> <p>Mark<br> </p> <div>On 2024-07-30 10:14 a.m., Valentin Abrutski wrote:<br> </div> <blockquote type="cite"> <div dir="ltr">Hello all, <div><br> </div> <div>Hopefully somebody can help me.</div> <div><br> </div> <div>Microsoft provides implementations for Microsoft Scripting Engine - VbScript and JScript.</div> <div>I need to add Python Script Engine support. I see that pywin32 already has a component for that(COM object). But it exposes only the IActiveScript interface. For my needs I also need IActiveScriptParse interface. <br> <br> please advise me if pywin32 implements it also and I just missed something? or if you have an idea what to do to get.. I will appreciate for your help.</div> </div> <br> <fieldset></fieldset> <pre>_______________________________________________ python-win32 mailing list <a href="mailto:[email protected]" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a> <a href="https://mail.python.org/mailman/listinfo/python-win32" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">https://mail.python.org/mailman/listinfo/python-win32</a> </pre> </blockquote> </div> </blockquote> </div> </blockquote> </div> </blockquote> </div> </blockquote> </div> <br> <fieldset class="moz-mime-attachment-header"></fieldset> <pre wrap="" class="moz-quote-pre">_______________________________________________ python-win32 mailing list <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a> <a class="moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/python-win32">https://mail.python.org/mailman/listinfo/python-win32</a> </pre> </blockquote> </body> </html> --------------wwDh4LxeSuzAJyzm0Hko8UGI-- --===============3036380792552908061== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ python-win32 mailing list [email protected] https://mail.python.org/mailman/listinfo/python-win32 --===============3036380792552908061==--