From patrik at ikus-soft.com Fri Jul 5 14:24:18 2024 From: patrik at ikus-soft.com (Patrik Dufresne) Date: Fri, 5 Jul 2024 14:24:18 -0400 Subject: [python-win32] Using win32com for ToastNotificationManager Message-ID: Hello, Is it possible to use win32com/pythoncom to instantiate a ToastNotificationManager. Looking at the registry is seams all the interface is registered using a GUID, but I'm not familiar enough to know exactly how to create an instance of the ToastNotificationManager using python. I've already had a look at winrt and winsdk that provide binding for winrt, but my application is required to be as small as possible and the library is 30Mib when installed. I also want to minimize the number of dependencies in my application, leveraging pywin32 make more sense for me. Thanks for helping. -- IKUS Software https://www.ikus-soft.com/ 514-971-6442 St-Colomban, QC J5K 1T9 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Sun Jul 7 21:16:19 2024 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 7 Jul 2024 21:16:19 -0400 Subject: [python-win32] Using win32com for ToastNotificationManager In-Reply-To: References: Message-ID: <337cd377-3001-4367-8591-fa482e1ca55a@skippinet.com.au> If it is possible it would not be at all straight-forward :( It doesn't look like these objects expose IDispatch, which is what we would need. winrt probably is your best bet. Cheers On 2024-07-05 2:24 p.m., Patrik Dufresne wrote: > Hello, > > Is it possible to use win32com/pythoncom to instantiate a > ToastNotificationManager. Looking at the registry is seams all the > interface is registered using a GUID, but I'm not familiar enough to > know exactly how to create an instance of the ToastNotificationManager > using python. > > I've already had a look at winrt and winsdk that provide binding for > winrt, but my application is required to be as small as possible and > the library is 30Mib when installed. I also want to minimize the > number of dependencies in my application, leveraging pywin32 make more > sense for me. > > Thanks for helping. > > > -- > IKUS Software > https://www.ikus-soft.com/ > 514-971-6442 > St-Colomban, QC J5K 1T9 > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From sven.bardos at googlemail.com Wed Jul 17 05:30:42 2024 From: sven.bardos at googlemail.com (Sven Bardos) Date: Wed, 17 Jul 2024 11:30:42 +0200 Subject: [python-win32] Dispatch vs EnsureDispatch performance In-Reply-To: References: Message-ID: Hi Mark, I found some time to debug and profile my issue a little bit more. In my scenario I call a COM method which returns a list of 14195 integers plus the amount of the found objects. If I profile that call I get the following: ncalls tottime percall cumtime percall filename:lineno(function) ... 1 0.000 0.000 0.025 0.025 __init__.py:572(_ApplyTypes_) 1 0.000 0.000 0.007 0.007 __init__.py:603(_get_good_object_) 14195 0.001 0.000 0.001 0.000 __init__.py:608(_get_good_single_object_) 14198/1 0.005 0.000 0.007 0.007 __init__.py:614(_get_good_object_) ... So _get_good_object_ is called ~14200 times. If I do that in a loop 100x, I get an execution time of ~3.3s If I change the code in the _ApplyTypes_ function to: def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args): return self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args) # return self._get_good_object_( # self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), # user, # resultCLSID, # ) that is, avoiding the _get_good_object_() calls, the execution time is ~1.6s for 100 iterations. Which is ~50% of the original time. The result is the same, in this case. Do you have any thoughts on this? Best regards, Sven Am Mi., 17. Apr. 2024 um 17:19 Uhr schrieb Mark Hammond < skippy.hammond at gmail.com>: > I'm mildly surprised by that - a profiler might show some low-hanging > fruit, and/or might show different characteristics when many more functions > are used. However, the primary reason for EnsureDispatch is for better > support of the object model - there's far more context available and this > less chance of upsetting some COM objects - eg, when `foo.bar` is seen, > EnsureDispatch knows for sure that `bar` is a method, but dynamic dispatch > doesn't know if the resulting object is going to be called or not. > > HTH, > > Mark > On 2024-04-17 2:07 a.m., Sven Bardos via python-win32 wrote: > > Hi, > > shouldn't be EnsureDispatch be faster than Dispatch once the code > generation is done? > > I've measured it by calling 6000 COM calls like this: > > dirpath = Path('C:/Users/sbardos/AppData/Local/Temp/gen_py/3.10/') > if dirpath.exists() and dirpath.is_dir(): > shutil.rmtree(dirpath) > > app = Dispatch("CT.Application") > job = app.CreateJobObject() > > start = timer() > > for i in range(2000): > cnt, devIds = job.GetAllDeviceIds() > cnt, sheetIds = job.GetSheetIds() > dev = job.CreateDeviceObject() > > end = timer() > print(f"Time ellapsed (late): {end - start}s") > and the ensure Dispatch version: > app = EnsureDispatch("CT.Application") > job = app.CreateJobObject() > start = timer() > for i in range(2000): > cnt, devIds = job.GetAllDeviceIds(None) > cnt, sheetIds = job.GetSheetIds(None) > dev = job.CreateDeviceObject() > end = timer() > print(f"Time ellapsed (early): {end - start}s") > EnsureDispatch is a little bit slower ~4.2s compared to ~4.0s. > If I don't get a performance boost with EnsureDispatch, is there even a > point using it? > > Thanks, > Sven > > _______________________________________________ > python-win32 mailing listpython-win32 at python.orghttps://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tgeppert at digitx.de Tue Jul 23 07:42:51 2024 From: tgeppert at digitx.de (Thomas Geppert) Date: Tue, 23 Jul 2024 13:42:51 +0200 Subject: [python-win32] Creating COM Records with a field of type SAFEARRAY(VT_RECORD) Message-ID: <6d1c2ecf-d93b-4c3f-a183-7ea31ae50464@digitx.de> Is it currently somehow possible to create a COM Record and assign a value of type SAFEARRAY(VT_RECORD) to one of the record fields? I'm dealing with a COM interface that defines a COM Record of the following type in the IDL-file. ??? typedef [uuid(xxxxx)] ??? struct tagT_RECORD_A { ??? ??? SAFEARRAY(T_RECORD_B) array_of_records; ?? ?? ? ??? } T_RECORD_A The 'T_RECORD_B' is another COM Record type with fields of just simple types. I didn't find a way to assign the required SAFEARRAY instance to the 'array_of_records' field of a 'T_RECORD_A' instance. When I run: ??? import pythoncom ??? import win32.client ??? from win32com.client import gencache, Record ??? mod = gencache.EnsureModule('{XXXXX}', X, Y, Z) ??? comp = win32com.client.Dispatch("SomeProgID", clsctx=pythoncom.CLSCTX_LOCAL_SERVER) ??? rec_a = Record("T_RECORD_A", comp) ??? rec_b_1 = Record("T_RECORD_B", comp) ??? rec_b_3 = Record("T_RECORD_B", comp) it successfully creates all record instances. However, assigning to the 'array_of_records' field of the 'T_RECORD_A' instance raises an exception: ??? rec_a.array_of_records = [rec_b_1, rec_b_2] ??? ??? com_error: (-2147024809,? 'The parameter is incorrect.', None, None) From what I can tell by skimming through the code, it looks like pywin32 is creating a SAFEARRAY(VT_VARIANT) with VARIANT elements of type VT_RECORD while the COM-server expects a SAFEARRAY(VT_RECORD), i.e. COM Record elements. Cheers, Thomas From va at zaptest.com Tue Jul 30 10:14:40 2024 From: va at zaptest.com (Valentin Abrutski) Date: Tue, 30 Jul 2024 17:14:40 +0300 Subject: [python-win32] Python Windows Scripting Engine Message-ID: 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. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Tue Jul 30 10:56:39 2024 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 30 Jul 2024 10:56:39 -0400 Subject: [python-win32] Python Windows Scripting Engine In-Reply-To: References: Message-ID: <8e658085-c118-4ccb-a667-3772b1eeb1a1@skippinet.com.au> 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 > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From va at zaptest.com Tue Jul 30 15:54:21 2024 From: va at zaptest.com (Valentin Abrutski) Date: Tue, 30 Jul 2024 22:54:21 +0300 Subject: [python-win32] Python Windows Scripting Engine In-Reply-To: <8e658085-c118-4ccb-a667-3772b1eeb1a1@skippinet.com.au> References: <8e658085-c118-4ccb-a667-3772b1eeb1a1@skippinet.com.au> Message-ID: Hi Mark Appreciate for fast response. I will look into it. Thank you. On Tue, Jul 30, 2024 at 5:56?PM Mark Hammond 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 listpython-win32 at python.orghttps://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From va at zaptest.com Tue Jul 30 16:29:01 2024 From: va at zaptest.com (Valentin Abrutski) Date: Tue, 30 Jul 2024 23:29:01 +0300 Subject: [python-win32] Python Windows Scripting Engine In-Reply-To: References: <8e658085-c118-4ccb-a667-3772b1eeb1a1@skippinet.com.au> Message-ID: 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? On Tue, Jul 30, 2024 at 10:54?PM Valentin Abrutski 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 > 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 listpython-win32 at python.orghttps://mail.python.org/mailman/listinfo/python-win32 >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Tue Jul 30 17:58:12 2024 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 30 Jul 2024 17:58:12 -0400 Subject: [python-win32] Python Windows Scripting Engine In-Reply-To: References: <8e658085-c118-4ccb-a667-3772b1eeb1a1@skippinet.com.au> Message-ID: <3aa8c2a7-ae04-407c-9a84-9927a3b5fcf1@skippinet.com.au> 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 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 > 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 >> python-win32 at python.org >> https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From va at zaptest.com Wed Jul 31 09:14:28 2024 From: va at zaptest.com (Valentin Abrutski) Date: Wed, 31 Jul 2024 16:14:28 +0300 Subject: [python-win32] Python Windows Scripting Engine In-Reply-To: <3aa8c2a7-ae04-407c-9a84-9927a3b5fcf1@skippinet.com.au> References: <8e658085-c118-4ccb-a667-3772b1eeb1a1@skippinet.com.au> <3aa8c2a7-ae04-407c-9a84-9927a3b5fcf1@skippinet.com.au> Message-ID: 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 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 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 >> 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 listpython-win32 at python.orghttps://mail.python.org/mailman/listinfo/python-win32 >>> >>> -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Wed Jul 31 10:01:05 2024 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 31 Jul 2024 10:01:05 -0400 Subject: [python-win32] Python Windows Scripting Engine In-Reply-To: References: <8e658085-c118-4ccb-a667-3772b1eeb1a1@skippinet.com.au> <3aa8c2a7-ae04-407c-9a84-9927a3b5fcf1@skippinet.com.au> Message-ID: 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 > 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 >> 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 >> 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 >>> python-win32 at python.org >>> https://mail.python.org/mailman/listinfo/python-win32 >> > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From va at zaptest.com Wed Jul 31 10:08:51 2024 From: va at zaptest.com (Valentin Abrutski) Date: Wed, 31 Jul 2024 17:08:51 +0300 Subject: [python-win32] Python Windows Scripting Engine In-Reply-To: References: <8e658085-c118-4ccb-a667-3772b1eeb1a1@skippinet.com.au> <3aa8c2a7-ae04-407c-9a84-9927a3b5fcf1@skippinet.com.au> Message-ID: Thank you Mark. I will try that. Appreciate ??, 31 ???. 2024??., 17:01 Mark Hammond : > 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 > 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 >> 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 >>> 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 listpython-win32 at python.orghttps://mail.python.org/mailman/listinfo/python-win32 >>>> >>>> > _______________________________________________ > python-win32 mailing listpython-win32 at python.orghttps://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tgeppert at digitx.de Wed Jul 31 13:19:18 2024 From: tgeppert at digitx.de (Thomas Geppert) Date: Wed, 31 Jul 2024 19:19:18 +0200 Subject: [python-win32] Creating COM Records with a field of type SAFEARRAY(VT_RECORD) In-Reply-To: <6d1c2ecf-d93b-4c3f-a183-7ea31ae50464@digitx.de> References: <6d1c2ecf-d93b-4c3f-a183-7ea31ae50464@digitx.de> Message-ID: <991ce039-d30a-4597-a20b-d5f698216f57@digitx.de> In case somebody has the same issue and stumbles into this thread I will answer my own question. With the current release (306) of pywin32 it is not possible to create a COM Record and assign a value of type SAFEARRAY(VT_RECORD) to one of the record fields. I have opened a pull request on github ( https://github.com/mhammond/pywin32/pull/2317 ) to add this functionality. Cheers, Thomas On 2024-07-23? 07:42 a.m. , Thomas Geppert wrote: > Is it currently somehow possible to create a COM Record and assign a > value of type SAFEARRAY(VT_RECORD) to one of the record fields? > > I'm dealing with a COM interface that defines a COM Record of the > following type in the IDL-file. > > ??? typedef [uuid(xxxxx)] > ??? struct tagT_RECORD_A { > ??? ??? SAFEARRAY(T_RECORD_B) array_of_records; > ?? ?? ? > ??? } T_RECORD_A > > The 'T_RECORD_B' is another COM Record type with fields of just simple > types. > > I didn't find a way to assign the required SAFEARRAY instance to the > 'array_of_records' field of a 'T_RECORD_A' instance. > > When I run: > > ??? import pythoncom > ??? import win32.client > ??? from win32com.client import gencache, Record > > ??? mod = gencache.EnsureModule('{XXXXX}', X, Y, Z) > ??? comp = win32com.client.Dispatch("SomeProgID", > clsctx=pythoncom.CLSCTX_LOCAL_SERVER) > ??? rec_a = Record("T_RECORD_A", comp) > ??? rec_b_1 = Record("T_RECORD_B", comp) > ??? rec_b_3 = Record("T_RECORD_B", comp) > > it successfully creates all record instances. However, assigning to > the 'array_of_records' field of the 'T_RECORD_A' instance > raises an exception: > > ??? rec_a.array_of_records = [rec_b_1, rec_b_2] > ??? ??? com_error: (-2147024809,? 'The parameter is incorrect.', None, > None) > > From what I can tell by skimming through the code, it looks like > pywin32 is creating a SAFEARRAY(VT_VARIANT) with > VARIANT elements of type VT_RECORD while the COM-server expects a > SAFEARRAY(VT_RECORD), i.e. COM Record elements. > > > Cheers, > > Thomas > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32