Window capture using WM_PRINT and Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • arN

    #1

    Window capture using WM_PRINT and Python

    Hi !

    I'm a Java developper and I wish to make a capture of an offscreen
    window (on WinXP). It's not possible in Java, so I use a python script
    and WM_PRINT, but it doesn't seem to work.

    Could someone have a look at my script and give me any advise ?

    TIA

    --
    Arnaud
    my python script : python snap.py GraphicalContex t_handle image_handle
    --------------------------------------------------------------------------------------------------
    snap.py :
    "
    import win32api, win32con, sys

    win32api.SendMe ssage(sys.argv[2], win32con.WM_PAI NT, sys.argv[3], 0)
    win32api.SendMe ssage(sys.argv[2], win32con.WM_PRI NT, sys.argv[3],
    win32con.PRF_CH ILDREN | win32con.PRF_CL IENT | win32con.PRF_OW NED)
    "

    ------------------------------------------------------------------------------------------------
    snippet from Snapshot.java :
    "
    public static Image snapshot(Compos ite bean) {
    GC gc = new GC(bean);
    final Image image = new Image (null, bean.getBounds( ).width,
    bean.getBounds( ).height);
    String commmand = "python snap.py " + gc.handle + " " + image.handle;

    Runtime rt = Runtime.getRunt ime();
    try {
    Process p = rt.exec(command );
    } catch (.....)

    gc.dispose();
    return image;
    }
    "
  • Roger Upole

    #2
    Re: Window capture using WM_PRINT and Python

    Do you get any kind of traceback when you start a process that way?
    There's not much info to go on.

    Sys.argv parameters are passed as strings. You'll need to do an int() on
    them
    before you can use them as handles. Also, not all handles are portable
    between processes. Your device context handle might not be valid
    even if you make it an int.

    hth
    Roger


    "arN" <pas@demail.svp > wrote in message
    news:41ed7017$0 $23339$7a628cd7 @news.club-internet.fr...[color=blue]
    > Hi !
    >
    > I'm a Java developper and I wish to make a capture of an offscreen window
    > (on WinXP). It's not possible in Java, so I use a python script and
    > WM_PRINT, but it doesn't seem to work.
    >
    > Could someone have a look at my script and give me any advise ?
    >
    > TIA
    >
    > --
    > Arnaud
    > my python script : python snap.py GraphicalContex t_handle image_handle
    > --------------------------------------------------------------------------------------------------
    > snap.py :
    > "
    > import win32api, win32con, sys
    >
    > win32api.SendMe ssage(sys.argv[2], win32con.WM_PAI NT, sys.argv[3], 0)
    > win32api.SendMe ssage(sys.argv[2], win32con.WM_PRI NT, sys.argv[3],
    > win32con.PRF_CH ILDREN | win32con.PRF_CL IENT | win32con.PRF_OW NED)
    > "
    >
    > ------------------------------------------------------------------------------------------------
    > snippet from Snapshot.java :
    > "
    > public static Image snapshot(Compos ite bean) {
    > GC gc = new GC(bean);
    > final Image image = new Image (null, bean.getBounds( ).width,
    > bean.getBounds( ).height);
    > String commmand = "python snap.py " + gc.handle + " " + image.handle;
    >
    > Runtime rt = Runtime.getRunt ime();
    > try {
    > Process p = rt.exec(command );
    > } catch (.....)
    >
    > gc.dispose();
    > return image;
    > }
    > "[/color]




    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

    Comment

    Working...