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 GraphicalContext_handle image_handle -- snap.py : " import win32api, win32con, sys win32api.SendMessage(sys.argv[2], win32con.WM_PAINT, sys.argv[3], 0) win32api.SendMessage(sys.argv[2], win32con.WM_PRINT, sys.argv[3], win32con.PRF_CHILDREN | win32con.PRF_CLIENT | win32con.PRF_OWNED) " snippet from Snapshot.java : " public static Image snapshot(Composite 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.getRuntime(); try { Process p = rt.exec(command); } catch (.) gc.dispose(); return image; } " -- http://mail.python.org/mailman/listinfo/python-list
Re: match nested parenthesis
[EMAIL PROTECTED] wrote: > hi > i wish to find an reg exp for matching nested parenthesis of varying > level like > string = > "somewords1(words(somewords2)-(some(some)words3)somestuff)somestuff" > and be able to evaluate the pair starting from the inner most(the > deepest level) , ie (some) > up till the outer most. What is a good reg exp to do this? or is simple > string manipulations enough? > thanks Evaluation using re.sub() and recursion (3 lines of code): def eval_sub(expr): r"""Evaluate subexpressions in nested paired delimiters. For example, single left-pointing angle quotation‹ single right-pointing angle quotation › >>> eval_sub('3 * 3 + 1 + 1 * 2') '21' >>> eval_sub('3 * 3 + 1 + 1 * 2') # test mismatched delimiters '13\x9b' >>> '\x9b' == '' # encoding ISO-8859-1 True >>> eval_sub('3 * 1 + 1 * 2 + 3') # test absence of outer delimiters '3 * 7' """ val, n = re.subn("([^]+)", lambda m: str(eval(m.group(1))), expr) if n == 0: return val return eval_sub(val) #end This is just a proof of concept. -- http://mail.python.org/mailman/listinfo/python-list