[python-win32] CreateDesktop() and displaying a window on it

2017-04-06 Thread k

Hey all,

I'm trying to get system modal functionality like the UAC dialog.

According to http://developex.com/blog/system-modal-back/ the thing to 
do is to create and switch to a new desktop.


Therefore, I'm doing:

hDeskOld=win32service.GetThreadDesktop(win32api.GetCurrentThreadId())
hDesk=win32service.CreateDesktop("SysModalDesktop",0,win32con.GENERIC_ALL,None)
hDesk.SwitchDesktop() # switch to the new desktop
try:
root=Tk()
app=SysmodalDialog(root,title,message,img)
app.mainloop()
except Exception,e:
print e
hDeskOld.SwitchDesktop() # switch back
hDesk.CloseDesktop() # done

The tk stuff inside the try works fine on its own.
If I replace the Tk stuff with time.sleep(5.0), then desktops switch 
fine as well.


The problem is I can't get the tk app to show on the new desktop (and 
therefore mainloop() blocks and I can't get back out of it!)


I tried changing Tk() to Tk(screenName="SysModalDesktop") but that 
didn't make a difference.


How do I make my window go to the right desktop??

-Kurt



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


[python-win32] force outlook ui update

2008-10-25 Thread Christian K.

Hi,

I apologize for asking a not specifically python related question but I 
have no idea where to ask (pointers welcome, too).


I noticed that after having written e.g. to the PR_SUBJECT of a mapi 
IMessage, e.g.:


msg = self.msgstore._OpenEntry(self.id, None, mapi.MAPI_BEST_ACCESS)
msg.SetProps([(PR_SUBJECT, self._subject)])
msg.SaveChanges(mapi.KEEP_OPEN_READWRITE)

the subject field in the inbox list changes immedately but the subject 
line of the message itself (either shown in the embedded panel or in its 
own frame) does not. After a couple of other actions, i.e. selecting and 
deslecting other items the message subject will be updated in every place.


Is there a way to force an UI update?

Regards, Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] force outlook ui update

2008-10-29 Thread Christan K .
Tim Roberts  probo.com> writes:

> 
> Christian K. wrote:
>
> > the subject field in the inbox list changes immedately but the subject
> > line of the message itself (either shown in the embedded panel or in
> > its own frame) does not. After a couple of other actions, i.e.
> > selecting and deslecting other items the message subject will be
> > updated in every place.
> >
> > Is there a way to force an UI update?
> 
> No.  MAPI controls the mail engine, not the user interface.

Actually I did not expect to find something within mapi. Do you have any ideas 
where to look for these gui related issues?

Thanks, Christian


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] force outlook ui update

2008-10-30 Thread Christan K .
Tim Roberts  probo.com> writes:

> 
> Christan K. wrote:
> > Tim Roberts  probo.com> writes:
> >   
> >> Christian K. wrote:
> >> 
> >>> the subject field in the inbox list changes immedately but the subject
> >>> line of the message itself (either shown in the embedded panel or in
> >>> its own frame) does not. After a couple of other actions, i.e.
> >>> selecting and deslecting other items the message subject will be
> >>> updated in every place.
> >>>
> >>> Is there a way to force an UI update?
> >>>   
> >> No.  MAPI controls the mail engine, not the user interface.
> >> 
> >
> > Actually I did not expect to find something within mapi. Do you have any 
ideas 
> > where to look for these gui related issues?
> >   
> 
> I guess it depends on what you are really trying to do, and on how
> general you need this to be.  MAPI is an abstraction.  There is no
> promise that MAPI requests will have any effect at all on a user
> interface.  The fact that you are seeing something update at all
> surprises me.  The effect would be very different if you happened to be
> running a different MAPI provider.  It might not even show a UI at all.
> 
> If what you really want to do is control Outlook, then Tim G is right --
> you need to control Outlook through Outlook's object model.  If what you
> really want to do is send email, then MAPI is a more general answer, but
> you give up the user interface.

Thank you both for your comments. In fact I naivly assumed that, thinking in 
terms of a mvc pattern, the outlook gui was the view and mapi manipulated the 
model so that the gui would be aware of every change in the model. Obviously 
this is not the case. I am using the msgstore module from the spambayes project 
to modify the mail subjects according to some special rules, triggered by 
clicking on CommandBarButtons. So I guess I wil have to look into Outlook's 
object model as Tim G. suggested. 

Thanks, Christian






___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] how to call the dll in python

2008-11-07 Thread Christian K.
ysystudio wrote:
> I have a windows dll1.dll with a export function:
>  
> int f1(char filename,char **buf,int *bufLen)
> {
> int len;
> //got the length of file anyway,such as 100
> len = 100;//len = getLen(filename);
> *buf = (char*)calloc(100);
> *bufLen = len;
> return 0;
> }
>  
> then how can I call the f1 function with python.
> thanks for your response.


Have a look at ctypes (which is included in python since 2.5):

http://python.net/crew/theller/ctypes/

Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] SOLVED: force outlook ui update

2008-12-14 Thread Christian K .
Hi,

a couple of weeks ago I asked how to refresh the outlook view after having
modified a mail's properties directly using the extended MAPI. At least for the
subject of the mail there is an easy workaround:

mailitem.Subject = mailitem.Subject

will trigger a refresh of all views of the mailitem.

Christian



___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] mapi - writing to PR_BODY

2009-02-08 Thread Christian K.

Hi,

according to
http://msdn.microsoft.com/en-us/library/cc839695.aspx
writing to the PR_BODY property of a mapi message should be done more or 
less like the following:


def TextToStream(mapi_object, text):
prop_id = PR_BODY_A
stream = mapi_object.OpenProperty(prop_id,
  pythoncom.IID_IStream,
  0, mapi.MAPI_MODIFY)
print stream.Stat(0)
print stream.Write('papperlapapp\n'*10)
mapi.RTFSync(mapi_object,
 mapi.RTF_SYNC_BODY_CHANGED|mapi.RTF_SYNC_RTF_CHANGED)
stream.Commit(1)
del stream   # instead of calling Release, which I could not find

write should return the number of bytes written but it returns None 
here. In case it makes a difference: I am not creating a new message 
rather than trying to modify the body of an existing one.
I learned much from the spambayes project how to properly read message 
bodies but I cannot find more information on write access.


Any pointers highly appreciated.

Regards, Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] mapi - writing to PR_BODY

2009-02-12 Thread Christian K.

Mark Hammond schrieb:

On 8/02/2009 7:06 PM, Christian K. wrote:

write should return the number of bytes written but it returns None
here.


It appears Roger fixed this on 2007/08/07 and the fix was in builds 211 
and 212.


I suppose I am using a recent build - where can I find the version 
information?


In fact I am currently not concerned that write returns None but that 
the code snippet shown before does not change the mail body at all.


And I had situations, where write indeed did return the number of bytes 
written, again without any change on the body. My understanding of mapi 
is very basic but this seems to have to do with the access method to the 
mail body, i.e. whether the body should be retrieved via GetProp or via 
streaming.


In the end I would like to be able the mail body of each recieved mail, 
i.e. I catch the newmail event, read the mail body and want to write it 
back. If there are any other ideas how to achieve that, I would be 
grateful to hear about them.


Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] mapi - writing to PR_BODY

2009-02-13 Thread Christian K.
Mark Hammond wrote:
> On 13/02/2009 2:35 AM, Christian K. wrote:
>> Mark Hammond wrote:
>> And I had situations, where write indeed did return the number of bytes
>> written, again without any change on the body. My understanding of mapi
>> is very basic but this seems to have to do with the access method to the
>> mail body, i.e. whether the body should be retrieved via GetProp or via
>> streaming.
> 
> That seems strange - the Write method on that interface used to
> unconditionally return None and now it unconditionally returns an integer.

I will check that again.

> 
> I'm afraid I'm missing the point then.  You referenced SpamBayes and it
> fetches the body text of each new mail as it arrives - why is that
> scheme not working for you?

Actually I am using the spambayes routines to read the body but I cannot
find a way to write it back to the message. Writing e.g. the subject is
much easier as I only have to call SetProps followed by SaveChanges.

Christian



___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] mapi - writing to PR_BODY

2009-02-13 Thread Christian K.

Mark Hammond schrieb:

On 13/02/2009 2:35 AM, Christian K. wrote:

Mark Hammond schrieb:

tuations, where write indeed did return the number of bytes

written, again without any change on the body. My understanding of mapi
is very basic but this seems to have to do with the access method to the
mail body, i.e. whether the body should be retrieved via GetProp or via
streaming.


That seems strange - the Write method on that interface used to 
unconditionally return None and now it unconditionally returns an integer.


You were right. I was mixing observations from two different machines, 
one of them has build 210, the other 212 installed. My mistake, sorry.


So write seems to work as expected (reporting the right number of bytes) 
but I have no clue *where* the data is written to. The mail body stays 
completely unaffected.


Any ideas?

Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] mapi - writing to PR_BODY

2009-02-15 Thread Christian K.

Mark Hammond schrieb:

On 14/02/2009 12:56 AM, Christian K. wrote:


So write seems to work as expected (reporting the right number of bytes)
but I have no clue *where* the data is written to. The mail body stays
completely unaffected.


I guess step 1 would be to see if you can re-read it - ie, is the data 
not getting there, or is Outlook etc simply ignoring it?


Godd point and in fact the modified text is there when I re-read it.

If the latter; I can't remember the details, but isn't there a flag 
which indicates if PR_BODY, PR_BODY_HTML or some other rich-text related 
property is used?


Right, spambayes is handling all those cases correctly and I think, that 
 it should be possible to write the plain body and let outlook do an 
internal synchronization of the various formats.


If also might be worth looking at the "Redemption" tool - IIRC, that 
tool gives you a nice raw internal view of such objects and may let you 
see what is going on a little better...


I am using outlookspy (by the same author as the redempion tool) to find 
out what is going on but had no luck so far.


Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] mapi - writing to PR_BODY

2009-02-15 Thread Christian K.
Christian K. wrote:
> def TextToStream(mapi_object, text):
> prop_id = PR_BODY_A
> stream = mapi_object.OpenProperty(prop_id,
>   pythoncom.IID_IStream,
>   0, mapi.MAPI_MODIFY)
> print stream.Stat(0)
> print stream.Write('papperlapapp\n'*10)
> mapi.RTFSync(mapi_object,
>  mapi.RTF_SYNC_BODY_CHANGED|mapi.RTF_SYNC_RTF_CHANGED)
> stream.Commit(1)
> del stream   # instead of calling Release, which I could not find

Found the solution. Partly a stupid mistake. I forgot to call
SaveChanges, for my excuse: it is not mentioned in the article above.
And the setting the PR_RTF_IN_SYNC to false is crucial to make outlook
convert the plain text to RTF.

mapi_object.SetProps([(PR_RTF_IN_SYNC, 0)])
mapi_object.SaveChanges()

Thanks Mark for your help,

Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] ANN: PyGUI 2.0

2009-04-16 Thread Christian K .

Hi,

I get the following traceback when running any demo. This is on XP using PyGUI 
2.0.1 with pythonxy 2.1.12, pywin32 2.13


Christian


$ python nag_box.py
  File "nag_box.py", line 1, in 
from GUI import ModalDialog, Label, Button, Task, application
  File "c:\pythonxy\python\Lib\site-packages\GUI\__init__.py", line 78, in 
__getattr__
traceback.print_stack()
Failed to import 'ModalDialog' from ModalDialogs
Traceback (most recent call last):
  File "c:\pythonxy\python\Lib\site-packages\GUI\__init__.py", line 69, in 
__getattr__
module = __import__(modname, self.__dict__, locals(), [name])
  File "c:\pythonxy\python\Lib\site-packages\GUI\Generic\ModalDialogs.py", line 
6, in 
from Dialogs import Dialog
  File "c:\pythonxy\python\lib\site-packages\GUI\Win32\Dialogs.py", line 7, in 

from GDialogs import Dialog
  File "c:\pythonxy\python\Lib\site-packages\GUI\Generic\GDialogs.py", line 8, 
in 
from Windows import Window
  File "c:\pythonxy\python\Lib\site-packages\GUI\Win32\Windows.py", line 15, in 

from Components import Component, _win_event_messages
  File "c:\pythonxy\python\Lib\site-packages\GUI\Win32\Components.py", line 12, 
in 
from Win32 import win_none
  File "c:\pythonxy\python\lib\site-packages\GUI\Win32\__init__.py", line 2, in 

raise ImportError("This should not be imported.")
ImportError: This should not be imported.




___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] ANN: PyGUI 2.0.2

2009-04-18 Thread Christian K.

Greg Ewing schrieb:

PyGUI 2.0.2 is available:

   http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/

Fixes problem on Windows causing "This file should not
be imported" error.


Now I get this traceback:

$ python main.py
  File "main.py", line 9, in 
from sheetapp import MatSheetApp
  File "d:\PyGUI-2.0.3\Demos\MatSheet\sheetapp.py", line 8, in 
from sheetdoc import SheetDoc, mash_type
  File "d:\PyGUI-2.0.3\Demos\MatSheet\sheetdoc.py", line 8, in 
from GUI import Document, FileType
  File "c:\pythonxy\python\Lib\site-packages\GUI\__init__.py", line 78, 
in __getattr__

traceback.print_stack()
Failed to import 'Document' from Documents
Traceback (most recent call last):
  File "c:\pythonxy\python\Lib\site-packages\GUI\__init__.py", line 69, 
in __getattr__

module = __import__(modname, self.__dict__, locals(), [name])
  File "c:\pythonxy\python\lib\site-packages\GUI\Generic\Documents.py", 
line 6, in 

from AlertFunctions import confirm, confirm_or_cancel
  File 
"c:\pythonxy\python\Lib\site-packages\GUI\Generic\AlertFunctions.py", 
line 1, in 

import BaseAlertFunctions
  File 
"c:\pythonxy\python\lib\site-packages\GUI\Generic\BaseAlertFunctions.py", 
line 5, in 

from Alerts import Alert, Alert2, Alert3
  File "c:\pythonxy\python\lib\site-packages\GUI\Win32\Alerts.py", line 
7, in 

from GAlerts import Alert, Alert2, Alert3
  File "c:\pythonxy\python\Lib\site-packages\GUI\Generic\GAlerts.py", 
line 5, in 

from BaseAlerts import BaseAlert
  File "c:\pythonxy\python\Lib\site-packages\GUI\Win32\BaseAlerts.py", 
line 10, in 

from Views import View
  File "c:\pythonxy\python\Lib\site-packages\GUI\Win32\Views.py", line 
9, in 

from Canvases import Canvas
  File "c:\pythonxy\python\lib\site-packages\GUI\Win32\Canvases.py", 
line 14, in 

from StdFonts import application_font
  File "c:\pythonxy\python\lib\site-packages\GUI\Win32\StdFonts.py", 
line 34, in 

system_font = Font("Tahoma", _win_pts_to_pixels(8))
  File "c:\pythonxy\python\lib\site-packages\GUI\Win32\Fonts.py", line 
73, in __init__

pitch_and_family = 0) ###win_family_map.get(family, win_default_pf))
  File "c:\pythonxy\python\lib\site-packages\GUI\Win32\Fonts.py", line 
34, in win_create_font

return ui.CreateFont(kwds)
TypeError: 'pitch_and_family' is an invalid keyword argument for this 
function


Christian


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] ANN: PyGUI 2.0.2

2009-04-20 Thread Christian K .
Greg Ewing  canterbury.ac.nz> writes:

> 
> Christian K. wrote:
> 
> > "c:\pythonxy\python\Lib\site-packages\GUI\Win32\ScrollableViews.py", 
> > line 31, in __init__
> >GScrollableView.__init__(self, _win = win)
> > win32ui.error: The object has been destroyed.
> 
> Do you have any problem running Tests/12-scroll.py?

Yes, same error.

Christian





___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] ANN: PyGUI 2.0.4

2009-04-21 Thread Christian K .

Hi Greg,

Greg Ewing  canterbury.ac.nz> writes:

> on Windows, although I can't be sure it will fix all
> the Windows problems people are having, because I
> haven't been able to reproduce some of them.
> 
> What is PyGUI?
> --
> 
> PyGUI is a cross-platform GUI toolkit designed to be lightweight
> and have a highly Pythonic API.
> 

I'm afraid, that error is stil there:

$ python 12-scroll.py
Traceback (most recent call last):
  File "12-scroll.py", line 38, in 
win = TestWindow()
  File "12-scroll.py", line 9, in __init__
width = 300, height = 300, scrolling = 'hv')
  File "d:\PyGUI-2.0.4\Tests\TestScrollableViews.py", line 16, in __init__
ScrollableView.__init__(self, **kwds)
  File "c:\pythonxy\python\Lib\site-packages\GUI\Win32\ScrollableViews.py", line
31, in __init__
GScrollableView.__init__(self, _win = win)
win32ui.error: The object has been destroyed.


Please tell me if I can help,

regards, Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] py2exe and com server again

2009-04-26 Thread Christian K.

Hi,

despite all the information on this list and on the wiki I can't get my 
com server up from the py2exe created dll. As it is a outlook com server 
I followed the approach taken in the spambayes project, i.e. in the 
addin I have:


bValidateGencache = not hasattr(sys, "frozen")
gencache.EnsureModule('{00062FFF---C000-0046}', 0, 9, 0,
bForDemand=True, 
bValidateFile=bValidateGencache) # Outlook 9

gencache.EnsureModule('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 1,
bForDemand=True, 
bValidateFile=bValidateGencache) # Office 9

gencache.EnsureModule('{AC0714F2-3D04-11D1-AE7D-00A0C90F26F4}', 0, 1, 0,
bForDemand=True, bValidateFile=bValidateGencache)
universal.RegisterInterfaces('{AC0714F2-3D04-11D1-AE7D-00A0C90F26F4}',
  0, 1, 0,["_IDTExtensibility2"])

and I added the typelib information to the py2exe options in the setup file:

"typelibs": [('{00062FFF---C000-0046}', 0, 9, 1),
 ('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 2),
 ('{AC0714F2-3D04-11D1-AE7D-00A0C90F26F4}', 0, 1, 0)]
   ]
This works on my developer machine but on any other I get the following 
traceback:


File "win32com\client\__init__.pyc", line 260, in DispatchWithEvents
AttributeError: 'NoneType' object has no attribute 'CLSID'

I also tried omitting the typelibs in setup.py, removed win32com\gen_py 
so that the typelib information would be generated in %temp% but still, 
anything runs on my machine but not on any other.


Any hints are highly appreciated!

Regards, Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] COM sending and receiveing events

2009-06-21 Thread Christian K .
Hi,

I apologize for my ignorance about COM programming in advance. I would like to
be pointed to an example of how I could send a message from a subthread of a COM
server back to the main thread. Being an outlook addin, the COM server is
already reacting to a couple of Outlook generated events. Now it would like to
add my own simple event handling and generation code. I have looked in the
win32com/demos folder and searched on that list, but I think I know too little
about COM to understand that information.

Regards, Christian


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] How to add Pylint for the Komodo IDE.

2009-08-20 Thread k c
Can you please help me, to add pylint for Komodo IDE. for analyze the source
code.
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] 2010 com addin and IRibbonExtensibilty

2010-12-05 Thread Christian K.

Hi,

has anybody experiencs in writing Outlook com addins using the 
IRibbonExtensibilty mechanism? I would like to make use of the ui 
features provided by office 2010. Currently I am creating office 
toolbars as demonstrated in the win32com.demos and all toolbars go to 
the "Addins" tab.


Thanks in advance, Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] 2010 com addin and IRibbonExtensibilty

2010-12-07 Thread Christian K.

Am 06.12.10 05:42, schrieb robert2682:

Christian K. wrote:

Hi,

has anybody experiencs in writing Outlook com addins using the
IRibbonExtensibilty mechanism? I would like to make use of the ui
features provided by office 2010. Currently I am creating office
toolbars as demonstrated in the win32com.demos and all toolbars go to
the "Addins" tab.


I tried to get it working using Excel 2007 (I have not tried 2010). I
was able to get the extension to display on the Ribbon, and was able to


I even fail to get that far. What do I have to change here to be able 
access the new style toolbars?


class Addin:
_com_interfaces_ = ['_IDTExtensibility2']
_public_methods_ = []
_reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER
_reg_clsid_ = "{D371B22C-78B1-4271-8C10-60AE4719CEE5}"
_reg_progid_ = "my_addin"
_reg_policy_spec_ = "win32com.server.policy.EventHandlerPolicy"

I must admit that I have neither read M.Hammonds book nor am I a windows 
programmer.



call a function on a button click, but I ran into trouble reading the
value of the IRibbonControl parameter to the callback. I just kept
getting a com error (I don't recall the number, but it was the one that
means generic error to Microsoft) trying to access the properties of the
IRibbonControl. I spent a goodly amount of time on this, and eventually
decided it was some kind of bug.

I had meant to post a small program demonstrating the bug, but never got
to it. If you make any progress, or want to discuss this further, please
let me know, on or off list.


Let us continue the discussion here. I would have been glad if I had found
something about that topic while searching.

Regards, Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] 2010 com addin and IRibbonExtensibilty

2010-12-08 Thread Christian K.

Hi Robert,

Am 09.12.10 00:05, schrieb robert2682:

 2) I'd appreciate it if you'll let me know whether the Tag attribute in

the callback can be read. This is the problem I mentioned in my initial
response. Just let me know the contents of the second message box after
clicking the button in Office.


I did a quick test (with Excel) and it seems to work:
Getting tag ok, tag=RibbonCall

Let me know if I can help with further tests.

Now I will have a look at your code. Thanks a lot!

Christian


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] addin fails to load the first time after login

2011-11-23 Thread Christian K.
Hi,

I am observing a strange behaviour of two python com-servers/addins, one
of them is called from Excel VBA the other one is an Outlook (both from
Office 2003) addin.

Both of them work if I register them and start using Outlook or Excel
thereafter. However when I log out and login the next time, both of them
fail to load. Excel is showing an error message when
CreateObject("addin") is called, showing a python traceback from
somewhere within win32com (only parts of it since the window cannot be
resized). Outlook silently ignores the addin and in the list of
com_addins it is marked as deactivated. Re-registering solves the
problem until the next login.

Interestingly I get them to work if I start e.g. spyder (a python IDE)
before making calls to the com servers. It does not seem to help though,
if I only open a python shell. This sounds like a timeout issue to me.

Do you know what might be the cause and what I can do about it?

Best regards, Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] how to create a instance of PyIMAPISession by hand

2013-05-08 Thread Christian K .

The following code has been suggested to me to get a handle to Outlook's
mapi session.


from win32com.client import Dispatch
from win32com.mapi import mapi
app = Dispatch('Outlook.Application')
app.GetNamespace('MAPI').Session.MAPIOBJECT

The MAPIOBJECT would then have to be cast to a IMAPISession object. How
would I do that? By calling the PyIMAPISesison constructor with MAPIOBJECT
as argument? Unfortunately I was not able to find the PyIMAPISession class
in the pywin32 namespace nor when digging through the source.



Any hints are very much appreciated.

Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] debugging outlook addin

2013-05-19 Thread Christian K.


I need to debug an outlook addin written in python which crashes outlook 
in a reproducible manner. How could I do that? Is it possible to have 
the addin loaded from within a pdb session?

The addin uses the mapi msgstore wrappers from the spambayes project.
The crash occurs while the addin is starting a background job in a 
thread. MAPIInitialize is called by the new thread as required by the 
msdn docs. The thread then is busy for some tens of seconds exporting 
mailitems by calling MailItem.Save provided by the OOM. In general this 
works fine, but on one system outlook crashes after a while without any 
python traceback. Sometimes the problem will disappear, especially when 
I insert print statements in the export loop (heisenbug?).


Thasnk, Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] wx.Frame with windows parent

2013-06-04 Thread Christian K.

Hi,
I asked this some time ago on the wxpython list and still have no solution:

I am trying to make a wx.Dialog float on a non-wxpython parent. I get 
the HWND of the window, call wx.Window_FromHWND(None, HWND) and open the 
dialog with that parent and FLOAT_ON_PARENT style. This works very well 
but suprisingly, it prevents the parent frame (in this case Outlook) 
from closing when clicking on the window's close button.
Actually this happens right after calling wx.Window_FromHWND, i.e. 
before opening/attaching the child window. After that the close button 
is no working anymore.

Is that to be expected? How can I possibly avoid that?

This happens with wxpython 2.8.12.1 and latest pywin32 on windows 7 (32bit)

Regards, Christian

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] python3 and extended mapi

2014-06-09 Thread Christian K .
Hi,

I was very pleased to see that retrieving properties of a MAPI object yields
either a  or  type depending on whether the _A or _W property
was queried and entryids are always returned as bytes types. Very nice! This
makes a lot of bin2str2bin conversion and encoding/decoding code obsolete.
Nevertheless now it seems that mapi.BinFromHex has a problem (needed to
convert entryids retrieved from the Outlook Object Model) with the input
type. It says it needs unicode input but I think it rather expects a 8-bit
string although it rejects bytes types. I replaced it by binascii.unhexlify
and do not need it anymore but for completeness I thought it should be reported.

Christian

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


Re: [python-win32] python3 and extended mapi

2014-06-09 Thread Christian K .
  Dell.com> writes:

> 
> 
> On Jun 9, 2014, at 9:07 AM, Christian K.  hoc.net> wrote:
> 
> > Hi,
> > 
> > I was very pleased to see that retrieving properties of a MAPI object yields
> > either a  or  type depending on whether the _A or _W property
> > was queried …
> 
> Really?  That seems strange.  As I recall, the *_W APIs are “wide
character” ones.  So in Python 3, they
> should both map to  type.   applies only to non-text data.

At least for text properties like e.g. PR_SUBJECT_A / _W the former returns
a mbcs encoded "string", i.e. of bytes type and the latter a 2-byte unicode
string. Binary properties are always returned as bytes in contrast to
earlier when using pyrhon2.

Chrisrian




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


Re: [python-win32] python3 and extended mapi

2014-06-09 Thread Christian K.

Am 09.06.14 16:00, schrieb paul_kon...@dell.com:


On Jun 9, 2014, at 2:53 PM, Christian K.  wrote:


 Dell.com> writes:




On Jun 9, 2014, at 9:07 AM, Christian K.  hoc.net> wrote:


Hi,

I was very pleased to see that retrieving properties of a MAPI object yields
either a  or  type depending on whether the _A or _W property
was queried …


Really?  That seems strange.  As I recall, the *_W APIs are “wide

character” ones.  So in Python 3, they

should both map to  type.   applies only to non-text data.


At least for text properties like e.g. PR_SUBJECT_A / _W the former returns
a mbcs encoded "string", i.e. of bytes type and the latter a 2-byte unicode
string. Binary properties are always returned as bytes in contrast to
earlier when using pyrhon2.


Yes, “bytes” for binary values is clearly correct.  But MBCS and “2 byte 
Unicode” (more accurately called either UCS-2 or UCS-2 BMP subset, not sure 
which) are both text strings.  The different encoding in the API doesn’t mean 
they should be different datatypes in Python 3; both cases are properly mapped 
to “str”.


No, this is not what I am seeing. MBCS encoded properties, i.e. those 
terminating with _A are mapped to 'bytes' and the _W ones to 'str' which 
is consistent with the handling of unicode and encoded information in 
python3. And this is great indeed because having to distinguish between 
strings which can be encoded or not while having the same type is really 
painful.


Christian




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


Re: [python-win32] python3 and extended mapi

2014-06-10 Thread Christian K .
  Dell.com> writes:

> 
> 
> On Jun 9, 2014, at 9:40 PM, Christian K.  hoc.net> wrote:
> 
> > Am 09.06.14 16:00, schrieb Paul_Koning  Dell.com:
> >> 
> >> On Jun 9, 2014, at 2:53 PM, Christian K.  hoc.net> wrote:
> >> 
> >>>  Dell.com> writes:
> >>> 
> >>>> 
> >>>> 
> >>>> On Jun 9, 2014, at 9:07 AM, Christian K.  hoc.net> wrote:
> >>>> 
> >>>>> Hi,
> >>>>> 
> >>>>> I was very pleased to see that retrieving properties of a MAPI
object yields
> >>>>> either a  or  type depending on whether the _A or _W
property
> >>>>> was queried …
> >>>> 
> >>>> Really?  That seems strange.  As I recall, the *_W APIs are “wide
> >>> character” ones.  So in Python 3, they
> >>>> should both map to  type.   applies only to non-text data.
> >>> 
> >>> At least for text properties like e.g. PR_SUBJECT_A / _W the former
returns
> >>> a mbcs encoded "string", i.e. of bytes type and the latter a 2-byte
unicode
> >>> string. Binary properties are always returned as bytes in contrast to
> >>> earlier when using pyrhon2.
> >> 
> >> Yes, “bytes” for binary values is clearly correct.  But MBCS and “2
byte Unicode” (more
> accurately called either UCS-2 or UCS-2 BMP subset, not sure which) are
both text strings.  The different
> encoding in the API doesn’t mean they should be different datatypes in
Python 3; both cases are properly
> mapped to “str”.
> > 
> > No, this is not what I am seeing. MBCS encoded properties, i.e. those
terminating with _A are mapped to
> 'bytes' and the _W ones to 'str' which is consistent with the handling of
unicode and encoded information
> in python3. And this is great indeed because having to distinguish between
strings which can be encoded or
> not while having the same type is really painful.
> 
> Perhaps I’m missing something.
> 
> I’m used to Windows API calls that come in a foo_A and foo_W flavor, the
only difference being that the _A
> flavor has ASCII arguments and the _W flavor has Unicode arguments (for
those arguments that are,
> abstractly, strings).
> 
> In Python 3, the “str” type is an abstract string; its character
repertoire is Unicode but it doesn’t
> have an encoding.  Instead, encoding and decoding is done when it is
converted to/from external
> interfaces — files, external API calls, etc.

True, and the type which handles that data is called "str". In contrast to
what I said before more than two bytes have to be used internally since
unicode defines more than 10 characters.

> So... I would expect foo_A and foo_W to have “str” arguments, and the
interface machinery between
> Python3 and those functions would run the appropriate encoding to generate
the string representation expected.
> 
> For example, if a given API wants strings in ASCII form, it would be
str.encode (“ascii”) or perhaps
> str.encode (“latin1”).  If it wants MBCS data, it would be encode to that
encoding.  If 2-byte Unicode,
> it would be encode to ucs-2.  And so on.  Ditto in the reverse direction,
when strings are delivered by an
> external function.

Whenever you encode a "str" object in python3, i.e. call its encode() method
you will end up with a "bytes" object. And vice versa only a "bytes" object
does have a decode method. So the concept of having a unicode character pool
and its printable representation is reflected by two differnt types in
python. unicode:"str", any encoded string:"bytes"
For that reason, if a function returns an encoded string, the return type
has to be "bytes" and this is what is happening when retrieving the _A
properties.
Try it yourself: type('a') yields "unicode", type('a'.encode('asci''))
yields "bytes"

> I would only want/expect to see “bytes” types when the values in question
are binary data streams, or
> unknown format.  But anytime we’re dealing with text strings, the Python 3
approach is that the Python
> code sees “str” type, and questions of encoding have been handled at the
edge.  This is where Python 3

This is not true, see above.

Christian



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


Re: [python-win32] python3 and extended mapi

2014-06-10 Thread Christian K .
Mark Hammond  gmail.com> writes:

> 
> It would be great if you could open a bug at sourceforge...

Done.

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


Re: [python-win32] python3 and extended mapi

2014-06-10 Thread Christian K .
Christian K.  hoc.net> writes:

> 
>   Dell.com> writes:

> > I would only want/expect to see “bytes” types when the values in question
> are binary data streams, or
> > unknown format.  But anytime we’re dealing with text strings, the Python 3
> approach is that the Python
> > code sees “str” type, and questions of encoding have been handled at the
> edge.  This is where Python 3
> 
> This is not true, see above.

What I mean is that you cannot leave it to the application. Once a "str"
type is returned is has to be assumed that it contains unicode data. "str"
classes do not have a decode method or is there a way to decode the data
hold by a "str" object assuming that is encoded and not unicode? 

Christian

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


Re: [python-win32] python3 and extended mapi

2014-06-14 Thread Christian K.

   Dell.com> writes:



I would only want/expect to see “bytes” types when the values in question

are binary data streams, or

unknown format.  But anytime we’re dealing with text strings, the Python 3

approach is that the Python

code sees “str” type, and questions of encoding have been handled at the

edge.  This is where Python 3

This is not true, see above.


What I mean is that you cannot leave it to the application. Once a "str"
type is returned is has to be assumed that it contains unicode data. "str"
classes do not have a decode method or is there a way to decode the data
hold by a "str" object assuming that is encoded and not unicode?


No objections here? I am not an expert to be without doubts on what I 
said myself. So please tell me if I am wrong.


Christian


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


[python-win32] question about DynamicPolicy.py

2007-02-02 Thread k f

Greetings,

In Chapter 12 of "Python Programming on Win32" there is a sample code
demonstrating how to expose a python module in a COM server.  A function
named FixArgs is used in the example to convert Unicode string to ascii
string.  I'm guessing this is no longer necessary for the recent versions of
python.  Btw, I'm using version 2.5. Can anyone confirm this? Thank you.

--
Kelie
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] com events while running wx main loop

2007-04-17 Thread Christian K.
Hi,

I'm trying to recieve com events in a wxpython application. I modified 
an example posted here by Thomas Heller some time ago. It seems that the 
events are not delivered. Am I doing something wrong or is this just a 
limitation of com/wxPython?

Thanks for any hint, Christian

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] com events while running wx main loop

2007-04-17 Thread Christian K.


sorry. I forgot the attachment.

Christian

import unittest
import comtypes.client

import wx

class EventHandler(object):
"""Instances are called when the COM object fires events."""
def __init__(self, view, name):
self.view = view
self.name = name

def __call__(self, this, *args, **kw):
self.view.write(unicode("Event %s fired" % self.name, args, kw))

class Events(object):
"""Provide handlers for COM events."""
def __init__(self, view):
self.view = view
self._event_names = set()

def __getattr__(self, name):
if name.startswith("__") and name.endswith("__"):
raise AttributeError(name)
self.view.write("# event found: %s"%name)
self._event_names.add(name)
return EventHandler(self.view, name)

class Panel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)

self.txt = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE|wx.TE_READONLY)
box = wx.BoxSizer(wx.VERTICAL)
box.Add(self.txt, 1 ,wx.EXPAND)
self.SetSizer(box)
self.Layout()

def write(self, txt):
self.txt.SetValue(self.txt.GetValue()+unicode(txt)+'\n')

class Listener(object):
def __init__(self):
app = wx.PySimpleApp(0)
self.f = wx.Frame(None, -1, 'listener')
self.view = Panel(self.f)

self.com_init()

self.f.Show()
app.MainLoop()

def com_init(self):
sink = Events(self.view)
self.o = comtypes.client.CreateObject("Outlook.Application", sink = 
sink)


if __name__ == "__main__":
Listener()
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] com events while running wx main loop

2007-04-18 Thread Christian K.
Thomas Heller wrote:
> Christian K. schrieb:
>> sorry. I forgot the attachment.
>>
>> Christian
>>
>>
>>
>> 
>>
>> import unittest
>> import comtypes.client
>>
>> import wx
>>
>> class EventHandler(object):
>> """Instances are called when the COM object fires events."""
>> def __init__(self, view, name):
>> self.view = view
>> self.name = name
>>
>> def __call__(self, this, *args, **kw):
>> self.view.write(unicode("Event %s fired" % self.name, args, kw))
> 
> Here is the problem:  

silly. Thanks. Works fine with the old version of comtypes I had installed.

Now I installed comtypes from svn and get this error running your new
example:

Traceback (most recent call last):
   File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 64, in ?
 Listener()
   File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 50, in 
__init__
 self.com_init()
   File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 59, in 
com_init
 self.s = comtypes.client.GetEvents(self.o, sink)
   File "c:\Python24\Lib\site-packages\comtypes\client\__init__.py", 
line 358, in GetEvents
 raise TypeError("cannot determine source interface")
TypeError: cannot determine source interface

As I'm real beginner with python on windows I'd like to ask some 
elementary questions if you don't mind:
1) Does comtypes depend on pywin32?
2) It seems that it provides the same (similar) mapi interface as 
pywin32, so can it be used as a replacement for pywin32?
3) Does comtypes expose the extended mapi?

Thanks for your help, Christian



___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] com events while running wx main loop

2007-04-20 Thread Christian K.
Thomas Heller wrote:
> Christian K. schrieb:
>> Now I installed comtypes from svn and get this error running your new
>> example:
>>
>> Traceback (most recent call last):
>>File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 64, in ?
>>  Listener()
>>File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 50, in 
>> __init__
>>  self.com_init()
>>File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 59, in 
>> com_init
>>  self.s = comtypes.client.GetEvents(self.o, sink)
>>File "c:\Python24\Lib\site-packages\comtypes\client\__init__.py", 
>> line 358, in GetEvents
>>  raise TypeError("cannot determine source interface")
>> TypeError: cannot determine source interface
> 
> First of all, when you install a new comtypes version you should clear the
> contents of the comtypes\gen directory, so that the typelib wrappers can
> be regenerated.  The old versions from previous comtypes releases should
> better not be used.

I had the comtypes directory removed before installing from svn.

> Second, if you are running the exact sample that I posted then it should work
> for InternetExplorer, and with slight changes also for Outlook.  At least
> it worked for me.

Well, here it doesn't.

> Third, the GetEvents function requires that the COM object exposes type 
> information,
> and that this information includes info about the outgoing default interface.
> Some objects do not do this, then you have to find the outgoing interface 
> yourself
> and pass that as the 'interface=...' parameter to the GetEvents function 
> (this description
> is from memory, read the sources to find out)

Ok, I've no idea what the 'interface' is in this case. Time for a good 
book obviously.

>> 2) It seems that it provides the same (similar) mapi interface as 
>> pywin32, so can it be used as a replacement for pywin32?
>> 3) Does comtypes expose the extended mapi?
> 
> I never used mapi so I cannot really answer this.
> comtypes normally creates the typelib wrappers itself; when these
> contain the mapi interfaces then there are chances that it would work.

The point why I was asking that, is, that in order to circumvent some 
silly Outlook security barrier when accessing it with simple mapi one 
has to use the extended mapi interface according to what I've understood 
from googeling. pywin32 ships with an example of how to create a new 
mail using the extended mapi and I guess this is the way to go for me.

But honestly I still know too few to even use all those acronyms properly :)

> If you are a newbie to COM, and pywin32 exposes the functionality that you 
> need
> you should probably better use pywin32. It is stable, well maintained, and 
> documented.
> You should probably get the 'Python Programming on Win32' book, or at least 
> read
> the online sample chapter.

Thank you for pointing that out.

> However, if you are brave, if you need to use non-dispatch based interfaces; 
> then
> comtypes may be what you want.

I successfully read out the Outlook inbox using comtpyes but finally 
switched back to pywin32 because I was not able to interprete the value 
of MailItem.CreationTime,
e.g:
obj.Session.Folders['mail.server.com'].Folders['INBOX'].Items.Item(1).CreationTime
which looks like a posix timestamp which dates back to the 70th. I guess 
pywin32 is doing some conversion there and comtypes is not?

Anyway I'll have a look at both again after having read some more 
documentation.

Christian

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] com events while running wx main loop

2007-04-20 Thread Christian K
Thomas Heller wrote:
> Christian K. schrieb:
>>> Second, if you are running the exact sample that I posted then it should 
>>> work
>>> for InternetExplorer, and with slight changes also for Outlook.  At least
>>> it worked for me.
>> Well, here it doesn't.
> 
> comtypes uses fairly extensive logging calls in certain areas.  You can 
> enable this
> to find out the reason.  Here is a little code snippet that shows what 
> happens on
> my system when I call GetEvents() with Internet Explorer:
> 
> 
> from comtypes.client import CreateObject, GetEvents
> import logging
> ie = CreateObject("InternetExplorer.Application")
> logging.basicConfig(level=logging.DEBUG)
> GetEvents(ie, sink=object())
> 

Thank you very much for all your help so far. I'll be quiet for the next two
weeks since I'm out of town.

Christian


___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] how to create a valid Sink

2007-05-08 Thread Christian K.

Hi,

I'd like to ask for help on how to create a valid event Sink which I can 
pass to the Advise() method of a message stores table.

Any class I made up so far gives the same error:

File "", line 333, in notify
TypeError: The Python instance can not be converted to a COM object

So what attributes does an object need to be convertable to a COM object?

Thanks in advance, Christian

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] how to create a valid Sink

2007-05-09 Thread Christian K.
Mark Hammond wrote:
>> I'd like to ask for help on how to create a valid event Sink
>> which I can
>> pass to the Advise() method of a message stores table.
> 
> This might be tricky unless pywin32 already has support for the specific
> interface you need.

I want to receive 'new mail' notifications from Outlook.

>> Any class I made up so far gives the same error:
>>
>> File "", line 333, in notify
>> TypeError: The Python instance can not be converted to a COM object
>>
>> So what attributes does an object need to be convertable to a
>> COM object?
> 
> It would need to be like any other pywin32 COM object; you should be able to
> find info about that on the web.

Forgive my ignorance but those are my first steps with com. Does that 
mean I should create and register a COM server?

Basically I'm trying to reimplement the following code in python:

http://www.codeproject.com/internet/CMapiEx.asp

Up to now this was straightforward, but at this point I'm stuck.

Thanks for any help, Christian

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] how to create a valid Sink

2007-05-09 Thread Christian K.


Mark Hammond wrote:
>> Forgive my ignorance but those are my first steps with com. Does that
>> mean I should create and register a COM server?
>
> You should create one - you probably don't need to register it.
>
>> Basically I'm trying to reimplement the following code in python:
>>
>> http://www.codeproject.com/internet/CMapiEx.asp
>>
>> Up to now this was straightforward, but at this point I'm stuck.
>
> I can't see anything related to a "sink" on that page - but as a start,

True, I was refering to the code in the zip file on that page. I'll 
attach MAPISink.h below.


> consider looking at the spambayes package at spambayes.org - there is 
code

> there that deals with MAPI in various ways.
>

Thank you. I'll have a look at it.

Christian

#ifndef __MAPISINK_H__
#define __MAPISINK_H__


//
// File: MAPISink.h
// Description: MAPI Advise Sink Wrapper
//
// Copyright (C) 2005-2006, Noel Dillabough
//
// This source code is free to use and modify provided this notice remains 
intact and that any enhancements
// or bug fixes are posted to the CodeProject page hosting this class for the 
community to benefit.
//
// Usage: see the Codeproject article at 
http://www.codeproject.com/internet/CMapiEx.asp
//




// CMAPISink

class CMAPISink : public IMAPIAdviseSink
{
public:
CMAPISink(LPNOTIFCALLBACK lpfnCallback,LPVOID lpvContext);

// Attributes
protected:
LPNOTIFCALLBACK m_lpfnCallback;  
LPVOID m_lpvContext;  
LONG m_nRef;  

// IUnknown
public:
STDMETHOD(QueryInterface)(REFIID riid,LPVOID FAR* ppvObj);
STDMETHOD_(ULONG, AddRef)();
STDMETHOD_(ULONG, Release)();

// IMAPIAdviseSink
public:
STDMETHOD_(ULONG, OnNotify)(ULONG cNotification,LPNOTIFICATION 
lpNotifications);
};  

#endif
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] AD group membership - recursive query

2007-06-26 Thread M K

Hello there,

First let me say that I'm new to both Python and LDAP programming in
general, so you can safely assume that I'm coding somewhat blindly.

What I'm trying to do is build a program against a Microsoft Active
Directory that will find all group memberships for the current user. Because
we have nested groups, it will need to do so recursively.

There is a VBScript that I'm using as a basis:

http://www.microsoft.com/technet/technetmag/issues/2006/03/ScriptingGuy/default.aspx

I wanted to share this before I delve any further to make sure I'm not
making any newbie mistakes. My ultimate goal is to build a List of all these
Groups, and remove any duplicates that may show up.

Here's the current state:


import active_directory

def nestedlookup (group):
   """ does a recursive lookup """
   nested_list = group.memberOf
   for members in nested_list:
   print "DESCENDENT: ", members.cn
   nestedlookup(members)

user = active_directory.find_user ()
print "User:", user.cn

group_list = user.memberOf

for group in user.memberOf:
   print "PARENT: ", group.cn
   nestedlookup(group)

__

Many thanks for any advice!
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] meaning of bin string representation of PR_ENTRYID

2007-06-28 Thread Christian K.
Hi,

can anybody tell me the meaning of the binary string representation of a
PR_ENTRYID, as obtained by calling GetProps() on a mail item?

I get e.g. the following IDs:

3C437E32AFD11C49ABB743DDE9EDFE6BE4652000
3C437E32AFD11C49ABB743DDE9EDFE6B24602000
3C437E32AFD11C49ABB743DDE9EDFE6B845F2000
3C437E32AFD11C49ABB743DDE9EDFE6B44612000
3C437E32AFD11C49ABB743DDE9EDFE6BA4672000
3C437E32AFD11C49ABB743DDE9EDFE6B64652000
 ^^

In case there isn't any meaning:
I noticed that most of the data is equal for all messages of one mail 
folder.
Only the characters marked above (3 bytes) are unique per item. Is it always
like that?
The reason I'm asking is, that I'd like to have a numeric representation of
those IDs. So, do you think int('0x'+id[40:46],16) would be ok?

Thanks for any hint, Christian

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] meaning of bin string representation of PR_ENTRYID

2007-06-28 Thread Christian K.
Mark Hammond wrote:
>> can anybody tell me the meaning of the binary string
>> representation of a
>> PR_ENTRYID, as obtained by calling GetProps() on a mail item?
> 
> Its a binary value that is unique for the item (but only unique within the
> store - PR_STORE_ENTRYID will tell you the store ID)
> 
>> I get e.g. the following IDs:
>>
>> 3C437E32AFD11C49ABB743DDE9EDFE6BE4652000
>> 3C437E32AFD11C49ABB743DDE9EDFE6B24602000
>> 3C437E32AFD11C49ABB743DDE9EDFE6B845F2000
>> 3C437E32AFD11C49ABB743DDE9EDFE6B44612000
>> 3C437E32AFD11C49ABB743DDE9EDFE6BA4672000
>> 3C437E32AFD11C49ABB743DDE9EDFE6B64652000
>>  ^^
> 
> You are getting them via the client libraries, which has already encoded the
> binary data as hex for you.  If you were to get the property directly from
> "extended mapi", you would get a string holding binary data.

I forgot to mention that. I used the extended mapi and converted it 
using HexFromBin.

>>
>> In case there isn't any meaning:
>> I noticed that most of the data is equal for all messages of one mail
>> folder.
>> Only the characters marked above (3 bytes) are unique per
>> item. Is it always
>> like that?
>> The reason I'm asking is, that I'd like to have a numeric
>> representation of
>> those IDs. So, do you think int('0x'+id[40:46],16) would be ok?
> 
> The values above already *are* a hexadecimal value - you can't safely change
> any part of it.

I do not want to change it. I hoped that the extracted part might be 
enough to identify a message within one message store.

 int("3C437E32AFD11C49ABB743DDE9EDFE6B64652000", 16)
> 344044589573578334092534486689392272954676813824L
> 
> Its a very large number to be sure, that that it the "numeric ID".

Indeed big. For my purpose I need an int though, not a long int. That's 
the reason why I tried to extract a smaller part. But if you don't 
consider it safe I will use a mapping dict to convert between the EIDs 
and my own ids.

Thanks, Christian

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] meaning of bin string representation ofPR_ENTRYID

2007-06-28 Thread Christian K.
Mark Hammond wrote:
>> > The values above already *are* a hexadecimal value - you
>> > can't safely change any part of it.
>>
>> I do not want to change it. I hoped that the extracted part might be
>> enough to identify a message within one message store.
> 
> That's what I meant - I should have said "you can't make any assumptions
> about any part of it" - indeed, you can't even *compare* 2 values to see if
> they are the same - you must ask MAPI to compare them.  You'll have to check
> the MS docs for exactly what they do and do not promise...

This sounds as if there was no point at all to do anything with the 
eids. If I am not even allowed to compare two ids, how could they point 
at different mail items?

The docs say:

"""
The PR_ENTRYID property identifies an object for OpenEntry to 
instantiate and provides access to all of its properties through the 
appropriate derived interface of IMAPIProp.
"""

I assume that means it is ok to store the eids and use them with 
OpenEntry to access the messages store's items.

Thanks again, Christian

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] how to terminate a extended mapi session

2007-08-24 Thread Christian K.
Hi,

what must I take care of by myself when I want to terminate a program which
communicates with Outlook through the extended mapi interface, i.e. in addition
to session.Logoff and mapi.MAPIUnitialize?
Currently I get the following errors upon prorgam termination and, what is more
important, Outlook hangs and has to be restarted:

Win32 exception occurred releasing IUnknown at 0x01fa09a8
Win32 exception occurred releasing IUnknown at 0x01f9e5c0
Win32 exception occurred releasing IUnknown at 0x01f9e5e8
Win32 exception occurred releasing IUnknown at 0x01f9e610
Win32 exception occurred releasing IUnknown at 0x01f82a48
Win32 exception occurred releasing IUnknown at 0x01fb7fc0
Win32 exception occurred releasing IUnknown at 0x01fb7fe8
Win32 exception occurred releasing IUnknown at 0x01f82aa0
Win32 exception occurred releasing IUnknown at 0x01f82ac8
Win32 exception occurred releasing IUnknown at 0x01f82af0
Win32 exception occurred releasing IUnknown at 0x01f82400
Win32 exception occurred releasing IUnknown at 0x01f89f80
Win32 exception occurred releasing IUnknown at 0x01f82428
Win32 exception occurred releasing IUnknown at 0x047b1fa8

Thanks for any hint, Christian


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] using wxPython from Outlook addin

2007-10-08 Thread Christian K.
Hi,
since my knowlegde about windows gui programming is not existent I'd prefer to
do the gui part of a Outlook addin using wxPython. 
Is that possible at all and if yes, at which point can I start the wxPython main
loop? Basically the addin does similar things as spambayes. It listens to button
and folder events and does something with the mail items.
Thanks for any hints, Christian


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] writin Outlook's custom action rules in python?

2007-10-15 Thread Christian K.
Hi,
is there any chance that one could write a custom action rule
(CAR, see http://support.microsoft.com/?kbid=151690)
for Outlook in python? 
Christian


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] gui examples

2007-10-15 Thread Christian K.
Hi,
could somebody point me please to examples of gui programming using pywin32?
Thanks, Christian


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] gui examples

2007-10-16 Thread Christian K.
Ludovic Reenaers wrote:
> Hi,
> you should download WxPython there is a pretty nice documentation with very
detailed samples.
> cheers,

I know, thanks. wxPython is usually my first choice, however this time I just
need some simple stuff, e.g. simple dialogs, message boxes and I don't want to
have that additional dependency.
I tried to learn from VB scripts, but all the gui stuff is usually done
with a gui builder, if I'm not wrong. So not much to learn there.

Christian


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] gui examples

2007-10-16 Thread Christian K.
Tim Golden  timgolden.me.uk> writes:

> 
> Christian K. wrote:
> > Ludovic Reenaers wrote:
> >> Hi,
> >> you should download WxPython there is a pretty nice documentation with very
> > detailed samples.
> >> cheers,
> > 
> > I know, thanks. wxPython is usually my first choice, however this time I 
> > just
> > need some simple stuff, e.g. simple dialogs, message boxes 
> 
> If that's really all you need, have a look at easygui:
> 
>http://www.ferg.org/easygui/

Indeed, that should provide everything I need, although I'd prefer using the
native gui elements and not Tk.

Christian


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] gui examples

2007-10-16 Thread Christian K.
Thanks everybody for all the pointers. I've enough to play with now.

Christian


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] unable to receive button click notifications

2007-10-16 Thread Christian K.

Hi,

I'm just trying the pywin gui examples and I'm wondering why I won't 
receive any BN_CLICKED notifications in the code attached. Can anyone help?


Christian

from pywin.mfc import dialog, window
import win32ui
import win32con
import win32api

def MakeDlgTemplate():
style = (win32con.DS_MODALFRAME |
 win32con.WS_POPUP |
 win32con.WS_VISIBLE |
 win32con.WS_CAPTION |
 win32con.WS_SYSMENU |
 win32con.DS_SETFONT)
cs = (win32con.WS_CHILD |
  win32con.WS_VISIBLE)

w = 164
h = 264

dlg = [["Red box",
(0, 0, w, h),
style,
None,
(9, "MS Sans Serif")],
   ]

s = win32con.WS_TABSTOP | cs

dlg.append([128,
"Cancel",
win32con.IDCANCEL,
(7, h - 18, 50, 14), s | win32con.BS_PUSHBUTTON])

dlg.append([128,
"Ok",
win32con.IDOK,
(57, h - 18, 50, 14), s | win32con.BS_PUSHBUTTON])

return dlg

class TestDialog(dialog.Dialog):
def OnInitDialog(self):
rc = dialog.Dialog.OnInitDialog(self)
self.btn = win32ui.CreateButton()
self.btn.CreateWindow('button', 
win32con.BS_PUSHBUTTON|win32con.WS_CHILD|win32con.WS_VISIBLE, (5, 5, 140, 140), 
self, 1001)

self.HookNotify(self.OnNotify, win32con.BN_CLICKED)

def OnNotify(self, *args):
print args

def demo():
d = TestDialog (MakeDlgTemplate())
d.DoModal()

if __name__=='__main__':
demo()

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] FTP Task Schedule in Python

2008-03-24 Thread K-Factory
Hi Forum,


I need to automate a scheduled weekly task i.e. downloading a file from FTP.
This is to be done on WINDOWS but I am unable to make any further
development on this as I am stuck with the python scheduler itself. Can
somebody help me with this, I just need a skeleton of code further things I
can personally input. Also can any one provide me with the link for any such
scheduler code or project.



Thanks Dylan
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] catching the "close" event

2009-02-12 Thread Pollack, Steven K
I am trying to write a python based glue to orchestrate interaction
between Access, Excel and Outlook.  

I understand events reasonably well, can DispatchWithEvents an instance
of excel and catch worksheet and file save related events.  but can't
figure out if there is an event I can catch associated with the "close"
button (the little ole red x) that I can trap  and or cancel before the
application dies.  I want to force a file save first.

Also, it would be nice to know (for a newbie)  how to search the archive
to see if such a thing has already been asked.

Steven K. Pollack, Ph.D.
Director, Division of Chemistry and Materials Science
Office of Science and Engineering Laboratories
Center for Devices and Radiological Health
Food and Drug Administration
10903 New Hampshire Avenue, Building 64, Room 4028
Silver Spring, Maryland 20903-0002
(301)-796-2476 (V)
(301)-801-4228 (M)
(301)-796-9924 (F)



___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Jonathan K Shelley is out of the office.

2009-07-22 Thread Jonathan K Shelley

I will be out of the office starting  07/21/2009 and will not return until
07/27/2009.

I will respond to your message when I return. For  assistance please
contact Blaik Beattie (blaik.beat...@inl.gov)___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Need data type identifiers

2012-07-21 Thread Fox, Michael K
We are having occasional difficulties when we need to pass an argument 
in-and-out of a COM method that we are calling in Python.  There is some magic 
in makepy that normally handles this for us but occasionally it fails because 
it somehow reads the typelib incorrectly and misunderstands the data type it 
must create.  Specifically, I have a C++ method exposed to COM and it expects 
an empty SafeArray of two elements (double floats) to be passed as an argument. 
 That method revises the array, filling it with two values.  We have found that 
makepy assigns some sort of identifier to each data type.  For instance an 
array of strings is assigned (24584, 3) and an array of variants is assigned 
(24588, 3) as shown in the line of code below, taken from one of the wrappers 
created by Makepy.

def GetDirection(self, oDirection=(0,0)):
  return self._ApplyTypes_(1611137025, 1, (24, 0), ((24588,3),), 
u'GetDirection', None, oDirection)

Occasionally pywin32 assigns the wrong identifier then the argument is cast as 
the wrong data type and an error is thrown.  We stumbled upon the correct 
identifier and when we corrected the identifier assigned by Makepy then we were 
able to call the method without throwing an error.  Where can we find a list of 
these identifiers?

Mike Fox

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Need data type identifiers

2012-07-30 Thread Fox, Michael K
Thanks Mark.  That's exactly what we needed.
  Mike Fox

> All the other comments in this thread are correct, but one other thing
> you can do in recent pywin32 builds is to use win32com.client.VARIANT to
> override how a value is passed - search for 'win32com.client.VARIANT' in
> pywin32.chm for basic docs.
>
> HTH,
>
> Mark
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32