Hi :) I've been asking about this matter in the python tutor mailing list and I've been suggested to post my question here, as it was specific to win32api. I want to be able to know what is my currently active language, how can I do that? I've been searching around for functions and this is the only thing I found fitting - http://msdn.microsoft.com/en-us/library/ms628562(VS.85).aspx
I've asked how to use it on the Tutor mailing list and this is the answer I got from a very nice fellow Maybe it could help you understand what I've got so far - " Dror Cohen wrote: > I'm trying to use the these functions which are in isnide of > ITfInputProcessorProfiles > http://msdn.microsoft.com/en-us/library/ms538984(VS.85).aspx<http://msdn.microsoft.com/en-us/library/ms538984%28VS.85%29.aspx> > > I think that its registry key is {892F230F-FE00-4A41-A98E-FCD6DE0D35EF} > (though I don't know if I even need this) > > How can I use its function inside of python. > I tried using this by thinking it will get me somewhere (Got no idea if I > was even close) > > > point = None > Inputpp = pythoncom.MakeIID('{892F230F-FE00-4A41-A98E-FCD6DE0D35EF}') > pythoncom.CoCreateInstance(Inputpp, None, pythoncom.CLSCTX_INPROC_SERVER, > point) > > but then I got this error message > > Traceback (most recent call last): > File "<interactive input>", line 1, in <module> > TypeError: Only strings and iids can be converted to a CLSID. > This question would probably be better posed to the python-win32 mailing list. People on the tutor list are always ready to be helpful, but this one's a bit specific. To answer your question as straightforwardly as possible: the pywin32 COM extensions can't handle arbitrary COM interfaces. For that you need to use comtypes [1] (or write your own extension). The code below works against the current comtypes svn HEAD. <code> import ctypes from ctypes import wintypes import comtypes class ITfInputProcessorProfiles (comtypes.IUnknown): _iid_ = comtypes.GUID ("{1F02B6C5-7842-4EE6-8A0B-9A24183A95CA}") _idlflags_ = [] _case_insensitive_ = False _methods_ = [ comtypes.COMMETHOD ( [], comtypes.HRESULT, "GetCurrentLanguage", (["out"], ctypes.POINTER (wintypes.LANGID), "pLangId") ) ] ipp = comtypes.CoCreateInstance ( comtypes.IID ("{33C53A50-F456-4884-B049-85FD643ECFED}"), ITfInputProcessorProfiles ) langid = wintypes.LANGID (ipp.GetCurrentLanguage ()) print langid </code> I get a value of 0, which seems to indicate a major and sub language of NEUTRAL. I don't really know how languages work on Windows, and there seem to be too many variants. As an alternative, you might want to look at the win32api module, which has functions like GetUserDefaultLangID and GetUserDefaultLCID. TJG " The problem with it is that it was always returning "c_ushort(0)" No matter what language I was set on typing in. Also, how can I write my own extensions? Will it be better for me in this case to write my own extension? I hope you guys will be able to help me :) Thanks a lot!
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32