PyQt4获取屏幕鼠标位置像素颜色,pyqt4获取屏幕像素,""" 鼠标移动需要


"""   鼠标移动需要把鼠标的XY值读取"""if event.buttons() & Qt.LeftButton:     pointX = event.globalX()   pointY = event.globalY()   # img is QImage type   img = QPixmap.grabWindow(           QApplication.desktop().winId()).toImage()   rgb = img.pixel(pointX, pointY)   #十进制   red10 = QtGui.qRed(rgb)   green10 =QtGui.qGreen(rgb)   blue10 = QtGui.qBlue(rgb)   color10="("+str(red10)+","+str(green10)+","+str(blue10)+")"   #十六进制   #print str(hex(red10))   red16=str(hex(red10))[2:]   green16=str(hex(green10))[2]   blue16=str(hex(blue10))[2:]   color16=red16+green16+blue16   #print color16   print "(%s,%s) = %s (%s,%s,%s)" % (pointX, pointY, color16,red10, green10, blue10)   self.label.setText("(%s,%s) = %s (%s,%s,%s)" % (pointX, pointY, color16,red10, green10, blue10))#该片段来自于http://byrx.net

评论关闭