Re: [comtypes-users] Creating Shell Links using comtypes
We use win32com for our shortcut creation as well. One thin I noticed that is different in you code compared to ours is that we pass true as the second parameter to persist_file.Save To be more helpful I think we would need to know where your code is dying, and what error messages you are getting. -Original Message- From: Markus Gritsch [mailto:[EMAIL PROTECTED] Sent: Monday, November 03, 2008 9:11 AM To: comtypes-users@lists.sourceforge.net Subject: [comtypes-users] Creating Shell Links using comtypes Hi, I would like to create shell links (.lnk) from my Python program. I found the following solution at [1] which uses win32com: import os, sys import pythoncom from win32com.shell import shell, shellcon shortcut = pythoncom.CoCreateInstance ( shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink ) shortcut.SetPath (sys.executable) shortcut.SetDescription (Python %s % sys.version) shortcut.SetIconLocation (sys.executable, 0) desktop_path = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0) persist_file = shortcut.QueryInterface (pythoncom.IID_IPersistFile) persist_file.Save (os.path.join (desktop_path, python.lnk), 0) I was trying to translate this to comtypes, but had absolutely no success. It would be very nice, if someone could give me any advice how to do this using comtypes. Kind regards, Markus [1] http://tgolden.sc.sabren.com/python/win32_how_do_i/create-a-shortcut.htm l - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users
Re: [comtypes-users] Creating Shell Links using comtypes
I don't believe IShellLink uses Dispatch/automation objects, so you will have to import the tlb information Microsoft supplies the idl and h file in shobjidl.idl and shobjidl.h You can use midl to create a tlb from it. Then you should be able to load the tlb into comtypes. -Original Message- From: Markus Gritsch [mailto:[EMAIL PROTECTED] Sent: Monday, November 03, 2008 9:51 AM To: comtypes-users@lists.sourceforge.net Subject: Re: [comtypes-users] Creating Shell Links using comtypes On Mon, Nov 3, 2008 at 3:16 PM, MR Michael Robellard (5314) [EMAIL PROTECTED] wrote: To be more helpful I think we would need to know where your code is dying, and what error messages you are getting. I tried the following: import sys import comtypes from comtypes.client import CreateObject CLSID_ShellLink = '{00021401---C000-0046}' IID_IShellLink = '{000214EE---C000-0046}' shortcut = CreateObject(CLSID_ShellLink, comtypes.CLSCTX_INPROC_SERVER) shortcut.SetPath(sys.executable) and got an AttributeError: 'POINTER(IUnknown)' object has no attribute 'SetPath' - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users
[comtypes-users] Change to register.py
Thomas, We came across an interesting issue this morning when we register our COM servers. It looks like register.py automatically uses sys.executable to register the COM object. In our case we have written a service that autoupdates the user's application. The problem is that the register function is being called by pythonservice.exe and not python.exe or pythonw.exe. This is causing crashes when you use the com object. Our fix is simple, can you please add an optional parameter to register.py to allow the executable to be passed. The changed register.py is attached. register.py Description: register.py - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/___ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users
[comtypes-users] COM issues with IE7 and python, possibly the GIL?
We have created a COM object that runs under IE to implement the IURLSearchHook2 interface. This allows you to intercept invalid URLs and run a search for them in the address bar of IE. Everything has been running great on my XP box with IE6 installed on it. We went to test it on an IE7 machine and we have instant issues with it. When you search in IE7 using the code it will randomly hang the search. The rest of IE continues to function. If you then execute a second search in the address bar, it will execute the second search and then the hung search will successfully execute. Attached is a standalone python module that successfully reproduces this issue. You will need to add the following GUID as the only string value in the key: {0BC6E3FA-78EF-4886-842C-5A1258C4455A} to this key in the registry HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\URLSearchHooks So the questions are: Have we done something in our implementation that is causing this issue? Is there an issue with how _ctypes.pyd is handling the GIL for these calls? As a workaround we have a C++ COM object that receives the calls on this interface and then forwards them to a localserver python com object that does the work. Not ideal but it seems to work. testserver.py Description: testserver.py - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/___ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users
Re: [comtypes-users] problem after packaging with py2exe
Try something like this # Create the wrapper in the comtypes.gen package, it will be named # AGCoreLib; the name is derived from the 'library ' statement # in the IDL file if not (hasattr(sys, frozen) or python25.zip in __file__): # pathname of the type library file tlbfile = os.path.join(os.path.dirname(__file__), lilw.tlb) # if running as frozen app (dll or exe), the wrapper should be in # the library archive, so we don't need to generate it. comtypes.client.GetModule(tlbfile) # Import the wrapper from comtypes.gen import AGCoreLib -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kelie Sent: Tuesday, July 29, 2008 1:28 PM To: comtypes-users@lists.sourceforge.net Subject: [comtypes-users] problem after packaging with py2exe Hello, I wrote a simple script which uses comtypes. When I run it the first time, it takes some time to generate the module(s) (in the comtypes/gen directory), which is normal. When I run the code again, the step of generating module(s) is skipped. But after I package the program into an executable with py2exe, it re-generates the module(s) every time I run the exe. Apparently it is not the case using PyWin32, or at least I cannot notice the delay. I'm not sure if this is related to its dynamic IDispatch feature that Michael mentioned in this post: http://article.gmane.org/gmane.comp.python.comtypes.user/192. Anyway is there a way to get around this? Thanks for your input! - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users
[comtypes-users] IOleObject and IRichEditOle
Thank you for this great library. I have managed to do some great things with Python in Windows, however I am still hitting some stumbling blocks. Currently I am trying to paste an object into a rich text edit control. I can do this successfully in C++ by using the IRichEditOle interface that you get when you do: disp = POINTER(IDispatch)() result = win32api.SendMessage(hInput, EM_GETOLEINTERFACE, 0, addressof(disp)) I can QueryInterface on this interface to get an ITextDocument. from comtypes.client import GetModule GetModule(riched20.dll) from comtypes.gen.tom import * td = disp.QueryInterface(ITextDocument) ts = td.Selection ts.Text = Hello World This all works and sets the text in the Rich Edit Control to Hello World What I can't figure out how to do is find a tlb for Either the IOleObject or IRichEditOle interfaces so that I can do something similar for them. Do these exist? Is there a better way to do the things I need to do? For instance on IOleObject I want to call SetClientSite Thanks for your help in advance Michael Robellard - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users