September 8th, 2005, 10:46 AM
is this possible with python?
i created a dll in c++, and this at the moment has a pointer to a function in the .exe that calls it.
is it possible to create a callback function in python to use wih a hook?
September 8th, 2005, 02:58 PM
There's a section in the tutorial dealing with passing Python functions as callbacks (near the end).
I don't know if you will have problems with your code being C++, but if anything can do it, CTypes probably can
Comments on this post
September 9th, 2005, 03:36 AM
cool, it looks promising. I don't know how familiar you are with windows, but in a windows program there is usually a windows procedure callback of type LRESULT CALLBACK, and any messages that the window receives get sent to this function. I was just wondering whether it is possible to implement this in python.
September 9th, 2005, 04:14 PM
It's as easy as that. I don't see what your problem is. Or is your problem receiving messages received from the Window? To get these messages it there are different procedures to use for each GUI library. I'm not sure what you're using.
from ctypes import *
September 9th, 2005, 08:14 PM
I have the book "Python Programming in Win32", and there are examples of writing a Win32 program in Python (with PyWin32) in it (although, it's at work at the moment).
It starts up, has a message loop getting Windows messages, so that is possible. I'm not familiar with Windows at that level, though, so I don't know if it uses a callback function, or if that's what you are asking either.