From timr at probo.com Sun Jul 3 14:46:56 2016 From: timr at probo.com (Tim Roberts) Date: Sun, 3 Jul 2016 11:46:56 -0700 Subject: [python-win32] win32 error running on python 3 and win 64 machine In-Reply-To: References: Message-ID: <624FDE7D-5435-449F-A6C9-369A301F8650@probo.com> On Jun 30, 2016, at 5:23 AM, Nabeela > wrote: i'm trying to run the following code and get this error import win32com.client as win32 import os excel = win32.gencache.EnsureDispatch('Excel.Application') Traceback (most recent call last): File "C:\Users\nabeelah.bijapur\Documents\Anaconda3\lib\site-packages\win32com\client\gencache.py", line 532, in EnsureDispatch ti = disp._oleobj_.GetTypeInfo() pywintypes.com_error: (-2147418111, 'Call was rejected by callee.', None, None) Do you actually have Microsoft Office installed on this machine? ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From webguy at totalrewind.com Wed Jul 6 19:42:27 2016 From: webguy at totalrewind.com (Kurt Eilander) Date: Wed, 6 Jul 2016 17:42:27 -0600 Subject: [python-win32] shell_view.py folder not browsable In-Reply-To: References: Message-ID: <0075a818-5a35-7933-a878-bf736d459955@totalrewind.com> > Hey all, > > I was hoping to create my own IShellFolder in python, but there seems to > be something wrong with the example on my system. > (Win7 64bit, Python 2.7) > > The folder shows up on the desktop, but I cannot open it. I saw an > earlier thread where the solution was to right-click and select > 'explore', but that doesn't even work for me. The context menu only has > Cut, Create Shortcut, and Delete. > > Not seeing any errors in the syslogs. > > Any fixes or suggestions would be most appreciated! > > Thanks in advance, > -Kurt Today I decided to try it on Vista 32-bit, SP2. Also, this was pristine code right off the Anaconda bundle. This time when I right-click, open on "Python Path Shell Browser" I see a brief blip, like it wanted to draw the window frame but decided not to. This was the only visible difference (and I think even that could be accounted for by the slower speed of the machine). Again, I run mmc and look at the syslogs. Nothing. That's a pretty old system. Just curious, when was the last time anybody has tried this example? Its starting to feel like the non-workingness may have been around for a long time. -Kurt From vernondcole at gmail.com Wed Jul 6 21:49:54 2016 From: vernondcole at gmail.com (Vernon D. Cole) Date: Wed, 6 Jul 2016 19:49:54 -0600 Subject: [python-win32] shell_view.py folder not browsable In-Reply-To: <0075a818-5a35-7933-a878-bf736d459955@totalrewind.com> References: <0075a818-5a35-7933-a878-bf736d459955@totalrewind.com> Message-ID: I seem to be suffering from a lack of context... What example are you referring to? On Wed, Jul 6, 2016 at 5:42 PM, Kurt Eilander wrote: > Hey all, >> >> I was hoping to create my own IShellFolder in python, but there seems to >> be something wrong with the example on my system. >> (Win7 64bit, Python 2.7) >> >> The folder shows up on the desktop, but I cannot open it. I saw an >> earlier thread where the solution was to right-click and select >> 'explore', but that doesn't even work for me. The context menu only has >> Cut, Create Shortcut, and Delete. >> >> Not seeing any errors in the syslogs. >> >> Any fixes or suggestions would be most appreciated! >> >> Thanks in advance, >> -Kurt >> > > Today I decided to try it on Vista 32-bit, SP2. Also, this was pristine > code right off the Anaconda bundle. > > This time when I right-click, open on "Python Path Shell Browser" I see a > brief blip, like it wanted to draw the window frame but decided not to. > This was the only visible difference (and I think even that could be > accounted for by the slower speed of the machine). > > Again, I run mmc and look at the syslogs. Nothing. > > That's a pretty old system. Just curious, when was the last time anybody > has tried this example? Its starting to feel like the non-workingness may > have been around for a long time. > > -Kurt > > _______________________________________________ > 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 rapzak at gmail.com Mon Jul 18 15:58:59 2016 From: rapzak at gmail.com (Kasper) Date: Mon, 18 Jul 2016 21:58:59 +0200 Subject: [python-win32] COM Server - COMTYPES / PYTHONCOM Message-ID: Hello all, I have some major problems with something i am not good at :( I have come to a situation where i have to add a COM server in my python code the get access to it from Labview Teststand. Firs i have tried with pythoncom/wincom and got it almost working, it registered and i could look it up in the windows COM data list. But this combination do not register coclasses: Coclasses are not registered (that is, RegisterTypeLib does not write any values to the CLSID key of the coclass). http://docs.activestate.com/activepython/2.6/pywin32/pythoncom__RegisterTypeLib_meth.html IDL File: http://pastebin.com/WGCMmzHv And here the code: http://pastebin.com/44t45tPj my reference: https://chromium.googlesource.com/chromium/deps/python_26/+/cd4a3da8f0f0806bec98a40d80484f2362908250/Lib/site-packages/win32com/test/pippo_server.py --------------------------------------------------------------------- Then i started by using COMTYPES, but this do not at all register into the COM catalog on windows - both solutions i can connect to from another python. here is my code - IDL is the same. http://pastebin.com/ke5V5ZbY How do i continue so i can use this server from Teststand or any other windows program?? I really hope some can give me an example or help me in what is wrong - i think it is quite close... Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Jul 18 17:07:21 2016 From: timr at probo.com (Tim Roberts) Date: Mon, 18 Jul 2016 14:07:21 -0700 Subject: [python-win32] COM Server - COMTYPES / PYTHONCOM In-Reply-To: References: Message-ID: Kasper wrote: > > I have some major problems with something i am not good at :( > > I have come to a situation where i have to add a COM server in my > python code the get access to it from Labview Teststand. > > Firs i have tried with pythoncom/wincom and got it almost working, it > registered and i could look it up in the windows COM data list. > But this combination do not register coclasses: > Coclasses are not registered (that is, RegisterTypeLib does not write > any values to the CLSID key of the coclass). I don't see how you are connecting things together here. Your IDL file has the following GUIDs: D04CBAD4... for the ITestServerApp interface (which you never use) BB5DD9CF... for the IPippo interface 1728B2B9... for the type library 398C2A35... for the TestServerApp coclass (which you never use) 47D38FBE... for the Pippo coclass But look at your code. The CPippo class says its CLSID is 05AC1CCE..., which doesn't match any of those. It also says its type library is 40159C57..., which also doesn't match any of those. I suspect what you want to do here is delete the ITestServerApp interface and TestServerApp coclass from the IDL, and change the type library GUID in your Python code to match the actual GUID you have in the type library. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rapzak at gmail.com Tue Jul 19 02:38:51 2016 From: rapzak at gmail.com (Kasper) Date: Tue, 19 Jul 2016 08:38:51 +0200 Subject: [python-win32] COM Server - COMTYPES / PYTHONCOM Message-ID: Hi again, I hope i have replied correctly, because i did not get the reply in my mail... (please correct me if i am doing worng and start a new thread) https://mail.python.org/pipermail/python-win32/2016-July/013732.html Well, i see your point, but the IDL filse was modifien for the second code to be sure not to use any guid again - if that was a problem. Well i will give it a shot again, but: in the python code: _reg_clsid_ = "{05AC1CCE-3F9B-4d9a-B0B5-DFE8BE45AFA8}" this one must be refering to the co-class or the library in TLB? _typelib_guid_ = '{41059C57-975F-4B36-8FF3-C5117426647A}' This must relate to the interface / coclass or library? Thank you very much for your support Kasper -------------- next part -------------- An HTML attachment was scrubbed... URL: From rapzak at gmail.com Tue Jul 19 03:37:21 2016 From: rapzak at gmail.com (Kasper) Date: Tue, 19 Jul 2016 09:37:21 +0200 Subject: [python-win32] COM Server - COMTYPES / PYTHONCOM Message-ID: Python code: http://pastebin.com/KV3JKuD3 IDL: http://pastebin.com/ec6BE4A1 VB code for testing and error: http://pastebin.com/McD2rnVv http://picpaste.com/com-AtIFF9f3.png So i think we are back to the sentence about co-classes are not registrered: Coclasses are not registered (that is, RegisterTypeLib does not write any values to the CLSID key of the coclass). http://docs.activestate.com/activepython/2.6/pywin32/pythoncom__RegisterTypeLib_meth.html Kasper -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Jul 19 12:23:19 2016 From: timr at probo.com (Tim Roberts) Date: Tue, 19 Jul 2016 09:23:19 -0700 Subject: [python-win32] COM Server - COMTYPES / PYTHONCOM In-Reply-To: References: Message-ID: <9af54287-78ac-8143-2d85-1f8ece70f3fd@probo.com> Kasper wrote: > > I hope i have replied correctly, because i did not get the reply in my > mail... > (please correct me if i am doing worng and start a new thread) > https://mail.python.org/pipermail/python-win32/2016-July/013732.html > > Well, i see your point, but the IDL filse was modifien for the second > code to be sure not to use any guid again - if that was a problem. You can make up your own GUIDs, but you have to link the two together. > Well i will give it a shot again, but: > > in the python code: > > _reg_clsid_ = "{05AC1CCE-3F9B-4d9a-B0B5-DFE8BE45AFA8}" > > this one must be refering to the co-class or the library in TLB? > You ought to be able to figure that out. This is a CLSID. That means it's the coclass. Interfaces are called IIDs. However, if the documentation is right, the coclass in the type library is not being used, anyway. > _typelib_guid_ = '{41059C57-975F-4B36-8FF3-C5117426647A}' > > This must relate to the interface / coclass or library? > Again, you ought to be able to figure that out from the variable name. That's the library ID. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gklein at xs4all.nl Tue Jul 26 06:26:21 2016 From: gklein at xs4all.nl (Gertjan Klein) Date: Tue, 26 Jul 2016 12:26:21 +0200 Subject: [python-win32] Context menu handler as executable Message-ID: Hi all, I am working on a Windows Explorer context menu handler; Windows 10, Python 3.4 (both 64 bit), pywin32 version 219 installed (no virtual environment). The handler is working fine when running it as a Python source file. However, I would like to create an executable containing all the dependencies, so it can be run on PCs that don't have Python installed. I can't get this to work. I have tried using py2exe and pyinstaller, with various setup.py and spec file examples, and nothing seems to work. I've attached a stripped-down version of my code; when registered, it adds a context menu entry that, when clicked, pops up a message box showing the item clicked. Can anyone help me find a way to convert this to an executable that still works? Thanks! Regards, Gertjan. -------------- next part -------------- #!/usr/bin/env python3.4 import sys, os from os.path import dirname, join, exists import pythoncom from win32com.shell import shell, shellcon import win32gui import win32gui_struct import win32con import win32process import win32api IContextMenu_Methods = ["QueryContextMenu", "InvokeCommand", "GetCommandString"] IShellExtInit_Methods = ["Initialize"] class ShellExtension: name = 'ContextMenuTest' _reg_progid_ = "Python.ShellExtension.ContextMenuTest" _reg_desc_ = "Contextmenu test" _reg_clsid_ = "{1055EB80-4862-11E6-8607-101F7414C0D3}" _com_interfaces_ = [shell.IID_IShellExtInit, shell.IID_IContextMenu] _public_methods_ = IContextMenu_Methods + IShellExtInit_Methods def Initialize(self, folder, dataobj, hkey): print("Initialize") self.dataobj = dataobj self.folder = folder def QueryContextMenu(self, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags): print("QueryContextMenu") flags = win32con.MF_BYPOSITION | win32con.MF_STRING win32gui.InsertMenu(hMenu, indexMenu, flags, idCmdFirst, "Context menu test") return 1 def InvokeCommand(self, ci): print("InvokeCommand") mask, hwnd, verb, params, dir, nShow, hotkey, hicon = ci if dir: mb_flags = win32con.MB_ICONEXCLAMATION | win32con.MB_OK win32gui.MessageBox(hwnd, dir, "Item clicked", 0) return def GetCommandString(self, cmd, typ): print("GetCommandString:", (cmd, typ)) return "" def __del__(self): # Automatically unload the module if and only if a file __debug__ is # present in the same directory as this file. path = dirname(__file__) flagfile = join(path, '__debug__') if not exists(flagfile): return # Flag file exists: unload module if self.__module__ in sys.modules: print("Deleting", self.__module__, "module.") del sys.modules[self.__module__] # ========== ========== ========== ========== ========== # Paths in HKCR to register / unregister REGPATHS = ( r"*\shellex\ContextMenuHandlers\%s", ) def DllRegisterServer(): import winreg classid = ShellExtension._reg_clsid_ for path in REGPATHS: path = path % ShellExtension.name key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, path) winreg.SetValueEx(key, None, 0, winreg.REG_SZ, classid) print(ShellExtension._reg_desc_, "registration complete.") def DllUnregisterServer(): for path in REGPATHS: path = path % ShellExtension.name del_key(path) print(ShellExtension._reg_desc_, "unregistration complete.") def del_key(path): import winreg try: key = winreg.DeleteKey(winreg.HKEY_CLASSES_ROOT, path) except WindowsError as details: import errno if details.errno != errno.ENOENT: raise # ========== ========== ========== ========== ========== if __name__ == '__main__': # Loaded as program: register as shell extension # Register: # py -3.4 ctxm.py --register # Unregister: # py -3.4 ctxm.py --unregister # No implicit registration if len(sys.argv) < 2: print("Use --register or --unregister.") sys.exit(1) # if sys.argv[1] == "/Automate": from win32com.server import localserver localserver.serve([ShellExtension._reg_clsid_]) sys.exit(0) from win32com.server import register register.UseCommandLine( ShellExtension, finalize_register = DllRegisterServer, finalize_unregister = DllUnregisterServer) else: # Loaded as module: use win32traceutil for debugging # To view output, use: # py -3.4 -mwin32traceutil import win32traceutil print("\n=====\nLoading ctmx module.") From timr at probo.com Tue Jul 26 12:48:47 2016 From: timr at probo.com (Tim Roberts) Date: Tue, 26 Jul 2016 09:48:47 -0700 Subject: [python-win32] Context menu handler as executable In-Reply-To: References: Message-ID: <8752a2c4-3989-1ab5-6d60-e0356d6a02b3@probo.com> Gertjan Klein wrote: > I am working on a Windows Explorer context menu handler; Windows 10, > Python 3.4 (both 64 bit), pywin32 version 219 installed (no virtual > environment). > > The handler is working fine when running it as a Python source file. > However, I would like to create an executable containing all the > dependencies, so it can be run on PCs that don't have Python installed. > I can't get this to work. I have tried using py2exe and pyinstaller, > with various setup.py and spec file examples, and nothing seems to work. Are you testing this on a 64-bit system? Remember that your 64-bit process will only work on 64-bit systems. What actually happens when you try to run it? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gklein at xs4all.nl Tue Jul 26 13:35:47 2016 From: gklein at xs4all.nl (Gertjan Klein) Date: Tue, 26 Jul 2016 19:35:47 +0200 Subject: [python-win32] Context menu handler as executable In-Reply-To: <8752a2c4-3989-1ab5-6d60-e0356d6a02b3@probo.com> References: <8752a2c4-3989-1ab5-6d60-e0356d6a02b3@probo.com> Message-ID: Tim Roberts wrote: > Gertjan Klein wrote: >> I am working on a Windows Explorer context menu handler; Windows 10, >> Python 3.4 (both 64 bit), pywin32 version 219 installed (no virtual >> environment). >> >> The handler is working fine when running it as a Python source file. >> However, I would like to create an executable containing all the >> dependencies, so it can be run on PCs that don't have Python installed. >> I can't get this to work. I have tried using py2exe and pyinstaller, >> with various setup.py and spec file examples, and nothing seems to work. > > Are you testing this on a 64-bit system? Remember that your 64-bit > process will only work on 64-bit systems. Yes, Windows and Python are both 64 bit. Note that the handler works fine as a python file, just not as an executable. > What actually happens when you try to run it? I guess I should have been more specific there... ;-) I have py2exe or pyinstaller create an executable; this registers itself without any error messages, and registry entries do appear in the registry. However, no context menu item appears, and nothing I tried showed any evidence of my code being run. I don't know nearly enough of Windows programming to have even an idea of what could be wrong, or debug further. Regards, Gertjan. From christiaanvanzyl at gmail.com Wed Jul 27 13:56:10 2016 From: christiaanvanzyl at gmail.com (Christiaan B v Zyl) Date: Wed, 27 Jul 2016 19:56:10 +0200 Subject: [python-win32] Context menu handler as executable Message-ID: > > Python 3.4 (both 64 bit), pywin32 version 219 installed > I've had success with cx_Freeze when building executables for Python 3 -------------- next part -------------- An HTML attachment was scrubbed... URL: From gklein at xs4all.nl Thu Jul 28 07:21:50 2016 From: gklein at xs4all.nl (Gertjan Klein) Date: Thu, 28 Jul 2016 13:21:50 +0200 Subject: [python-win32] Context menu handler as executable In-Reply-To: References: Message-ID: Christiaan B v Zyl wrote: > >> Python 3.4 (both 64 bit), pywin32 version 219 installed > > I've had success with cx_Freeze when building executables for Python 3 I just tried cx_freeze, and essentially have the same symptoms as with the other two executable-builders: registering the exe works (as in: says it's successful, and registry entries appear), but no context menu. I must be missing something fundamental. How is the code expected to run? The only thing I found is an entry in the registry that specifies an "/Automate" switch. However, this does not seem to get called at all. Does anybody know what is supposed to happen? Regards, Gertjan.