#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    4
    Rep Power
    0

    win32 python - mouse events


    Ok, I'm trying to write a quick script that will send a mouse_event to the currently focused window.

    E.g.
    Script runs --> desktop is focused --> right click event is sent.

    I've tried
    Code:
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 700, 700, 0)
    But this doesn't seem to work.

    I'm using activestate python with its win32 extentions. I understand it makes reference to c++ documentation for the win32 api/com, but I cannot find any decent examples around.

    Can anyone help me out creating a "right clicker" script? Is there any way to target particular applications?

    Just so you know, the event seems to work, but I believe I need to target applications. I've imorted win32api and win32con and a try clause doesn't raise any exceptions.

    Yours,
    Twll
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    4
    Rep Power
    0
    Originally Posted by twll
    Ok, I'm trying to write a quick script that will send a mouse_event to the currently focused window.

    E.g.
    Script runs --> desktop is focused --> right click event is sent.

    I've tried
    Code:
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 700, 700, 0)
    But this doesn't seem to work.

    I'm using activestate python with its win32 extentions. I understand it makes reference to c++ documentation for the win32 api/com, but I cannot find any decent examples around.

    Can anyone help me out creating a "right clicker" script? Is there any way to target particular applications?

    Just so you know, the event seems to work, but I believe I need to target applications. I've imorted win32api and win32con and a try clause doesn't raise any exceptions.

    Yours,
    Twll
    EDIT:

    I managed to get it to send the mouse event to the windows desktop and various win32 apps. But it doesn't seem to send the mouse_event() to directx applications. This is ultimatly what I want to achieve.

    I think I have to use win32con.setCapture() to choose the window to send the mouse_event to, but I'm not sure how to specify the window.

    If anyone can explain how I use setCapture, or how I specify a window please let me know.

IMN logo majestic logo threadwatch logo seochat tools logo