From omega.centauri at gmail.com Wed Dec 6 10:51:37 2017 From: omega.centauri at gmail.com (NIcola Montecchiari) Date: Wed, 6 Dec 2017 16:51:37 +0100 Subject: [python-win32] Using COM Event. A problem Message-ID: Dear All, I am trying to create a call back for som events generated by a COM server that I connect. Looking at some posts apparently related to the same topic, I wrote this sample code to test: import win32com.client as com from win32com.client import gencache class Eventi: def Device_Notify(self,EventCode): if EventCode==0: print "begin" elif EventCode==1: print "end" mod = gencache.EnsureModule('{B4955EC7-F7F2-11D2-AA9C-444553540000}', 0, 1, 0) ob = mod.Application() objCybio = com.DispatchWithEvents(ob, Eventi) When I run this code, it starts the connection, but soon after it is stopped with the following error: Traceback (most recent call last): File "evento.py", line 13, in objCybio = com.DispatchWithEvents(ob, Eventi) File "D:\Python27\lib\site-packages\win32com\client\__init__.py", line 256, in DispatchWithEvents raise TypeError("This COM object can not automate the makepy process - please run makepy manually for this object") TypeError: This COM object can not automate the makepy process - please run makepy manually for this object I did run the makepy, but still the same error. Do you have any suggestion of what it could be wrong? Thanks a lot for your help Nicola -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Dec 6 18:25:18 2017 From: timr at probo.com (Tim Roberts) Date: Wed, 6 Dec 2017 15:25:18 -0800 Subject: [python-win32] Using COM Event. A problem In-Reply-To: References: Message-ID: <233bd217-e958-6100-a210-30bfc7581d96@probo.com> NIcola Montecchiari wrote: > > I am trying to create a call back for som events generated by a COM > server that I connect. > Looking at some posts apparently related to the same topic, I wrote > this sample code to test: > > import win32com.client as com > from win32com.client import gencache > ... > mod = gencache.EnsureModule('{B4955EC7-F7F2-11D2-AA9C-444553540000}', > 0, 1, 0) > ob = mod.Application() > objCybio = com.DispatchWithEvents(ob, Eventi) > > When I run this code, it starts the connection, but soon after it is > stopped with the following error: Do you get the same result if you replace those three lines with this? ??? objCybio = win32con.client.DispatchWithEvents("Maxim.Application", Eventi) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From thopiekar at gmail.com Mon Dec 11 17:47:19 2017 From: thopiekar at gmail.com (Thomas Pietrowski) Date: Mon, 11 Dec 2017 23:47:19 +0100 Subject: [python-win32] Writing an COM server and client with PyWin32 Message-ID: Dear mailing-list members, first I'd like to introduce myself. I'm Thomas Pietrowski and I'm working on a plugin, which shall enable Windows Automation for Cura. Cura is a slicing application for 3D-printers written in Python and I would like to control this application over COM. The last weeks I worked hard on getting something working and managed to do function calls and get values of some attributes. However, something I still don't manage to do is receiving signals. While slicing there is the progress sent within Cura as a Qt signal. This is one of the Qt signals, which I would turn into a COM event. So whenever the progress changes, the widget in the GUI will get updated, as well as the event will be sent over COM. However, this is what I have in mind. What I still can't manage to get working is executing a "DoEvent()" function, which emits an signal and receiving the "OnEvent()" in my handler. Whenever I want to DispatchWithEvents() or do a WithEvents() on a running client session, I always get an error that the client can't manage to automise something and I shall use makepy. After using makepy I still get the same issue. So I guess I made something wrong while writing my IDL and/or COM server. Therefore my client is not able to get all the info it needs. All source are available on GitHub: https://github.com/thopiekar/CuraInterfacePlugin/tree/master-sending-and-receiving-signals (here: "master-sending-and-receiving-signals" branch) Do you see any mistakes I made? Alternatively, do you have a working server/client example with working events? This would probably give me an kickstart :) With kind regards - Thomas Karl Pietrowski -------------- next part -------------- An HTML attachment was scrubbed... URL: From webguy at totalrewind.com Thu Dec 14 19:10:25 2017 From: webguy at totalrewind.com (Kurt Eilander) Date: Thu, 14 Dec 2017 17:10:25 -0700 Subject: [python-win32] playing with scintillacon Message-ID: Hey all, I recently noticed that pythonwin comes with a scintilla wrapper. Seems USEFUL!? so I decided to (scientifically) try poking it with a stick to see what it does. (https://github.com/mhammond/pywin32/tree/7da19cd2ca3fac06638d9af690b8b6f5fcc65e8b/Pythonwin/pywin/scintilla) I didn't get too far, for when I do: ??? from scintilla import scintillacon I get: ??? ImportError: DLL load failed: %1 is not a valid Win32 application. Presumably this means there's a dll it can't find?? Unfortunately the %1 is not replaced with what it's looking for.? (If there's not a bug out on this somewhere, there probably should be.) That's not the point though.? Point is: what are we looking for? Thanks, -Kurt From Jim at JC-Bell.com Fri Dec 15 12:23:55 2017 From: Jim at JC-Bell.com (Jim Bell) Date: Fri, 15 Dec 2017 11:23:55 -0600 Subject: [python-win32] playing with scintillacon In-Reply-To: References: Message-ID: <32f46439-6f12-c8cf-032d-5f2a9e591f5b@JC-Bell.com> "... not a valid Win32 application" sounds like a 32/64-bit issue to me. The 32/64-bit version of python you're running: does it match the DLLs? On 2017-12-14 6:10 PM, Kurt Eilander wrote: > Hey all, > > I recently noticed that pythonwin comes with a scintilla wrapper. > Seems USEFUL!? so I decided to (scientifically) try poking it with a > stick to see what it does. > (https://github.com/mhammond/pywin32/tree/7da19cd2ca3fac06638d9af690b8b6f5fcc65e8b/Pythonwin/pywin/scintilla) > > > I didn't get too far, for when I do: > ??? from scintilla import scintillacon > I get: > ??? ImportError: DLL load failed: %1 is not a valid Win32 application. > > Presumably this means there's a dll it can't find?? Unfortunately the > %1 is not replaced with what it's looking for.? (If there's not a bug > out on this somewhere, there probably should be.) That's not the point > though.? Point is: what are we looking for? > > Thanks, > -Kurt > > From webguy at totalrewind.com Fri Dec 15 16:10:51 2017 From: webguy at totalrewind.com (Kurt Eilander) Date: Fri, 15 Dec 2017 14:10:51 -0700 Subject: [python-win32] playing with scintillacon In-Reply-To: <32f46439-6f12-c8cf-032d-5f2a9e591f5b@JC-Bell.com> References: <32f46439-6f12-c8cf-032d-5f2a9e591f5b@JC-Bell.com> Message-ID: <130e0ea6-844b-b45f-e9de-d6473298e5e1@totalrewind.com> Ok, I found scintilla.dll in the directory above scintillacon.py, but it came with pywin32, so it *should* be the correct one. DLL inspector says it's a 64-bit, which is correct for my os. I copy that dll, and indeed, all binaries in that directory (just to be sure) into my program directory and it still does not work! Yet, the program Pythonwin.exe in that directory works fine and does its syntax highlighting with scintilla.dll. I have no idea what could be wrong.? Oh!? To know what that little %1 means! On 12/15/2017 10:23 AM, Jim Bell wrote: > "... not a valid Win32 application" sounds like a 32/64-bit issue to > me. The 32/64-bit version of python you're running: does it match the > DLLs? > > > On 2017-12-14 6:10 PM, Kurt Eilander wrote: >> Hey all, >> >> I recently noticed that pythonwin comes with a scintilla wrapper. >> Seems USEFUL!? so I decided to (scientifically) try poking it with a >> stick to see what it does. >> (https://github.com/mhammond/pywin32/tree/7da19cd2ca3fac06638d9af690b8b6f5fcc65e8b/Pythonwin/pywin/scintilla) >> >> >> I didn't get too far, for when I do: >> ??? from scintilla import scintillacon >> I get: >> ??? ImportError: DLL load failed: %1 is not a valid Win32 application. >> >> Presumably this means there's a dll it can't find? Unfortunately the >> %1 is not replaced with what it's looking for.? (If there's not a bug >> out on this somewhere, there probably should be.) That's not the >> point though.? Point is: what are we looking for? >> >> Thanks, >> -Kurt >> >> > From eryksun at gmail.com Fri Dec 15 17:47:07 2017 From: eryksun at gmail.com (eryk sun) Date: Fri, 15 Dec 2017 22:47:07 +0000 Subject: [python-win32] playing with scintillacon In-Reply-To: <130e0ea6-844b-b45f-e9de-d6473298e5e1@totalrewind.com> References: <32f46439-6f12-c8cf-032d-5f2a9e591f5b@JC-Bell.com> <130e0ea6-844b-b45f-e9de-d6473298e5e1@totalrewind.com> Message-ID: On Fri, Dec 15, 2017 at 9:10 PM, Kurt Eilander wrote: > Ok, I found scintilla.dll in the directory above scintillacon.py, but it > came with pywin32, so it *should* be the correct one. > DLL inspector says it's a 64-bit, which is correct for my os. > > I copy that dll, and indeed, all binaries in that directory (just to be > sure) into my program directory and it still does not work! Try importing win32api in the same context. If that fails, check PATH for pywintypesXY.dll: where pywintypes*.dll > I have no idea what could be wrong. Oh! To know what that little %1 means! System error message include inserts such as %1 for when errors and exceptions are shown by the system itself. All Python has in this case is the error code, ERROR_BAD_EXE_FORMAT. So when it calls FormatMessage, it uses the flag FORMAT_MESSAGE_IGNORE_INSERTS, as it should. From webguy at totalrewind.com Sat Dec 16 13:13:11 2017 From: webguy at totalrewind.com (Kurt Eilander) Date: Sat, 16 Dec 2017 11:13:11 -0700 Subject: [python-win32] playing with scintillacon In-Reply-To: References: <32f46439-6f12-c8cf-032d-5f2a9e591f5b@JC-Bell.com> <130e0ea6-844b-b45f-e9de-d6473298e5e1@totalrewind.com> Message-ID: I already had "import win32api". As for pywintypes27.dll, it is one of four files automatically placed in c:\windows\system32 by the installer, which is a pretty sure thing as far as being able to find it.? I was getting desperate so I even copied it over, AND all the binaries from the C:\Python27\Lib\site-packages\pythonwin directory for good measure.? I checked the security privileges on all of them and verified that they were 64-bit using a PE explorer (ProcessHacker2). There must be something else I'm missing. NOTE: I am basing my code on the example C:\Python27\Lib\site-packages\win32comext\shell\demos\servers\shell_view.py ScintillaShellView class.? Which is supposed to implement a windows explorer preview with scintilla highlighting. Anyway, when I try and run that full sample, I get a folder created that I cannot open.? (Like it's registered correctly, but the code behind it is kaput.) ? I use NirSoft's shell extension viewer (http://www.nirsoft.net/utils/shexview.html), and it tells me it "cannot find c:\Windows\system32\pythoncom27.dll". Bafflingly, it IS THERE!? And, since it is another of the same set of dll's created by the installer, I'm wondering if this might be a clue?? Could there be a problem with the way the dll's are compiled and/or installed?? On 12/15/2017 3:47 PM, eryk sun wrote: > On Fri, Dec 15, 2017 at 9:10 PM, Kurt Eilander wrote: >> Ok, I found scintilla.dll in the directory above scintillacon.py, but it >> came with pywin32, so it *should* be the correct one. >> DLL inspector says it's a 64-bit, which is correct for my os. >> >> I copy that dll, and indeed, all binaries in that directory (just to be >> sure) into my program directory and it still does not work! > Try importing win32api in the same context. If that fails, check PATH > for pywintypesXY.dll: > > where pywintypes*.dll