Пример #1
0
    def clickrelativetopanel(self,
                             relativevalue,
                             corner='topleft',
                             click='single'):
        """
        Clicks on a relative position in a panel.

       eg: effect.controls.clickrelativetopanel(10,30)
       Will click 10 pixels to the right and 30 pixels to the bottom of the panel Effect Controls.
       Useful for UI mouse automation, even if you change the panel sizes.

        :param relativevalue: a tuple containing (x, y) coordinates of the relative value to move or click
        :param corner: which corner to start the relative move from
                       options: default is 'topleft', 'topright', 'bottomleft', 'bottomright'
        :param click: default 'single, option to 'double' click
        """

        x, y = self.abspos_from_rel(relativevalue, corner)
        mouse.move(x, y)

        if click == 'single':
            mouse.click()
        elif click == 'double':
            mouse.double_click()
        else:
            return
Пример #2
0
    def pixelsearch(self, pixel, offset=(0, 0, 0, 0), click=''):
        """
        Searches first pixel and if click = '', return its absolute (x, y) position.

        :param pixel: a tuple (R, G, B) of int values corresponding to the pixel values.
        :param offset: a tuple (left, top, right, bottom) for how much to offset the search area.
                offset crops the panel search area so you can control better where you want to find the pixel,
                in case it finds pixels before that are not intended.
        :param click: whether to 'click', 'double' click, 'move', or if default '', return the position.
        """
        p = self
        if DRAW_OUTLINES:
            p.draw_outline()

        #Lets set our haystack bounding box to be searched
        hx1, hy1 = p.rectangle().left + offset[0], p.rectangle(
        ).top + offset[1]
        hx2, hy2 = p.rectangle().right - offset[2], p.rectangle(
        ).bottom - offset[3]

        #save that haystack as a PIL RGB image and then as a numpy array
        im = getRectAsImage((hx1, hy1, hx2, hy2))
        image = np.array(im)

        #image is RGB, but cv2 uses BGR for searching, so we need to invert it
        image = image[:, :, ::-1].copy()

        #we're not doing an upper or lower boundary because we want exactly the pixel that we specified
        lower = np.array([pixel[2], pixel[1], pixel[0]])  # BGR-code
        upper = np.array([pixel[2], pixel[1], pixel[0]])  # BGR-code

        mask = cv2.inRange(image, lower, upper)
        coord = cv2.findNonZero(mask)

        try:
            #foundcoord = first pixel found, we could implement a way to get the next pixels too.
            #             we're not limited to the first one.
            foundcoord = (coord[0][0][0], coord[0][0][1])

            #get the absolute position
            absx, absy = self.abspos_from_rel(foundcoord, offset=offset)
            print(f'Pixel found at {absx}, {absy}')

            if click == '':
                return (absx, absy)
            else:
                mouse.move(absx, absy)

            if click == 'single':
                mouse.click()
            elif click == 'double':
                mouse.double_click()
            elif click == 'move':
                return

        except TypeError:
            print('Pixel not found!')
Пример #3
0
def clicker_speed_2():
    i = 0
    global cclick, mytime, stop
    while i < cclick:
        time.sleep(mytime)
        m.double_click(button='left')
        i += 1
        if i == cclick:
            quit()
        elif k.is_pressed(stop):
            quit()
Пример #4
0
 def tick(self):
     if self.enabled:
         if self.enabled:
             # click
             self.report(True)
             if not self.double_click:
                 mouse.click(button=self.button)
             else:
                 mouse.double_click(button=self.button)
             self.timer = threading.Timer(self.delay, self.tick)
             self.timer.start()
Пример #5
0
def click_loop():
    global clicking, delay, cb_marked, repeat

    while running:


            if cb_marked == False and clicking == True:

                sleep(0.05)

                while repeat != 0 and clicking == True and running == True and values["-CTIOM-"] == "Single Click":

                    click(click_but)
                    repeat = int(repeat) - 1
                    sleep(float(delay))

                    if repeat == 1:
                        clicking = False

                while repeat != 0 and clicking == True and running == True and values["-CTIOM-"] == "Double Click":
                    
                    double_click(click_but)
                    repeat = int(repeat) - 1
                    sleep(float(delay))

                    if repeat == 1:
                        clicking = False


            elif cb_marked == True and clicking == True:

                sleep(0.05)

                while clicking == True and running == True and values["-CTIOM-"] == "Single Click":

                    click(click_but)
                    sleep(float(delay))


                while clicking == True and running == True and values["-CTIOM-"] == "Double Click":
                    
                    double_click(click_but)
                    sleep(float(delay))



            if clicking == False:
                sleep(0.24)
                pass
Пример #6
0
def main():

    # while True:
    # #     time.sleep(5)
    # #     screenGrab()
    # screenGrab()
    while True:
        if kb.is_pressed('s'):
            while True:
                if kb.is_pressed('e'):
                    print("STOP----------------------------")
                    break
                print("Click.")
                # time.sleep(0.0001)
                mouse.double_click(button='left')
Пример #7
0
 def play(self):
     for action in self.actions:
         try:
             action.delay
         except AttributeError:
             action = Action(action['button'],
                             action['action'],
                             None,
                             delay=float(action['delay']))
         time.sleep(action.delay)
         if action.action == mouse.UP:
             mouse.release(action.button)
         elif action.action == mouse.DOWN:
             mouse.press(action.button)
         elif action.action == mouse.DOUBLE:
             mouse.double_click(action.button)
Пример #8
0
 def test_buttons(self):
     mouse.press()
     self.assertEqual(self.flush_events(), [(DOWN, LEFT)])
     mouse.release()
     self.assertEqual(self.flush_events(), [(UP, LEFT)])
     mouse.click()
     self.assertEqual(self.flush_events(), [(DOWN, LEFT), (UP, LEFT)])
     mouse.double_click()
     self.assertEqual(self.flush_events(), [(DOWN, LEFT), (UP, LEFT),
                                            (DOWN, LEFT), (UP, LEFT)])
     mouse.right_click()
     self.assertEqual(self.flush_events(), [(DOWN, RIGHT), (UP, RIGHT)])
     mouse.click(RIGHT)
     self.assertEqual(self.flush_events(), [(DOWN, RIGHT), (UP, RIGHT)])
     mouse.press(X2)
     self.assertEqual(self.flush_events(), [(DOWN, X2)])
Пример #9
0
    def double_click(self, where, duration):
        """Mouse double click.

        :param where: Location , image name or Pattern.
        :param duration: Speed of hovering from current location to target.
        :return: Call the double_click() method.
        """
        return double_click(where, duration, self)
Пример #10
0
def click_loop():
    global clicking, delay, cb_marked, repeat

    while running:

        try:
            if cb_marked == False and clicking == True:

                sleep(0.05)

                while int(
                        repeat) != 1 and clicking == True and running == True:

                    if values["-CTIOM-"] == "Single Click":
                        click(click_but)
                        repeat = int(repeat) - 1
                        clicking = True
                        sleep(float(delay))
                        if repeat == 1:
                            clicking = False

                    else:
                        double_click(click_but)
                        repeat = int(repeat) - 1
                        clicking = True
                        sleep(float(delay))
                        if repeat == 1:
                            clicking = False

            if clicking == False:
                sleep(0.24)
                pass

            if clicking == True:

                if values["-CTIOM-"] == "Single Click":
                    click(click_but)
                    sleep(float(delay))

                else:
                    double_click(click_but)
                    sleep(float(delay))

        except ValueError:
            clicking = False
Пример #11
0
def make_bet(color, amount):
    mouse.move(coord.bet_amount_right_x - 5, coord.bet_amount_right_y, True,
               0.1)
    time.sleep(0.1)
    mouse.drag(coord.bet_amount_right_x, coord.bet_amount_right_y,
               coord.bet_amount_left_x, coord.bet_amount_left_y, True, 0.5)
    time.sleep(0.5)
    keyboard.write(str(amount), 0.5)
    keyboard.press_and_release('enter')
    time.sleep(0.25)
    if color == "red":
        mouse.move(coord.bet_red_x, coord.bet_red_y, True, 0.2)
        mouse.double_click('left')
        time.sleep(0.5)
        mouse.move(coord.rest_x, coord.rest_y + 50, True, 1)
        time.sleep(4)
    elif color == 'black':
        mouse.move(coord.bet_black_x, coord.bet_black_y, True, 0.2)
        mouse.double_click('left')
        time.sleep(0.5)
        mouse.move(coord.rest_x, coord.rest_y + 50, True, 1)
        time.sleep(4)
Пример #12
0
    def imagesearch(self,
                    im,
                    precision=0.8,
                    offset=(0, 0, 0, 0),
                    click='',
                    moveback=True):
        """

        :param im: file path of image to search (needle)
        :param precision: precision factor for when it considers the image to be found
        :param offset: a tuple (left, top, right, bottom) for how much to offset the search area.
                offset crops the panel search area so you can control better where you want to find the pixel,
                in case it finds pixels before that are not intended.
        :param click: whether to 'click', 'double' click, 'move', or if default '', return the position.
        :param moveback: whether to move the mouse back after completion
        """

        p = self
        origx, origy = mouse.get_position()
        #Lets set our haystack bounding box to be searched
        hx1, hy1 = p.rectangle().left + offset[0], p.rectangle(
        ).top + offset[1]
        hx2, hy2 = p.rectangle().right - offset[2], p.rectangle(
        ).bottom - offset[3]

        #save it as np array
        img_rgb = np.array(getRectAsImage((hx1, hy1, hx2, hy2)))

        #cv2.matchTemplate only accepts grayscale, so transform it from BGR to grayscale
        img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)

        template = cv2.imread(im, 0)
        height, width = template.shape

        #do the search itself
        res = cv2.matchTemplate(img_gray, template, cv2.TM_CCOEFF_NORMED)
        min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)

        loc = np.where(res >= precision)
        coord = list(zip(*loc[::-1]))

        # image not found!
        if max_val < precision:
            print('Image not found')
            return [-1, -1]

        #returns first image found. could also change it to get other images found.
        foundcoord = (coord[0][0], coord[0][1])

        # get the absolute position
        x, y = self.abspos_from_rel(foundcoord, offset=offset)

        # and lets change that position to the middle of the image found, just because it looks nicer instead of
        # the topleft pixel.
        absx = int(x + width / 2)
        absy = int(y + height / 2)

        print(f'Image found at {absx}, {absy}')

        if click == '':
            return absx, absy
        if click == 'single':
            mouse.move(absx, absy)
            mouse.click()
        elif click == 'double':
            mouse.move(absx, absy)
            mouse.double_click()
        elif click == 'move':
            mouse.move(absx, absy)
        if moveback:
            mouse.move(origx, origy)
        if click == 'drag':
            mouse.drag(absx, absy, origx, origy, duration=MOUSEDELAY)
Пример #13
0
import colorama#импорт ранее установлиного пакета
from colorama import init
init()
from colorama import Fore, Back, Style

#принемаем данные пользователя

true_f = True
start_key = input("Enter start key: ")
stop_key = input("Enter stop key: ")
click_button = input("Enter click button: ")



while True:#проверяем нажатие start_key
	if key.is_pressed( start_key ):
		print( Back.GREEN )
		print("WARRING: Starting clicker to start key!")
		if true_f == False:
			break
		while True:
			sleep(0.01)#кликаем
			mouse.double_click(button = click_button.lower())

			if key.is_pressed( stop_key ):
				print( Back.RED )
				print("WARRING: Stoping program to stop key!")
				true_f = False
				break 

Пример #14
0
import mouse
from time import sleep

while True:
    if mouse.is_pressed(button='left'):
        while True:
            sleep(0.01)
            mouse.double_click(button='left')