Joe Bennett wrote: > Looking for a good simple remedial course on getting my python script > to talk to a Windows program. The author of the windows program has > documented the api here: > > http://www.logger32.net/help/Logger32/Using%20the%20Logger32%20External%20Interface.htm
To use this API, you have to BE a Windows application, with at least one window and a message loop. You cannot call this from a console application. > I get a response for 'hwnd' but have not been able to get any > confirmation that RegisterMessage, PostMessage and GetMessage are > working, configured properly or...what... > > Running this all in WIN7 with ActivePython 2.6.6... > > import win32api > import win32gui > > hwnd = win32gui.FindWindowEx(0, 0, 0, "Logger32") > print "hwnd= ", hwnd > > message = win32api.RegisterWindowMessage("Logger32 3") > win32api.PostMessage(hwnd,message,1,99999) That much is probably working just fine. You're registering a window message and getting a handle. But, as Roger pointed out, you need to tell it YOUR window handle to the logging application, so it can send information to you. You're passing a made-up number, which won't work. > test = win32gui.GetMessage(hwnd,0,0) > print "GetMessage: ", test This is not right. GetMessage is used to get messages that have been send to your OWN windows. In this case, you're giving it the handle of a window that belongs to another process. You can do this with a hidden window -- it doesn't have to be visible. Basically, you call RegisterClass and CreateWindow to create the window, then run a message loop with PumpWaitingMessages. In the PyWin32 distribution, go look for win32ui_devicenotify.py. That is a sample application that creates a hidden window in order to catch PnP notifications. You can yank out the most of the code and use the shell. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32