diff options
author | André Glüpker <git@wgmd.de> | 2016-04-05 20:44:49 +0200 |
---|---|---|
committer | André Glüpker <git@wgmd.de> | 2016-04-05 20:44:49 +0200 |
commit | 2c7cfb0b177ed5763937451641d3a23e094339e5 (patch) | |
tree | 45ab81feee34351d4768bb5a850aacf10c235ff7 /9kwpyqt.py | |
parent | 616f1cae0858ec0bbf974ae62d7e6d7ed1239f0a (diff) | |
download | 9kwpyqt-2c7cfb0b177ed5763937451641d3a23e094339e5.tar.gz 9kwpyqt-2c7cfb0b177ed5763937451641d3a23e094339e5.tar.bz2 9kwpyqt-2c7cfb0b177ed5763937451641d3a23e094339e5.zip |
Remove pseudo mouse support again
Diffstat (limited to '9kwpyqt.py')
-rwxr-xr-x | 9kwpyqt.py | 84 |
1 files changed, 0 insertions, 84 deletions
@@ -14,38 +14,10 @@ API_URL = "http://www.9kw.eu/index.cgi" API_KEY = "" soundfile = "notify.wav" -class PixelInfo(): - pixelA = 0 - pixelR = 0 - pixelG = 0 - pixelB = 0 - - def __init__(self, argb): - self.pixelB = argb & 0xff - argb = argb >> 8 - self.pixelG = argb & 0xff - argb = argb >> 8 - self.pixelR = argb & 0xff - argb = argb >> 8 - self.pixelA = argb & 0xff - - def isLower(self, r, g, b): - return (self.pixelR < r and self.pixelG < g and self.pixelB < b) - - def isHigher(self, r, g, b): - return (self.pixelR > r and self.pixelG > g and self.pixelB > b) - - def isExactly(self, r, g, b): - return (self.pixelR == r and self.pixelG == g and self.pixelB == b) - - - class ExtendedQLabel(QLabel): clicked = pyqtSignal(int, str) image = False # QPixmap() imageR = False # QPixmap() resized - imageB = False # QImage() - captchaType = False # int / detected captcha type def __init(self, parent): QLabel.__init(self, parent) @@ -54,15 +26,11 @@ class ExtendedQLabel(QLabel): self.image = image self.imageR = self.image.scaled(self.size(), Qt.KeepAspectRatio) - self.imageB = False - self.captchaType = False self.setPixmap(self.imageR) def removeImage(self): self.image = False self.imageR = False - self.imageB = False - self.captchaType = False self.setPixmap(QPixmap()) def resizeEvent(self, evt=None): @@ -72,58 +40,6 @@ class ExtendedQLabel(QLabel): Qt.KeepAspectRatio) self.setPixmap(self.imageR) - def mouseReleaseEvent(self, ev): - if not self.image: - return - if not self.imageB: - self.imageB = self.image.toImage() - - # get size of pixmap - imgx = self.pixmap().size().width() - imgy = self.pixmap().size().height() - - # get cursor position relative to pixmap ((0,0) = topleft) - x = ev.pos().x() - self.size().width() / 2 + imgx/2 - y = ev.pos().y() - self.size().height() / 2 + imgy/2 - - if not self.captchaType: - # Which type of captcha is this image? - if PixelInfo(self.imageB.pixel(90, 45)).isExactly(0,0,0) and \ - PixelInfo(self.imageB.pixel( 5, 30)).isHigher(220,220,220) and \ - PixelInfo(self.imageB.pixel(40, 5)).isHigher(220,220,220) and \ - (PixelInfo(self.imageB.pixel(58, 30)).isHigher(220,220,220) or \ - PixelInfo(self.imageB.pixel(71, 30)).isHigher(220,220,220)) and \ - (PixelInfo(self.imageB.pixel(40, 59)).isHigher(220,220,220) or \ - PixelInfo(self.imageB.pixel(40, 60)).isHigher(220,220,220)): - self.captchaType = 1 - elif PixelInfo(self.imageB.pixel( 16, 47)).isLower(20,20,20) and \ - PixelInfo(self.imageB.pixel(144, 47)).isLower(20,20,20) and \ - PixelInfo(self.imageB.pixel(269, 47)).isLower(20,20,20) and \ - PixelInfo(self.imageB.pixel( 16, 172)).isLower(20,20,20) and \ - PixelInfo(self.imageB.pixel(144, 172)).isLower(20,20,20) and \ - PixelInfo(self.imageB.pixel(269, 172)).isLower(20,20,20) and \ - PixelInfo(self.imageB.pixel( 16, 298)).isLower(20,20,20) and \ - PixelInfo(self.imageB.pixel(144, 298)).isLower(20,20,20) and \ - PixelInfo(self.imageB.pixel(269, 298)).isLower(20,20,20): - self.captchaType = 2 - else: - self.captchaType = -1 - - if self.captchaType == 1: - # check if on pixmap (upper 17.5% = infopanel) - if x > imgx or y > imgy or x < 0 or y < 0.175*imgy: - return - xpiece = x // (imgx / 3) + 1 - ypiece = (y-0.175*imgy) // (imgy*0.825 / 3) - self.clicked.emit(3*ypiece+xpiece, ",") - elif self.captchaType == 2: - # check if on pixmap (upper 7% = infopanel) - if x > imgx or y > imgy or x < 0 or y < 0.0735*imgy: - return - xpiece = x // (imgx / 3) + 1 - ypiece = (y-0.0735*imgy) // (imgy*0.9265 / 3) - self.clicked.emit(3*(2-ypiece)+xpiece, "") - class CaptchaGUI(QWidget): |