[Twisted-Python] win 32 reactor

Gabriel Rossetti mailing_lists at evotex.ch
Mon Mar 31 10:28:09 MDT 2008


Hello,

I need to use PyHook, a win32 lib allowing global input monitoring 
(mouse, keyboard, etc). It uses the PyWin32 extentions, in particular 
win32com's PumpMessages() function. This is an event loop defined like so :

// @pymethod |pythoncom|PumpMessages|Pumps all messages for the current 
thread until a WM_QUIT message.
static PyObject *pythoncom_PumpMessages(PyObject *self, PyObject *args)
{
    MSG msg;
    int rc;
    Py_BEGIN_ALLOW_THREADS
    while ((rc=GetMessage(&msg, 0, 0, 0))==1) {
        TranslateMessage(&msg); // needed?
        DispatchMessage(&msg);
    }
    Py_END_ALLOW_THREADS
    if (rc==-1)
        return PyWin_SetAPIError("GetMessage");
    Py_INCREF(Py_None);
    return Py_None;
}

my question is ho can I make this work with twisted? Is there a way to 
use the supplied win32 reactors (there are three I think) or do I have 
to write one myself? Could someone please point me in the right direction?

Thanks,
Gabriel




More information about the Twisted-Python mailing list