import win32gui<br />from re import match<br />def draw_line():<br /> print 'x1,y1,x2,y2?'<br /> s=raw_input()<br /> if match('/d+,/d+,/d+,/d+',s):<br /> x1,y1,x2,y2=s.split(',')<br /> x1=int(x1)<br /> y1=int(y1)<br /> x2=int(x2)<br /> y2=int(y2)<br /> hwnd=win32gui.WindowFromPoint((x1,y1))<br /> hdc=win32gui.GetDC(hwnd)<br /> x1c,y1c=win32gui.ScreenToClient(hwnd,(x1,y1))<br /> x2c,y2c=win32gui.ScreenToClient(hwnd,(x2,y2))<br /> win32gui.MoveToEx(hdc,x1c,y1c)<br /> win32gui.LineTo(hdc,x2c,y2c)<br /> win32gui.ReleaseDC(hwnd,hdc)<br /> main()<br />def draw_point():<br /> print 'x,y,color?'<br /> s=raw_input()<br /> if match('/d+,/d+,/d+',s):<br /> x,y,color=s.split(',')<br /> x=int(x)<br /> y=int(y)<br /> color=int(color)<br /> hwnd=win32gui.WindowFromPoint((x,y))<br /> hdc=win32gui.GetDC(hwnd)<br /> x1,y1=win32gui.ScreenToClient(hwnd,(x,y))<br /> win32gui.SetPixel(hdc,x1,y1,color)<br /> win32gui.ReleaseDC(hwnd,hdc)<br /> main()<br />def get_pixel_col():<br /> print 'x,y?'<br /> s=raw_input()<br /> if match('/d+,/d+',s):<br /> x,y=s.split(',')<br /> x=int(x)<br /> y=int(y)<br /> hwnd=win32gui.WindowFromPoint((x,y))<br /> hdc=win32gui.GetDC(hwnd)<br /> x1,y1=win32gui.ScreenToClient(hwnd,(x,y))<br /> color=win32gui.GetPixel(hdc,x1,y1)<br /> win32gui.ReleaseDC(hwnd,hdc)<br /> print color<br /> main()<br />def get_current_pos_info():<br /> x,y=win32gui.GetCursorPos()<br /> hwnd=win32gui.WindowFromPoint((x,y))<br /> hdc=win32gui.GetDC(hwnd)<br /> x1,y1=win32gui.ScreenToClient(hwnd,(x,y))<br /> print x,y,win32gui.GetPixel(hdc,x1,y1)<br /> win32gui.ReleaseDC(hwnd,hdc)<br /> main()<br />def main():<br /> print ('''l. draw line<br />p. draw point<br />g. get pixel color<br />c. get current mouse position's info''')<br /> s=raw_input()<br /> if s.lower()=='l':<br /> draw_line()<br /> if s.lower()=='p':<br /> draw_point()<br /> if s.lower()=='g':<br /> get_pixel_col()<br /> if s.lower()=='c':<br /> get_current_pos_info()<br />main()