コード例 #1
0
ファイル: Actions.py プロジェクト: HedgeSpade/Auto-Clicker
    def do_action(self):
        """ Scan a specified area of the screen for an image and store the location in a variable """

        try:
            img = Image.open(self.screenshot)
        except:
            if (self.screenshot is None):
                s = "No image selected in detect image action"
            else:
                s = "Image " + self.screenshot + " Not Found."
            messagebox.showinfo("Image Not Found",
                                s,
                                parent=ToplevelObserver.top())
            return False

        width, height = img.size
        pt = imgsearch.imagesearcharea(self.screenshot,
                                       self.scanPoint.x,
                                       self.scanPoint.y,
                                       self.scanPoint.x + self.scanWidth,
                                       self.scanPoint.y + self.scanHeight,
                                       precision=(float(self.precision) /
                                                  100.0))
        point = POINT(int(pt[0] + (width / 2) + self.scanPoint.x),
                      int(pt[1] + (height / 2 + self.scanPoint.y)))
        if (pt[0] is -1):
            if (self.failOption.get() == 'Set Default Value'):
                point = self.failDefaultValue
            elif (self.failOption.get() == 'Retry'):
                timer = time.time()
                while (pt[0] is -1
                       and (time.time() - timer) < self.retryTimer):
                    pt = imgsearch.imagesearcharea(
                        self.screenshot,
                        self.scanPoint.x,
                        self.scanPoint.y,
                        self.scanPoint.x + self.scanWidth,
                        self.scanPoint.y + self.scanHeight,
                        precision=(float(self.precision) / 100.0))
                if pt[0] is -1:
                    s = "Image not found after retry, stopping."
                    messagebox.showinfo("Image Not Found",
                                        s,
                                        parent=ToplevelObserver.top())
                    return False
                point = POINT(int(pt[0] + (width / 2) + self.scanPoint.x),
                              int(pt[1] + (height / 2 + self.scanPoint.y)))
            else:
                s = "Image not found, stopping."
                messagebox.showinfo("Image Not Found",
                                    s,
                                    parent=ToplevelObserver.top())
                return False

        s = str(point.x) + " " + str(point.y)
        VariableList.set(self.storeVariable.get(), point)
        return True
コード例 #2
0
ファイル: Actions.py プロジェクト: HedgeSpade/Auto-Clicker
 def __init__(self):
     super(DetectImage, self).__init__('Detect Image')
     self.scanPoint = POINT(0, 0)
     self.scanWidth = 0
     self.scanHeight = 0
     self.retryTimer = 0
     self.precision = 0
     self.failDefaultValue = POINT(0, 0)
     self.screenshot = None
     self.storeVariable = StringVar()
     self.storeVariable.set('None')
     self.failOption = StringVar()
     self.failOption.set('Stop Program')
コード例 #3
0
ファイル: Actions.py プロジェクト: HedgeSpade/Auto-Clicker
    def load(self, data):
        """ Load the data """

        self.delay = data['delay']
        self.repeat = data['repeat']
        self.scanPoint = POINT(data['scan point x'], data['scan point y'])
        self.scanWidth = data['scan width']
        self.scanHeight = data['scan height']
        self.failDefaultValue = POINT(data['fail default x'],
                                      data['fail default y'])
        self.screenshot = data['screenshot']
        self.storeVariable.set(data['store variable'])
        self.failOption.set(data['fail option'])
        self.precision = data['precision']
        self.retryTimer = data['retry timer']
        self.dependentVars = [data['store variable']]
コード例 #4
0
ファイル: Actions.py プロジェクト: HedgeSpade/Auto-Clicker
    def get_point(self):
        """ Get the point location of the click with the added randomness """

        x = 0
        y = 0
        if (self.clickOption.get() == 'Point'):
            x = int(self.mousePos.x)
            y = int(self.mousePos.y)
        else:
            pt = VariableList.get(self.variables.get()).get()
            x = pt.x
            y = pt.y

        rand = random.randint(0, self.randomness)
        xvec = random.uniform(0, 1)
        yvec = 1.0 - xvec

        randx = xvec * rand
        randy = yvec * rand

        if random.randint(0, 1):
            randx = randx * -1

        if random.randint(0, 1):
            randy = randy * -1

        x = int(x + randx)
        y = int(y + randy)
        return POINT(x, y)
コード例 #5
0
ファイル: Actions.py プロジェクト: HedgeSpade/Auto-Clicker
 def __init__(self, actionType, label):
     super(ClickMenu, self).__init__(actionType)
     self.mousePos = POINT(0, 0)
     self.label = label
     self.clickOption = StringVar()
     self.clickOption.set('Point')
     self.variables = StringVar()
     self.variables.set('None')
     self.randomness = 0
コード例 #6
0
ファイル: Actions.py プロジェクト: HedgeSpade/Auto-Clicker
    def load(self, data):
        """ Load the data """

        self.delay = data['delay']
        self.repeat = data['repeat']
        self.mousePos = POINT(data['mouse position x'],
                              data['mouse position y'])
        self.clickOption.set(data['click option'])
        self.variables.set(data['variable'])
        self.randomness = data['randomness']
コード例 #7
0
ファイル: Actions.py プロジェクト: HedgeSpade/Auto-Clicker
    def save(self):
        """ Get data from the entries and save the values """

        scan = self.scanPointFrame.get()
        self.scanPoint = POINT(scan[0], scan[1])
        self.scanWidth = scan[2]
        self.scanHeight = scan[3]

        self.dependentVars = [self.storeVariable.get()]
        self.precision = self.precisonScale.get()

        if (self.failOption.get() == 'Set Default Value'):
            self.failDefaultValue = self.mouseOpFrame.get()

        elif (self.failOption.get() == 'Retry'):
            self.retryTimer = self.retryTimerEntry.get()
コード例 #8
0
 def __init__(self, name):
     super(PointVariable, self).__init__("Point", name)
     self.value = POINT(0, 0)
コード例 #9
0
    def load(self, data):
        """ Load the data """

        self.value = POINT(data['value x'], data['value y'])