From 38d90a826bb9dbd1aadf01b0925bd0f7c2016e9e Mon Sep 17 00:00:00 2001 From: clem-ant Date: Fri, 5 Mar 2021 13:31:24 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Remplissage=20automatique=20des=20fichiers?= =?UTF-8?q?=20"coordinates"=20en=20fonction=20des=20applications=20(s?= =?UTF-8?q?=C3=A9lectionn=C3=A9)=20+=20ajout=20d'un=20mode=20manuel=20qui?= =?UTF-8?q?=20permet=20de=20rentrer=20les=20coordon=C3=A9es=20=C3=A0=20la?= =?UTF-8?q?=20main=20comme=20avant.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++--- drawbot.py | 3 +-- utils.py | 1 - 3 files changed, 66 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index d259460..4df7b3d 100644 --- a/app.py +++ b/app.py @@ -6,7 +6,7 @@ # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. - +import os from PyQt5 import QtCore, QtGui, QtWidgets from pynput.keyboard import Key, Listener @@ -56,6 +56,7 @@ def setupUi(self, MainWindow): self.appBox.addItem("") self.appBox.addItem("") self.appBox.addItem("") + self.appBox.addItem("") self.verticalLayout.addWidget(self.appBox) spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem2) @@ -364,6 +365,7 @@ def retranslateUi(self, MainWindow): self.appBox.setItemText(0, _translate("MainWindow", "Gartic Phone")) self.appBox.setItemText(1, _translate("MainWindow", "Skribbl")) self.appBox.setItemText(2, _translate("MainWindow", "Paint")) + self.appBox.setItemText(3, _translate("MainWindow", "Autre")) self.speedLabel.setText(_translate("MainWindow", "Vitesse")) self.skippedPixelsLabel.setText(_translate("MainWindow", "Pixels ignorés")) self.label_4.setText(_translate("MainWindow", "Moins on en ignore, plus c\'est précis (mais lent)")) @@ -412,13 +414,73 @@ def setBoundsWorker(self): self.height = abs(bounds[0][1] - bounds[1][1]) self.startPosition = (bounds[0][0], bounds[0][1]) self.widthLabel.setText(str(self.width) + ' x ' + str(self.height) + ' px') - + + def displayMouseCoordinates(self): t = threading.Thread(target=self.displayMouseCoordinatesWorker) t.start() def displayMouseCoordinatesWorker(self): - self.MouseCoordinateLabel.setText(str(utils.getNextMouseClickPositionCoordinates())) + initCoordinate = utils.getNextMouseClickPositionCoordinates() + self.MouseCoordinateLabel.setText(str(initCoordinate)) + if(self.app == 0): + self.registerColorPosInGarticFolder(initCoordinate) + elif(self.app == 1): + self.registerColorPosInFolderSkribbl(initCoordinate) + elif(self.app == 2): + self.registerColorPosINFolderPaint(initCoordinate) + + + def initFichierCoordinate(self, coordinate, app): + coordinatesFile = os.path.dirname(os.path.abspath(__file__)) + "\\colorPalettes\\" + app + "Coordinates.txt" + os.remove(coordinatesFile) + for coo in coordinate: + open(coordinatesFile, 'a').write(coo) + + def registerColorPosInGarticFolder(self, firstCoordinates): + x = firstCoordinates[0] + y = firstCoordinates[1] + tmpX = x + coordinate = [] + k = 0 + for line in range(6): + for raw in range(3): + coordinate.append("(" + str(x) +"," +str(y)+") ") + k += 1 + x += 45 #Decallage de 45 px entre chaques couleurs + x = tmpX + y += 50 #Decallga de 50 px entre chaques couleurs + self.initFichierCoordinate(coordinate, "gartic") + + def registerColorPosInFolderSkribbl(self, firstCoordinates): + x = firstCoordinates[0] + y = firstCoordinates[1] + tmpX = x + coordinate = [] + k = 0 + for line in range(2): + for raw in range(11): + coordinate.append("(" + str(x) + "," + str(y)+") ") + k += 1 + x += 26 + x = tmpX + y += 25 + self.initFichierCoordinate(coordinate, "skribbl") + + def registerColorPosINFolderPaint(self, firstCoordinates): + x = firstCoordinates[0] + y = firstCoordinates[1] + tmpX = x + coordinate = [] + k = 0 + for line in range(2): + for raw in range(10): + coordinate.append("(" + str(x) +"," +str(y)+") ") + k += 1 + x += 22 #Decallage de 22px entre chaques couleurs + x = tmpX + y += 22 #Decallaga de 22px entre chaques couleurs + self.initFichierCoordinate(coordinate, "paint") def draw(self): if self.url != "" and self.width != 0: diff --git a/drawbot.py b/drawbot.py index 242a30e..aa4fea5 100644 --- a/drawbot.py +++ b/drawbot.py @@ -1,6 +1,5 @@ -from PIL import Image, ImageFilter from pynput.mouse import Controller, Button -from PIL import Image, ImageFilter, UnidentifiedImageError +from PIL import Image, ImageFilter, UnidentifiedImageError import time import sys import requests diff --git a/utils.py b/utils.py index d647c9a..7875d9a 100644 --- a/utils.py +++ b/utils.py @@ -1,5 +1,4 @@ from pynput.mouse import Controller, Button, Listener -from pynput import keyboard from queue import Queue import os From a083c009382c65444fb5326814a5fc7a26bee649 Mon Sep 17 00:00:00 2001 From: clem-ant Date: Sun, 7 Mar 2021 18:29:44 +0100 Subject: [PATCH 2/2] Changement du nom des fonctions, suppression de la variable k inutile et des commentaire --- app.py | 22 ++++++++-------------- colorPalettes/garticCoordinates.txt | 2 +- colorPalettes/paintCoordinates.txt | 2 +- colorPalettes/skribblCoordinates.txt | 2 +- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/app.py b/app.py index 4df7b3d..1efb3e8 100644 --- a/app.py +++ b/app.py @@ -442,44 +442,38 @@ def registerColorPosInGarticFolder(self, firstCoordinates): y = firstCoordinates[1] tmpX = x coordinate = [] - k = 0 for line in range(6): for raw in range(3): - coordinate.append("(" + str(x) +"," +str(y)+") ") - k += 1 - x += 45 #Decallage de 45 px entre chaques couleurs + coordinate.append("(" + str(x) + "," + str(y)+") ") + x += 45 x = tmpX - y += 50 #Decallga de 50 px entre chaques couleurs + y += 50 self.initFichierCoordinate(coordinate, "gartic") - def registerColorPosInFolderSkribbl(self, firstCoordinates): + def registerColorPosInSkribblFolder(self, firstCoordinates): x = firstCoordinates[0] y = firstCoordinates[1] tmpX = x coordinate = [] - k = 0 for line in range(2): for raw in range(11): coordinate.append("(" + str(x) + "," + str(y)+") ") - k += 1 x += 26 x = tmpX y += 25 self.initFichierCoordinate(coordinate, "skribbl") - def registerColorPosINFolderPaint(self, firstCoordinates): + def registerColorPosInPaintFolder(self, firstCoordinates): x = firstCoordinates[0] y = firstCoordinates[1] tmpX = x coordinate = [] - k = 0 for line in range(2): for raw in range(10): - coordinate.append("(" + str(x) +"," +str(y)+") ") - k += 1 - x += 22 #Decallage de 22px entre chaques couleurs + coordinate.append("(" + str(x) + "," + str(y)+") ") + x += 22 x = tmpX - y += 22 #Decallaga de 22px entre chaques couleurs + y += 22 self.initFichierCoordinate(coordinate, "paint") def draw(self): diff --git a/colorPalettes/garticCoordinates.txt b/colorPalettes/garticCoordinates.txt index 39d12ee..f55c245 100644 --- a/colorPalettes/garticCoordinates.txt +++ b/colorPalettes/garticCoordinates.txt @@ -1 +1 @@ -(412,394) (459,387) (507,392) (413,443) (457,442) (504,442) (411,495) (461,497) (506,496) (410,544) (457,543) (505,546) (412,597) (459,599) (509,601) (411,648) (459,648) (507,645) \ No newline at end of file +(2801,154) (2846,154) (2891,154) (2801,204) (2846,204) (2891,204) (2801,254) (2846,254) (2891,254) (2801,304) (2846,304) (2891,304) (2801,354) (2846,354) (2891,354) (2801,404) (2846,404) (2891,404) \ No newline at end of file diff --git a/colorPalettes/paintCoordinates.txt b/colorPalettes/paintCoordinates.txt index 19ad46f..2c10516 100644 --- a/colorPalettes/paintCoordinates.txt +++ b/colorPalettes/paintCoordinates.txt @@ -1 +1 @@ -(882,60) (901,58) (924,60) (948,61) (966,59) (995,59) (1013,57) (1034,61) (1054,60) (1077,59) (883,85) (902,81) (928,84) (945,83) (968,84) (991,84) (1014,84) (1034,84) (1056,83) (1079,85) \ No newline at end of file +(2803,155) (2825,155) (2847,155) (2869,155) (2891,155) (2913,155) (2935,155) (2957,155) (2979,155) (3001,155) (2803,177) (2825,177) (2847,177) (2869,177) (2891,177) (2913,177) (2935,177) (2957,177) (2979,177) (3001,177) \ No newline at end of file diff --git a/colorPalettes/skribblCoordinates.txt b/colorPalettes/skribblCoordinates.txt index 1d4162d..44c94b9 100644 --- a/colorPalettes/skribblCoordinates.txt +++ b/colorPalettes/skribblCoordinates.txt @@ -1 +1 @@ -(553,948) (574,947) (602,946) (629,946) (655,946) (683,948) (714,948) (735,946) (759,947) (787,948) (814,946) (552,975) (577,977) (600,973) (631,978) (651,977) (684,974) (707,974) (732,973) (761,973) (785,974) (812,976) \ No newline at end of file +(586,894) (612,894) (638,894) (664,894) (690,894) (716,894) (742,894) (768,894) (794,894) (820,894) (846,894) (586,919) (612,919) (638,919) (664,919) (690,919) (716,919) (742,919) (768,919) (794,919) (820,919) (846,919) \ No newline at end of file