Thread: windows hooks

    #1
  1. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    43
    Rep Power
    0

    windows hooks


    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?

    cheers
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    CTypes

    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

    • Yegg` agrees
  4. #3
  5. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    43
    Rep Power
    0
    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.
  6. #4
  7. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Code:
    from ctypes import *
    cdll.dll_file_name.function_name(arguments)
    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.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    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.
    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.

IMN logo majestic logo threadwatch logo seochat tools logo