Hey,
thanks for your hints. I guess my easiest option would be to build a C++ CLI 
(.exe) from the code in the Gist and just call it with 
"subprocess.check_output()".
Best regards

    On Thursday, June 1, 2023 at 07:09:02 PM GMT+2, Bill Tutt <b...@tutts.org> 
wrote:  
 
 This IDL snippet from the GIST contains the GUID you're looking for: 
[uuid(f53321fa-34f8-4b7f-b9a3-361877cb94cf)]
 coclass QuietHoursSettings
 {
    [default] interface IQuietHoursSettings;
 }

coclass's are the COM object. The interface guid you mentioned is that you need 
to supply to QueryInterface once you've created the COM object.
NOTE: Those COM interfaces don't inherit from IDispatch (and aren't dual) so 
even the universal vtable code that was written once upon a time might have 
some issues with the data types in some of the methods in the 
IQuietHoursSettings. (Assuming that the IDL definitions in the GIST match 
reality since this COM object isn't actually documented publicly.)
I haven't done this for literally decades,  so take this for what it is worth 
(almost nothing). 
So, you might have a simpler time of it exposing a C API from a small custom 
DLL that uses the C++ sample code you mentioned and consume that via ctypes, or 
come up with some wrapper objects you expose via a new Python extension DLL. If 
you're really determined, you could add pywin32 style support for the 
interfaces in a new DLL without too much grief. (But it is a fairly tedious 
process and would probably involve learning more about how the pywin32 COM goo 
works on the inside of the source code)
Bill
On Wed, May 31, 2023 at 2:53 PM Steven Manross <ste...@manross.net> wrote:


Interfaces are definitely different and cannot be used with IDispatch, etc.

 

Someone with more experience might be able to direct you to something, but as 
far as I know, that’s reserved for C++ (or likely ctypes in python…  but that’s 
on the fringe of what I’m capable of helping with – and completely outside the 
scope of the pywin32 module).

 

But to make it more clear..  ctypes is how python can call things like that C++ 
code, but my one endeavor into that space was a VERY long and frustrating road 
as making sure that all the prerequisite data structures were created (and 
defined correctly) was a daunting task, and someone ended up figuring it out 
for me – as I was totally missing different structures that needed to be 
defined (it was for some data from Terminal Server that is not publicly 
supported – but totally capable of being read from Windows).

 

HTH

 

Steven

From: python-win32 <python-win32-bounces+steven=manross....@python.org>On 
Behalf Of name zero via python-win32
Sent: Tuesday, May 30, 2023 10:32 PM
To: python-win32@python.org
Subject: Re: [python-win32] Setting Focus Assist Mode via COM

 

Hi,

 

thanks for explaining the issue with clsids.

 

The "application" is basically part of MS Windows. Talking to it via COM is 
100% possible, as the C++ code (that is part of the GitHub-Gist)demonstrates. 
It just doesn't work with pywin32.

 

When I look for "6bff4732-81ec-4ffb-ae67-b6c1bc29631f" in the Windows registry, 
I only find an entry in "HKEY_CLASSES_ROOT\Interface" (there is no entry in 
HKEY_CLASSES_ROOT\clsid) with a default value of  "IQuietHoursSettings". But 
win32com.client.Dispatch('IQuietHoursSettings') fails with the error message 
"Invalid class string".

 

Best regards!

 

 

On Tuesday, May 30, 2023 at 11:41:25 PM GMT+2, Steven Manross 
<ste...@manross.net> wrote:

 

 

While I haven’t worked on exactly what you are working on:

 

I’d first verify suggest that the application that installs this class needs to 
be installed on the PC you are trying to create the automation from, because 
“Class not Registered” isn’t a python error, and it talks more directly to the 
fact that the appropriate class from the software you are trying to automate 
isn’t on the computer you are running python from: so either you have the wrong 
CLSID or are doing something else wrong (missing software???).

 

Classes are listed in the registry here:

 

HKEY_CLASSES_ROOT\clsid\{6bff4732-81ec-4ffb-ae67-b6c1bc29631f}

… and your CLSID would need to exist (as installed from whatever software you 
are trying to automate) prior to python being able to automate it.

 

Here is an example that should work on your system…

 

ms_dict = win32com.client.Dispatch('Scripting.Dictionary')

 

… because the scripting dictionary object class is installed in just about 
every Windows OS since pre-WindowsXP

 

I hope this helps.  Enjoy your day.

 

Steven

From: python-win32 <python-win32-bounces+steven=manross....@python.org>On 
Behalf Of name zero via python-win32
Sent: Monday, May 29, 2023 6:02 AM
To: python-win32@python.org
Subject: [python-win32] Setting Focus Assist Mode via COM

 

Hi,

 

could someone help me out with first steps for how to set Focus Assist via COM, 
whichhttps://gist.github.com/riverar/085d98ffb1343e92225a10817109b2e3 
demonstrates for a C++ code base? Something like

 

win32com.client.Dispatch('{6bff4732-81ec-4ffb-ae67-b6c1bc29631f}', 
clsctx=pythoncom.CLSCTX_LOCAL_SERVER)

 

fails with "pywintypes.com_error: (-2147221164, 'Class not registered', None, 
None)"

 

Thank you and best regards!
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

  
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to