Beispiel #1
3
def temp():
    pyautogui.alert('This displays some text with an OK button.')
    pyautogui.position()  # current mouse x and y
    pyautogui.onScreen(x, y)  # True if x & y are within the screen.
    pyautogui.PAUSE = 2.5   # Pause 2.5 s
    pyautogui.dragTo(x, y, duration=num_seconds)  # drag mouse to XY
    pyautogui.dragRel(xOffset, yOffset, duration=num_seconds)  # drag mouse relative to its current position
    pyautogui.click(x=moveToX, y=moveToY, clicks=num_of_clicks, interval=secs_between_clicks, button='left') # The button keyword argument can be 'left', 'middle', or 'right'.
    pyautogui.scroll(amount_to_scroll, x=moveToX, y=moveToY)
    pyautogui.mouseDown(x=moveToX, y=moveToY, button='left')
    pyautogui.mouseUp(x=moveToX, y=moveToY, button='left')
    pyautogui.typewrite('Hello world!\n', interval=secs_between_keys)  # useful for entering text, newline is Enter
    pyautogui.typewrite(['a', 'b', 'c', 'left', 'backspace', 'enter', 'f1'], interval=secs_between_keys)
    pyautogui.hotkey('ctrl', 'c')  # ctrl-c to copy
    pyautogui.hotkey('ctrl', 'v')  # ctrl-v to paste
    pyautogui.alert('This displays some text with an OK button.')
    pyautogui.confirm('This displays text and has an OK and Cancel button.')
    pyautogui.prompt('This lets the user type in a string and press OK.')
    pyautogui.screenshot('foo.png')  # returns a Pillow/PIL Image object, and saves it to a file
    pyautogui.locateOnScreen('looksLikeThis.png')
    pyautogui.locateCenterOnScreen('looksLikeThis.png')  # returns center x and y
 def call(self):
     v = self.LOCATIONS['call']
     gui.moveTo(v[0][0] + self.x + 50, v[0][1] + self.y + 10, duration = .3) 
     time.sleep(.3)
     gui.mouseDown()
     time.sleep(.2)
     gui.mouseUp()
Beispiel #3
0
 def debuff_enemy(self, duration):
     """Break enemy defence, hits many enemies ahead of you"""
     duration = random.uniform(duration - .25, duration + 1.5)
     pyautogui.mouseDown(self.E)
     time.sleep(duration)
     pyautogui.mouseUp()
     self.heal()
Beispiel #4
0
 def balls_to_the_wall(self, duration):
     """Pushes enemy to end of field with shield.
        Then launches every powerful attack that's not 
        currently cooling down. Loots corner afterwards."""
     logging.info('Starting balls_to_the_wall.')
     tactic_timer = time.time()
     level = 1
     while (time.time() - tactic_timer) < duration:
         self.buffs()
         self.heal()
         #Set them up
         self.shield_charge(random.randrange(10, 18))
         self.gas_explosion(random.randrange(6, 10))
         self.nether_shield()
         self.run('opposite', random.uniform(.5, 1.25))
         self.turn()
         #Knock them down
         attack_timer = time.time()
         self.debuff_enemy(random.uniform(.5, 3.5))
         while (time.time() - attack_timer) < random.randrange(8, 12):
             pyautogui.mouseDown(self.Q)
             self.heal()
             self.nether_shield()
             self.scooby_bats()
         pyautogui.mouseUp()
         #Pick up remains and reposition
         self.loot_corner(self.direction)
         self.run('forward', random.uniform(.5, 1.25))
         self.nether_shield()
         self.level_navigation()
     logging.info('Ending balls_to_the_wall.')
Beispiel #5
0
 def down_a_level(self):
     """Holds down and presses alt to jump down"""
     time.sleep(1)
     pyautogui.mouseDown(self.DOWN)
     time.sleep(2.5)
     pyautogui.click(self.ALT)
     pyautogui.mouseUp()
Beispiel #6
0
def moveClick(x,y, button=0):#moves to random X,Y of found match of template
    moveTo(x,y)
    RandTime.randTime(0,0,0,0,0,2)
    if button != 0:
        pyautogui.mouseDown(button='left')
        RandTime.randTime(0,1,0,0,2,9)#time between click
        pyautogui.mouseUp(button='left')
Beispiel #7
0
    def send_click_to_square(self, square_id):
        if not self.board_started:
            return

        if self.flipped.get():
            square_to_click = [x for x in self.board_squares if x['reversed_id'] == square_id]
        else:
            square_to_click = [x for x in self.board_squares if x['square_id'] == square_id]

        if square_to_click:
            square_to_click = square_to_click[0]
        else:
            self.msg.set('Unable to find square to click!')
            return

        x, y = square_to_click.get('center')

        try:
            self.msg.set('Trying to click on "{}"'.format(square_to_click['name']))
            time.sleep(0.2)
            pyautogui.mouseDown(x, y)
            time.sleep(0.2)
            pyautogui.mouseUp(x, y)
        except Exception as e:
            self.msg.set(str(e))
Beispiel #8
0
 def scooby_bats(self):
     """Sends small horde of bats to obtain enemy agro"""
     cool_down = 8
     if (time.time() - self.scooby_bat_timer) > cool_down:
         pyautogui.mouseDown(self.D)
         time.sleep(0.35)
         pyautogui.mouseUp()
         cooldown_timer = time.time()
Beispiel #9
0
 def up_a_level(self):
     """Presses ALT UP UP for a super vertical jump"""
     time.sleep(0.5)
     pyautogui.click(self.ALT)
     pyautogui.doubleClick(self.UP)
     pyautogui.mouseDown(self.UP) 
     time.sleep(2.5)
     pyautogui.mouseUp()
Beispiel #10
0
def OnKeyUpEvent(event):
#only watching up events for debounced buttons	
	if event.Key in debouncedKeyList:
		pyautogui.mouseUp()
		keyPairs[event.Key] = False
		
# return True to pass the event to other handlers
	return (event.Key not in keyList)
Beispiel #11
0
 def loot_ahead(self):
     """Walk short distance ahead looting on the way"""
     pyautogui.mouseDown(self.Z)
     time.sleep(1)
     for x in range(3):
         pyautogui.mouseDown(self.Z)
         time.sleep(random.uniform(0.5, 1.3))
         self.run('forward', random.uniform(0.1, 0.5))
     pyautogui.mouseUp()
Beispiel #12
0
 def gas_explosion(self, duration):
     """Gas storm damages enemies life steal with exploding AOE finale"""
     cool_down = 12
     if (time.time() - self.gas_explosion_timer) > cool_down:
         duration = random.uniform(duration - 1.5, duration + 1.5)
         pyautogui.mouseDown(self.S)
         time.sleep(duration)
         pyautogui.mouseUp()
         self.heal()
Beispiel #13
0
 def nether_shield(self):
     """Sends homing shields out to attack enemies"""
     cool_down = 6
     if (time.time() - self.nethershield_timer) > cool_down:
         self.nethershield_timer = time.time()
         pyautogui.mouseDown(self.A)
         time.sleep(0.55)
         pyautogui.mouseUp()
         self.heal()
Beispiel #14
0
 def click(self, key, duration):
     """
     Given a key to click and a duration to click it for, this method will
     click the key for the given duration.
     """
     self._moveTo(key)
     pyautogui.mouseDown()
     time.sleep(duration)
     pyautogui.mouseUp()
     time.sleep(0.25)
 def fold(self):
     if self.user_position() is 'BB' and self.bets().max() == self.blinds:
         v = self.LOCATIONS['call']      
     else:  
         v = self.LOCATIONS['fold']
         
     gui.moveTo(v[0][0] + self.x + 50, v[0][1] + self.y + 10, duration = .3) 
     time.sleep(.3)
     gui.mouseDown()
     time.sleep(.2)
     gui.mouseUp()
Beispiel #16
0
def reset_ui_field_on_android():
    # select all texts in the UI field
    pyautogui.mouseDown();
    time.sleep(2)
    pyautogui.mouseUp()
    # reset the UI field
    pyautogui.press("backspace")
    pyautogui.press("del")
    pyautogui.press("delete")
    # unfocus the UI field
    pyautogui.moveRel(-150, 0, duration)
    pyautogui.click()
    time.sleep(1)
Beispiel #17
0
 def loot(self):
     """Auto loots the area"""
     loot_directions = [self.LEFT, self.RIGHT]
     for direction in loot_directions:
         for x in range(5):
             pyautogui.mouseDown(direction)
             time.sleep(0.1)
             pyautogui.mouseUp()
             pyautogui.mouseDown(self.Z)
             time.sleep(1)
             pyautogui.mouseUp()
         if direction is self.LEFT:
             self.run('right', 1)
         elif direction is self.RIGHT:
             self.run('left', 1)
Beispiel #18
0
 def across_platform(self):
     """Fly across to adjacent platform"""
     time.sleep(2)
     self.run('opposite', 1.2)
     self.turn()
     #Keep direction pressed down as we click alt
     if self.direction is 'left':
         pyautogui.mouseDown(self.LEFT)
     elif self.direction is 'right':
         pyautogui.mouseDown(self.RIGHT)
     time.sleep(1)
     pyautogui.click(self.ALT)
     pyautogui.mouseDown(self.ALT)
     time.sleep(1.5)
     pyautogui.mouseUp()
Beispiel #19
0
 def run(self, direction, duration):
     """Character runs for duration heading toward direction"""
     if direction is 'right':
         pyautogui.mouseDown(self.RIGHT)
         self.direction = 'right'
     elif direction is 'left':
         pyautogui.mouseDown(self.LEFT)
         self.direction = 'left'
     elif direction is 'opposite':
         if self.direction is 'left':
             self.run('right', duration)
         elif self.direction is 'right':
             self.run('left', duration)
     elif direction is 'forward':
         self.run(self.direction, duration)
     time.sleep(duration)
     pyautogui.mouseUp()
Beispiel #20
0
def comm(inp, ser):
    print inp

    if "RELOAD" in inp:
        pyautogui.press('R')
        inp =  ser.readline()
        while "RELOAD" in inp:
           inp =  ser.readline()
           pyautogui.press('R')
        print "R"

    elif "LR" in inp:
        pyautogui.mouseDown(button='left')
        pyautogui.mouseDown(button='right')
        inp =  ser.readline()
        while "LR" in inp:
            inp =  ser.readline()

        pyautogui.mouseUp(button='left')
        pyautogui.mouseUp(button='right')
        
    elif "LEFT" in inp:
        pyautogui.mouseDown(button='left')

        inp =  ser.readline()
        while "LEFT" in inp:
            inp =  ser.readline()
        pyautogui.mouseUp(button='left')

    elif "RIGHT" in inp:
        pyautogui.mouseDown(button='right')

        inp =  ser.readline()
        while "RIGHT" in inp:
            inp =  ser.readline()

        pyautogui.mouseUp(button='right')

    elif "TOGGLE" in inp:
           inp =  ser.readline()
           #close_action()
           Toggle()
           
    elif "CLOSE" in inp:
           inp =  ser.readline()
           close_action()
           #Toggle()
            
    else:
        inp =  ser.readline()
    
    return inp
Beispiel #21
0
def execute(order):
    args = order.split(',');
    mess = args[0];
    if mess.startswith('key'):
        key = args[1]
        if mess.endswith('Down'):
            pyautogui.keyDown(key);
        else:
            pyautogui.keyUp(key);
    elif mess.startswith('mouse'):
        x = int(args[1])
        y = int(args[2])
        if mess.endswith('Down'):
            pyautogui.mouseDown(x, y);
        elif mess.endswith('Up'):
            pyautogui.mouseUp(x, y);
        else:
            pyautogui.moveTo(x, y);
    else:
        print("Error:mess=", args);
Beispiel #22
0
def scrollMonsterBarRightToLeft(numOfTimes,allConfigs,direction = 'left'):
    for i in xrange(0,numOfTimes):
        screenshot = functions_screenshot.screenshotOpencv(allConfigs)
        monster_select = checkPicture(screenshot,'monster_select.png', allConfigs['tolerance'] ,allConfigs['directories'],allConfigs, multiple = True)

        most_left_monster = find_min_max(monster_select,'x','min')
        most_right_monster = find_min_max(monster_select,'x','max')

        if direction == 'left':
            pyautogui.moveTo(most_right_monster['points'][0]['top_left'][0],most_right_monster['points'][0]['bottom_right'][1])
            pyautogui.mouseDown()
            pyautogui.moveTo(most_left_monster['points'][0]['top_left'][0]+int(allConfigs['error_correction']['monster_scroll']),most_left_monster['points'][0]['bottom_right'][1],allConfigs['wait_times']['scroll_speed'])
            pyautogui.mouseUp()
            functions_general.randomWait( allConfigs['wait_times']['between_scrolls'],0 )
        else:
            pyautogui.moveTo(most_left_monster['points'][0]['top_left'][0],most_left_monster['points'][0]['bottom_right'][1])
            pyautogui.mouseDown()
            pyautogui.moveTo(most_right_monster['points'][0]['top_left'][0]+int(allConfigs['error_correction']['monster_scroll']),most_right_monster['points'][0]['bottom_right'][1],allConfigs['wait_times']['scroll_speed'])
            pyautogui.mouseUp()
            functions_general.randomWait( allConfigs['wait_times']['between_scrolls'],0 )
    return    
def copyVerCode():
	pyautogui.click(1275,730)
	time.sleep(1)
	pyautogui.click(820,370)
	time.sleep(1)
	pyautogui.click(500,150)
	time.sleep(1)
	pyautogui.mouseDown(500, 150, button='left')
	time.sleep(1.5)
	pyautogui.mouseUp(500, 150, button='left')
	time.sleep(1)
	pyautogui.click(500,390)
	time.sleep(1)
	pyautogui.click(500,680)
	time.sleep(1)
	pyautogui.hotkey('ctrl', 'v')
	time.sleep(1)
	pyautogui.doubleClick(500,680)
	time.sleep(1)
	pyautogui.click(520,710)
	pyautogui.dragTo(540, 715, duration=0.5)
Beispiel #24
0
def ioThread():
    OOO="       "
    printer.p(OOO+"ioThread === checking in...")
    global req
    global alive
    l=0
    r=0
    while alive:
        if myID==IDcheck:
            #if time.time()-start>20: alive=False #autorestart
            try:
                response=requests.post('http://'+ip+'/zerog/getgui.php', params={"mode":"r"})
                j=response.json()
          
                req=int(j['req'])
                if req==-1: alive=False
                if req!=1: continue
                o_l=l
                o_r=r
                x=int(j['x'])
                y=int(j['y'])
                l=int(j['l'])
                k=int(j['k'])
                r=int(j['r'])
                
                printer.p(OOO+"ioThread === xyzlr:"+str(x)+","+str(y)+","+str(l)+","+str(r)+",  k:"+str(k)+",  req:"+str(req))
                
                pyautogui.moveTo(x,y,0)
                if l==1 and o_l!=1: pyautogui.mouseDown();
                elif l==0 and o_l!=0: pyautogui.mouseUp();
                
                if r==1 and o_r!=1: pyautogui.mouseDown(button='right');
                elif r==0 and o_r!=0: pyautogui.mouseUp(button='right');
                
                time.sleep(1)
            except:
                pass
        else: time.sleep(5)
        
    printer.p(OOO+"ioThread === ...checking out")
Beispiel #25
0
 def do_it(self):
     while True:
         try:
             try:
                 body = self.INPUT_Q.get_nowait()
             except:
                 body = None
             if body != None:
                 head = body[:4]
                 body = body[4:]
                 if head == 'MOUS' and self.mous_press == False:
                     mxy = body.split('|')
                     self.mous.move(int(mxy[0]),int(mxy[1]))
                     #pyautogui.moveTo(int(mxy[0]),int(mxy[1]))
                 elif head == 'MCLK' or self.mous_press == True:
                     mxy = body.split('|')
                     if mxy[2] == 'DOWN':
                         if mxy[3] == '1':
                             pyautogui.mouseDown(int(mxy[0]),int(mxy[1]),button='left')
                         elif mxy[3] == '3':
                             pyautogui.mouseDown(int(mxy[0]),int(mxy[1]),button='right')
                         else:
                             pyautogui.scroll(5,x=int(mxy[0]),y=int(mxy[1]))
                     else:
                         self.mous_press = False
                         if mxy[3] == '1':
                             pyautogui.mouseUp(int(mxy[0]),int(mxy[1]),button='left')
                         elif mxy[3] == '3':
                             pyautogui.mouseUp(int(mxy[0]),int(mxy[1]),button='right')
                         else:
                             pyautogui.scroll(-5,x=int(mxy[0]),y=int(mxy[1]))
                 elif head == "KCLK":
                     key_ev = body.split('|')
                     if key_ev[0] == 'DOWN':
                         pyautogui.keyDown(key_ev[1])
                     elif key_ev[0] == "UP":
                         pyautogui.keyUp(key_ev[1])
         except Exception as e:
             print "INPUT CONTROL ERROR",e
Beispiel #26
0
 def spam_attack(self, duration):
     """All action non-stop attack rampage super killer mode"""
     logging.info('Starting spam_attack.')
     tactic_timer = time.time()
     turn_timer = time.time()
     level = 0
     while (time.time() - tactic_timer) < duration:
         self.heal()
         self.buffs()
         self.nether_shield()
         self.shield_charge(random.randrange(9, 18))
         self.nether_shield()
         self.gas_explosion(random.randrange(3, 9))
         self.nether_shield()
         self.debuff_enemy(random.randrange(7, 16))
         self.heal()
         self.scooby_bats()
         spam_timer = time.time()
         while (time.time() - spam_timer) < random.randrange(3, 8):
             pyautogui.mouseDown(self.Q)
         pyautogui.mouseUp()
         self.loot_ahead()
         self.level_navigation()
     logging.info('Ending spam_attack.')
Beispiel #27
0
def main():
    #time.sleep(3.5)
    demonBot = DemonAvenger()
    while True:
        for x in range(4):
            demonBot.buffs()
            demonBot.heal()
            demonBot.random_ability(random.uniform(6, 25))
            #Loot 
            for x in range(10):
                if demonBot.direction is 'left':
                    pyautogui.mouseDown(demonBot.LEFT)
                elif demonBot.direction is 'right':
                    pyautogui.mouseDown(demonBot.RIGHT)
                time.sleep(0.1)
                pyautogui.click(demonBot.Z)
                pyautogui.mouseUp()
            #demonBot.run('forward', random.uniform(0.3, 1.75))
            #pyautogui.mouseDown(demonBot.Z)
            #time.sleep(random.uniform(1.0, 2.5))        #demonBot.random_tactics()
            #pyautogui.mouseUp()
        demonBot.level_navigation()
        demonBot.turn()
        logging.info('DemonAvenger main loop cycling')
Beispiel #28
0
 def loot_corner(self, direction):
     """Auto loots corner of area which you are facing"""
     for x in range(2):
         pyautogui.mouseDown(self.Z)
         time.sleep(0.5)
         pyautogui.mouseUp()
         if direction is 'left':
             pyautogui.mouseDown(self.LEFT)
         elif direction is 'right':
             pyautogui.mouseDown(self.RIGHT)
         time.sleep(0.2)
         pyautogui.mouseUp()
         pyautogui.mouseDown(self.Z)
         time.sleep(2.5)
         pyautogui.mouseUp()
         self.heal()
     self.turn()
     pyautogui.mouseDown(self.Z)
     time.sleep(2)
     pyautogui.mouseUp()
Beispiel #29
0
    print(u"移動して")
    pyautogui.moveTo(110, 100, duration=1)
    print(u"移動して")
    pyautogui.moveTo(120, 300, duration=1)
    print(u"移動して")
    pyautogui.moveTo(130, 100, duration=1)
    print(u"移動して")
    pyautogui.moveTo(140, 300, duration=1)
    print(u"移動して")
    pyautogui.moveTo(150, 100, duration=1)
    print(u"移動して")
    pyautogui.moveTo(160, 300, duration=1)
    print(u"移動して")
    pyautogui.moveTo(170, 100, duration=1)
    print(u"移動して")
    pyautogui.moveTo(180, 300, duration=1)
    print(u"移動して")
    pyautogui.moveTo(190, 100, duration=1)
    print(u"移動して")
    pyautogui.moveTo(200, 300, duration=1)

    print(u"放す")
    pyautogui.mouseUp(210, 200, button='left')

    print(u"おしまい。とじていいよ")

    time.sleep(30)
    sys.exit()

# Ends here.
Beispiel #30
0
def colab_top(x_top=1360, y_top=210, slow_motion=1):
    time.sleep(0.1 * slow_motion)
    pyautogui.mouseDown(x_top, y_top, 'left')
    pyautogui.mouseUp(x_top, y_top, 'left')
    time.sleep(0.1 * slow_motion)
Beispiel #31
0
# Tweening functions
tweening = [
    pyautogui.easeInQuad, pyautogui.easeOutQuad, pyautogui.easeInOutQuad,
    pyautogui.easeInBounce, pyautogui.easeInElastic
]

cleanScreen()
toggleControls()
i = 0
while True:
    if (i >= cleanScreenInterval):
        cleanScreen
        i = 0
    # If q is pressed we stop the madness
    if keyboard.is_pressed('q'):
        pyautogui.mouseUp()
        toggleControls()
        break
    # On a pressed r we clean the screen
    if keyboard.is_pressed('r'):
        cleanScreen()
        i = 0
    # Get our random numbers
    random.seed()

    # Only do something every 2 strokes
    if (i % 2 == 0 and i != 0):
        # Get a new color maybe?
        if (random.randint(1, 100) <= chanceChangeColor): changeColor()
        # Chance rotational symmetry or mirroring maybe?
        if (random.randint(1, 100) <= chanceChangeRotationalSym):
def inverseClick(doReg=False):
    if doReg:
        pyg.click()
    else:
        pyg.mouseUp()
        pyg.mouseDown()
Beispiel #33
0
def reEnter():

    okButton = pyA.locateOnScreen('images/okButt.PNG', confidence=0.75)
    if okButton != None:
        okButton = pyA.center(okButton)
        okButtonX, okButtonY = okButton
        time.sleep(1)
        pyA.click(okButtonX, okButtonY)
        pyA.mouseDown()
        pyA.mouseUp()
        #print('finished quest ok button clicked')
        #print(datetime.now())

    time.sleep(3)

    okButton = pyA.locateOnScreen('images/okButt.PNG', confidence=0.75)
    if okButton != None:
        okButton = pyA.center(okButton)
        okButtonX, okButtonY = okButton
        time.sleep(1)
        pyA.click(okButtonX, okButtonY)
        pyA.mouseDown()
        pyA.mouseUp()
        #print('finished quest ok button clicked')
        #print(datetime.now())

    time.sleep(3)

    okButton = pyA.locateOnScreen('images/okButt.PNG', confidence=0.75)
    if okButton != None:
        okButton = pyA.center(okButton)
        okButtonX, okButtonY = okButton
        time.sleep(1)
        pyA.click(okButtonX, okButtonY)
        pyA.mouseDown()
        pyA.mouseUp()
        #print('finished quest ok button clicked')
        #print(datetime.now())

    time.sleep(3)

    okButton = pyA.locateOnScreen('images/okButt.PNG', confidence=0.75)
    if okButton != None:
        okButton = pyA.center(okButton)
        okButtonX, okButtonY = okButton
        time.sleep(1)
        pyA.click(okButtonX, okButtonY)
        pyA.mouseDown()
        pyA.mouseUp()
        #print('finished quest ok button clicked')
        #print(datetime.now())

    time.sleep(3)

    okButton = pyA.locateOnScreen('images/okButt.PNG', confidence=0.75)
    if okButton != None:
        okButton = pyA.center(okButton)
        okButtonX, okButtonY = okButton
        time.sleep(1)
        pyA.click(okButtonX, okButtonY)
        pyA.mouseDown()
        pyA.mouseUp()
        #print('finished quest ok button clicked')
        #print(datetime.now())

    time.sleep(4)

    playAgain = pyA.locateOnScreen('images/playagainbutton.PNG',
                                   confidence=0.75)
    if playAgain != None:
        #print("Pic found!")
        playAgain = pyA.center(playAgain)
        playAgainX, playAgainY = playAgain
        time.sleep(1)
        pyA.click(playAgainX, playAgainY)
        pyA.mouseDown()
        pyA.mouseUp()
        #print('playagain button clicked')
        #print(datetime.now())
    else:
        #print("Did not find the play again button")
        #print(datetime.now())
        return 12

    time.sleep(4)

    pic5 = pyA.locateOnScreen('images/findMatchbutton.PNG', confidence=0.75)
    if pic5 != None:
        pic5 = pyA.center(pic5)
        pic5X, pic5Y = pic5
        time.sleep(1)
        pyA.click(pic5X, pic5Y)
        pyA.mouseDown()
        pyA.mouseUp()
        #print('found the re find match button for next game')
        #print(datetime.now())
    else:
        #print("Did not find the re-find match button")
        #print(datetime.now())
        return 6

    time.sleep(3)

    z = 0
    notinGame = True
    while notinGame:
        pic6 = pyA.locateOnScreen('images/Accept2.PNG', confidence=0.9)
        if pic6 != None:
            pic6 = pyA.center(pic6)
            pic6X, pic6Y = pic6
            time.sleep(1)
            pyA.click(pic6X, pic6Y)
            pyA.mouseDown()
            pyA.mouseUp()
            #print('found the match accepted button for the next match')
            #print(datetime.now())
        else:
            #print("Did not find the match accepted button. Trying again")
            #print(datetime.now())
            z += 1
            if z > 80:  #should be 80
                print("the error has been found. fk")
                restart()
                getIntoFirstGame()
                return 12

        time.sleep(5)
        #Check if I am in the match
        if (pyA.locateOnScreen('images/TFTTab2.PNG', confidence=0.75)) == None:
            notinGame = False
Beispiel #34
0
})
# pre-execution steps
for values in selling:
    status.update({values: True})
else:
    print("Keys initialized")
afk_time = (storage_size / 500000) * (60 * (35 - fortune))  # random formula xd

print("Time to start, you have 10 seconds to enter the client in FullScreen")
time.sleep(10)

# farming module
try:
    pyautogui.mouseDown(button='left')
    time.sleep(afk_time)
    pyautogui.mouseUp(button='left')
    time.sleep(1)
    pyautogui.press('t')
    pyautogui.write('/kho', interval=0.1)
    pyautogui.keyDown('shift')
    for keys in status.keys():
        if status[keys]:
            coords = coords_map[keys]
            relative = res_handler(default_resolution, resolution, coords[0],
                                   coords[1])
            pyautogui.rightClick(x=relative[0], y=relative[1])
        else:
            pass
        time.sleep(0.15)  # 15ms delay
except KeyboardInterupt:
    # press CTRL+C or Delete to cancel
Beispiel #35
0
#双击
pg.doubleClick()

#triple click
pg.tripleClick()

#右击
pg.rightClick()

#中击
pg.middleClick()

# 鼠标当前位置滚轮滚动
pg.scroll()

# 鼠标拖拽
pg.dragTo(x=427, y=535, duration=3, button='left')

# 鼠标相对拖拽
pg.dragRel(xOffset=100,
           yOffset=100,
           duration=3,
           button='left',
           mouseDownUp=False)

#鼠标移到x=1796, y=778位置按下
pg.mouseDown(x=1796, y=778, button='left')

#鼠标移到x=2745, y=778位置松开(与mouseDown组合使用选中)
pg.mouseUp(x=2745, y=778, button='left', duration=5)
Beispiel #36
0
def leftClick(delay=0.1):
    pyautogui.mouseDown()
    time.sleep(delay)
    pyautogui.mouseUp()
def start_mouse():
    with open("range.pickle", "rb") as f:
        t = pickle.load(f)

    cam = cv2.VideoCapture(1)
    if cam.read()[0] == False:
        cam = cv2.VideoCapture(0)
    lower = np.array([t[0], t[1], t[2]])  # HSV green lower
    upper = np.array([t[3], t[4], t[5]])  # HSV green upper
    screen_width, screen_height = gui.size()
    frame_width, frame_height = 640, 480
    cam.set(cv2.CAP_PROP_FRAME_WIDTH, frame_width)
    cam.set(cv2.CAP_PROP_FRAME_HEIGHT, frame_height)
    center, old_center = [[0, 0]] * 2, [[
        0, 0
    ]] * 2  # center of 2 fingers together or 2 fingers separate
    area1 = area2 = 0
    damping = 0.5
    sx, sy = (screen_width / frame_width) / damping, (screen_height /
                                                      frame_height) / damping

    is_mouse_down = False

    # flags for 0 fingers, 1 finger and 2 finger
    flags = [True, False, False]

    # frame count for 0 fingers, 1 finger and 2 fingers
    finger_frame_count = [0, 0, 0]

    while True:
        _, img = cam.read()
        img = cv2.flip(img, 1)
        imgHSV = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
        mask = cv2.inRange(imgHSV, lower, upper)
        blur = cv2.medianBlur(mask, 15)
        blur = cv2.GaussianBlur(blur, (5, 5), 0)
        thresh = cv2.threshold(blur, 0, 255,
                               cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
        contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE,
                                    cv2.CHAIN_APPROX_NONE)[1]
        mposx, mposy = gui.position()

        #print(flags)
        if len(contours) >= 2:
            old_center[0] = center[0]
            if is_mouse_down:
                Thread(target=gui.mouseUp, args=()).start()
                is_mouse_down = False
            # if left click was done
            if flags[1] == True:
                is_mouse_down = False

                # do a right click if the fingers were together for 10-20 frames and then released
                if finger_frame_count[1] >= 10 and finger_frame_count[1] <= 20:
                    gui.rightClick()
                # else if fingers were together for less than 10 frames then do a left click
                elif finger_frame_count[1] < 10:
                    gui.click()
                finger_frame_count[1] = 0
            finger_frame_count[2] += 1

            c1, c2 = top(contours, cv2.contourArea, 2)

            rect1 = cv2.minAreaRect(c1)
            (w, h) = rect1[1]
            area1 = w * h
            center1 = np.int0(rect1[0])
            box = cv2.boxPoints(rect1)
            box = np.int0(box)
            cv2.drawContours(img, [box], 0, (0, 0, 255), 2)

            rect2 = cv2.minAreaRect(c2)
            (w, h) = rect2[1]
            area2 = w * h
            center2 = np.int0(rect2[0])
            box = cv2.boxPoints(rect2)
            box = np.int0(box)
            cv2.drawContours(img, [box], 0, (0, 0, 255), 2)

            center[0] = np.int0((center1 + center2) / 2)
            cv2.line(img, tuple(center1), tuple(center2), (255, 0, 0), 2)
            cv2.circle(img, tuple(center[0]), 2, (255, 0, 0), 3)

            if not flags[0]:
                if np.any(abs(center[0] - old_center[0]) > 5):
                    Thread(target=gui.moveTo, args=(mposx+(center[0][0]-old_center[0][0])*sx, mposy + (center[0][1]-old_center[0][1])*sy,\
                     0.1, gui.easeInOutQuad)).start()

            flags = [False, False, True]

        elif len(contours) >= 1:
            old_center[1] = center[1]
            c1 = max(contours, key=cv2.contourArea)
            rect1 = cv2.minAreaRect(c1)
            (w, h) = rect1[1]
            area3 = w * h
            center[1] = np.array(rect1[0])
            box = cv2.boxPoints(rect1)
            box = np.int0(box)
            cv2.drawContours(img, [box], 0, (0, 0, 255), 2)

            error = abs((area1 + area2 - area3) / area3 * 100)
            if (error < 40):
                finger_frame_count[1] += 1
                # do a left click and hold if the fingers were together for more than 20 frames
                if finger_frame_count[1] > 20:
                    if not is_mouse_down:
                        gui.mouseDown()
                        is_mouse_down = True
                    if np.any(abs(center[1] - old_center[1]) > 5):
                        Thread(target=gui.moveTo, args=(mposx+(center[1][0]-old_center[1][0])*sx, mposy + (center[1][1]-old_center[1][1])*sy, \
                            0.1, gui.easeInOutQuad)).start()
                flags = [False, True, False]
            else:
                flags = [True, False, False]

        else:
            if is_mouse_down:
                Thread(target=gui.mouseUp, args=()).start()
                thread.start_new_thread(gui.mouseUp, ())
                is_mouse_down = False
            flags = [True, False, False]

        cv2.imshow("Virtual Mouse", img)
        if cv2.waitKey(1) == ord('q'):
            break

    cam.release()
    cv2.destroyAllWindows()
    gui.mouseUp()
pyautogui.scroll(amount_to_scroll, x=moveToX, y=moveToY)
print(pyautogui.position())
pyautogui.click(1341, 331)
pyautogui.scroll(10)  # scroll up 10 "clicks"
pyautogui.scroll(-10)  # scroll down 10 "clicks"

pyautogui.scroll(
    10, x=1341,
    y=331)  # move mouse cursor to 100, 200, then scroll up 10 "clicks"

pyautogui.hscroll(10)  # scroll right 10 "clicks"
pyautogui.hscroll(-10)  # scroll left 10 "clicks"

pyautogui.mouseDown(x=moveToX, y=moveToY, button='left')
pyautogui.mouseUp(x=moveToX, y=moveToY, button='left')

#Keyboard Functions
pyautogui.typewrite('Hello world!\n',
                    interval=1.0)  #write message with 1 sec between keys
pyautogui.hotkey('ctrl', 'c')  # ctrl-c to copy
pyautogui.hotkey('ctrl', 'v')  # ctrl-v to paste
pyautogui.keyDown(key_name)
pyautogui.keyUp(key_name)

#The press() Functions
pyautogui.press('enter')  # press the Enter key
pyautogui.press('f1')  # press the F1 key
pyautogui.press('left')  # press the left arrow key

#Message Box Functions
Beispiel #39
0
# 中击
pyautogui.middleClick()

#  用缓动/渐变函数让鼠标2秒后移动到(500,500)位置
#  use tweening/easing function to move mouse over 2 seconds.
pyautogui.moveTo(x=500, y=500, duration=2, tween=pyautogui.easeInOutQuad)

# 鼠标拖拽
pyautogui.dragTo(x=427, y=535, duration=3, button='left')

# 鼠标相对拖拽
pyautogui.dragRel(xOffset=100,
                  yOffset=100,
                  duration=0.0,
                  button='left',
                  mouseDownUp=False)

# 鼠标移动到x=1796, y=778位置按下
pyautogui.mouseDown(x=1796, y=778, button='left')

# 鼠标移动到x=2745, y=778位置松开(与mouseDown组合使用选中)
pyautogui.mouseUp(x=2745, y=778, button='left', duration=5)

# 鼠标当前位置滚轮滚动
# pyautogui.scroll()
# 鼠标水平滚动(Linux)
# pyautogui.hscroll()
# # 鼠标左右滚动(Linux)
# pyautogui.vscroll()
Beispiel #40
0
def clickInGame(imageCoords):
    pyautogui.moveTo(imageCoords, duration=2)
    pyautogui.click(imageCoords, duration=.2)
    pyautogui.mouseUp(imageCoords, duration=.1)
Beispiel #41
0
def mouseup(posx, posy):
    pyautogui.mouseUp(posx, posy)
Beispiel #42
0
def send_input():
    if buttons_pressed['l_stick_down'] and not buttons_currently_down['l_stick_down'] \
            and True not in buttons_currently_down.values():
        pyautogui.mouseDown(DOWN_BUTTON)
        buttons_currently_down['l_stick_down'] = True
    elif buttons_currently_down[
            'l_stick_down'] and not buttons_pressed['l_stick_down']:
        pyautogui.mouseUp(DOWN_BUTTON)
        buttons_currently_down['l_stick_down'] = False

    if buttons_pressed['l_stick_up'] and not buttons_currently_down['l_stick_up'] \
            and True not in buttons_currently_down.values():
        pyautogui.mouseDown(UP_BUTTON)
        buttons_currently_down['l_stick_up'] = True
    elif buttons_currently_down[
            'l_stick_up'] and not buttons_pressed['l_stick_up']:
        pyautogui.mouseUp(UP_BUTTON)
        buttons_currently_down['l_stick_up'] = False

    if buttons_pressed['l_stick_left'] and not buttons_currently_down['l_stick_left'] \
            and True not in buttons_currently_down.values():
        pyautogui.mouseDown(LEFT_BUTTON)
        buttons_currently_down['l_stick_left'] = True
    elif buttons_currently_down[
            'l_stick_left'] and not buttons_pressed['l_stick_left']:
        pyautogui.mouseUp(LEFT_BUTTON)
        buttons_currently_down['l_stick_left'] = False

    if buttons_pressed['l_stick_right'] and not buttons_currently_down['l_stick_right'] \
            and True not in buttons_currently_down.values():
        pyautogui.mouseDown(RIGHT_BUTTON)
        buttons_currently_down['l_stick_right'] = True
    elif buttons_currently_down[
            'l_stick_right'] and not buttons_pressed['l_stick_right']:
        pyautogui.mouseUp(RIGHT_BUTTON)
        buttons_currently_down['l_stick_right'] = False

    if buttons_pressed['a'] and not buttons_currently_down['a'] \
            and True not in buttons_currently_down.values():
        pyautogui.mouseDown(ACTION)
        buttons_currently_down['a'] = True
    elif buttons_currently_down['a'] and not buttons_pressed['a']:
        pyautogui.mouseUp(ACTION)
        buttons_currently_down['a'] = False

    if buttons_pressed['x'] and not buttons_currently_down['x'] \
            and True not in buttons_currently_down.values():
        switch_motor('A')
        buttons_currently_down['x'] = True
    elif buttons_currently_down['x'] and not buttons_pressed['x']:
        buttons_currently_down['x'] = False

    if buttons_pressed['y'] and not buttons_currently_down['y'] \
            and True not in buttons_currently_down.values():
        switch_motor('B')
        buttons_currently_down['y'] = True
    elif buttons_currently_down['y'] and not buttons_pressed['y']:
        buttons_currently_down['y'] = False

    if buttons_pressed['b'] and not buttons_currently_down['b'] \
            and True not in buttons_currently_down.values():
        switch_motor('C')
        buttons_currently_down['b'] = True
    elif buttons_currently_down['b'] and not buttons_pressed['b']:
        buttons_currently_down['b'] = False

    if buttons_pressed['r_shoulder'] and not buttons_currently_down['r_shoulder'] \
            and True not in buttons_currently_down.values():
        swap_direction()
        buttons_currently_down['r_shoulder'] = True
    elif buttons_currently_down[
            'r_shoulder'] and not buttons_pressed['r_shoulder']:
        buttons_currently_down['r_shoulder'] = False

    if buttons_pressed['left'] and not buttons_currently_down['left'] \
            and True not in buttons_currently_down.values():
        adjust_active_speed('down')
        buttons_currently_down['left'] = True
    elif buttons_currently_down['left'] and not buttons_pressed['left']:
        buttons_currently_down['left'] = False

    if buttons_pressed['right'] and not buttons_currently_down['right'] \
            and True not in buttons_currently_down.values():
        adjust_active_speed('up')
        buttons_currently_down['right'] = True
    elif buttons_currently_down['right'] and not buttons_pressed['right']:
        buttons_currently_down['right'] = False

    if buttons_pressed['start'] and not buttons_currently_down['start'] \
            and True not in buttons_currently_down.values():
        swap_NXT()
        buttons_currently_down['start'] = True
    elif buttons_currently_down['start'] and not buttons_pressed['start']:
        buttons_currently_down['start'] = False
Beispiel #43
0
def leftRelease():
    pyautogui.mouseUp(button='left')
Beispiel #44
0
def click():
    pyautogui.mouseDown()
    time.sleep(0.05)
    pyautogui.mouseUp()
Beispiel #45
0
 def do_it(self,body):
     try:
         if body != None:
             head = body[:4]
             body = body[4:]
             if head == 'MOUS':
                 #MOUSE MOVE EVENT
                 mxy = body.split('|')
                 self.mous.move(int(mxy[0]),int(mxy[1]))
                 #pyautogui.moveTo(int(mxy[0]),int(mxy[1]))
             elif head == 'MCLK':
                 #MOUSE CLICK EVENT
                 mxy = body.split('|')
                 if mxy[2] == 'DCLK':
                     # DOUBLE CLICK
                     if mxy[3] == '1':
                         pyautogui.doubleClick(int(mxy[0]),int(mxy[1]),button='left')
                     elif mxy[3] == '2':
                         pyautogui.doubleClick(int(mxy[0]),int(mxy[1]),button='right')
                 elif mxy[2] == 'SCLK':
                     #SINGLE CLICK
                     if mxy[3] == '1':
                         pyautogui.click(int(mxy[0]),int(mxy[1]),button='left')
                     elif mxy[3] == '2':
                         pyautogui.click(int(mxy[0]),int(mxy[1]),button='right')
                 elif mxy[2] == 'DOWN':
                     #MOUSE PRESS
                     if mxy[3] == '1':
                         pyautogui.mouseDown(int(mxy[0]),int(mxy[1]),button='left')
                     elif mxy[3] == '3':
                         pyautogui.mouseDown(int(mxy[0]),int(mxy[1]),button='right')
                     elif mxy[3] == '4':
                         #SCROLL DOWN
                         pyautogui.scroll(-5,x=int(mxy[0]),y=int(mxy[1]))
                 elif mxy[2] == 'UP':
                     #MOUSE RELEASE
                     if mxy[3] == '1':
                         pyautogui.mouseUp(int(mxy[0]),int(mxy[1]),button='left')
                     elif mxy[3] == '3':
                         pyautogui.mouseUp(int(mxy[0]),int(mxy[1]),button='right')
                     elif mxy[3] == '4':
                         #SCROLL UP
                         pyautogui.scroll(5,x=int(mxy[0]),y=int(mxy[1]))
             elif head == "KCLK":
                 #KEYBOARD EVENT
                 key_ev = body.split('|')
                 if key_ev[0] == 'DOWN':
                     pyautogui.keyDown(key_ev[1])
                 elif key_ev[0] == "UP":
                     pyautogui.keyUp(key_ev[1])
                 elif key_ev[0] == "PRES":
                     pyautogui.press(key_ev[1])
             elif head == 'CLIP':
                 # CLIP BOARD EVENT
                 if body[:4] == 'COPY':
                     #send local clipboard to remote
                     lclip = pyperclip.paste()
                     screen_output_q.put_nowait(self.controler+lclip)
                 elif body[:4] == 'PAST':
                     #receive remote clipboad
                     data = body[4:]
                     pyperclip.copy(data)
              
         return True
     except Exception as e:
         print "INPUT CONTROL ERROR",e
         return False
Beispiel #46
0
def getIntoFirstGame():
    time.sleep(3)

    pic1 = pyA.locateOnScreen('images/TFTtab2.png', confidence=0.75)
    if pic1 != None:
        #print("Pic found!")
        pic1 = pyA.center(pic1)
        pic1X, pic1Y = pic1
        time.sleep(1)
        pyA.click(pic1X, pic1Y)
        pyA.mouseDown()
        pyA.mouseUp()
    else:
        #print("Did not find first TFT Tab")
        return

    time.sleep(3)

    pic2 = pyA.locateOnScreen('images/playbutton.PNG', confidence=0.75)
    pic22 = pyA.locateOnScreen('images/partybutton.PNG', confidence=0.75)
    if pic2 != None:
        #print("Pic found!")
        pic2 = pyA.center(pic2)
        pic2X, pic2Y = pic2
        time.sleep(1)
        pyA.click(pic2X, pic2Y)
        pyA.mouseDown()
        pyA.mouseUp()
    elif pic22 != None:
        #print("Pic found!")
        pic22 = pyA.center(pic22)
        pic22X, pic22Y = pic22
        time.sleep(1)
        pyA.click(pic22X, pic22Y)
        pyA.mouseDown()
        pyA.mouseUp()
    else:
        #print("Did not find play button")
        return

    time.sleep(3)

    pic3 = pyA.locateOnScreen('images/teamfighttab.PNG', confidence=0.75)
    if pic3 != None:
        #print("Pic found!")
        pic3 = pyA.center(pic3)
        pic3X, pic3Y = pic3
        time.sleep(1)
        pyA.click(pic3X, pic3Y)
        pyA.mouseDown()
        pyA.mouseUp()
    else:
        #print("Did not find team fight tab")
        return

    time.sleep(3)

    pic4 = pyA.locateOnScreen('images/confirmbutton.PNG', confidence=0.75)
    if pic4 != None:
        #print("Pic found!")
        pic4 = pyA.center(pic4)
        pic4X, pic4Y = pic4
        time.sleep(1)
        pyA.click(pic4X, pic4Y)
        pyA.mouseDown()
        pyA.mouseUp()
    else:
        #print("Did not find the confirm button")
        return

    time.sleep(4)

    pic5 = pyA.locateOnScreen('images/findMatchbutton.PNG', confidence=0.75)
    if pic5 != None:
        #print("Pic found!")
        pic5 = pyA.center(pic5)
        pic5X, pic5Y = pic5
        time.sleep(1)
        pyA.click(pic5X, pic5Y)
        pyA.mouseDown()
        pyA.mouseUp()
    else:
        #print("Did not find the find match button")
        return

    time.sleep(3)

    notinGame = True
    while notinGame:
        pic6 = pyA.locateOnScreen('images/Accept2.PNG', confidence=0.9)
        if pic6 != None:
            #print("Pic found!")
            pic6 = pyA.center(pic6)
            pic6X, pic6Y = pic6
            time.sleep(1)
            pyA.click(pic6X, pic6Y)
            pyA.mouseDown()
            pyA.mouseUp()
        else:
            pass
            #print("Did not find the match accepted button. Trying again")
        time.sleep(5)
        #Check if I am in the match
        if (pyA.locateOnScreen('images/TFTTab2.PNG', confidence=0.75)) == None:
            notinGame = False
Beispiel #47
0
    # out.write(frame)
    cv2.imshow("", frame)

    for y in range(500, 400, -1):
        for x in range(1160, 1150, -1):
            c = screen[y][x] == 0
            d = screen[y][x - 120] == 0
            e = screen[y][x - 240] == 0
            f = screen[y][x - 360] == 0
            if c.any():
                newX = x
                newY = y
                pg.mouseDown(x=newX, y=newY)

                pg.sleep(0.06)
                pg.mouseUp(x=newX, y=newY)
                break
            elif d.any():
                newX = x - 120
                newY = y
                pg.mouseDown(x=newX, y=newY)

                pg.sleep(0.06)
                pg.mouseUp(x=newX, y=newY)
                break
            elif e.any():
                newX = x - 240
                newY = y
                pg.mouseDown(x=newX, y=newY)

                pg.sleep(0.06)
            frame, reference_point)

        # mouse click
        if mouse_enabled and (blink or blink_prev[0]):
            if t_blink == 0:
                t_blink = time.time()
            if (time.time() - t_blink) > 0.3:
                if not (left_b):
                    print("[INFO] Left mouse button PRESSED")
                    pyautogui.mouseDown()
                    left_b = True
        if mouse_enabled and not (blink or blink_prev[0] or blink_prev[1]):
            t_blink = 0
            if left_b:
                print("[INFO] Left mouse button RELEASED")
                pyautogui.mouseUp()
                left_b = False

        # Keystroke detect:
        k = cv2.waitKey(1)
        if k > 0:  # keystroke detected
            # quit on "Q"
            if k == ord('q'):
                break
            # new reference point on "R"
            if k == ord('r'):
                if len(center_face_position) != 0:
                    reference_point = center_face_position
                    print("[STATE] Reference set as:", reference_point)
            # toggle mouse control enable on "E"
            if k == ord('e'):
Beispiel #49
0
def Logic(
        MousePos):  #HACK: passing mouse position is rather limiting, consider
    windowpos = Hooks.GetWinPos(global_game_coords, MousePos)
    #print("X:{} Y:{}".format(windowpos[0], windowpos[1]))

    #Variable Declarations? #HACK: move to seperate file
    screen = np.array(ImageGrab.grab(bbox=global_game_coords))
    rest = Hooks.GetScreenPos(global_game_coords, Point(100, 150))
    play_all_button = Point(330, 715)
    end_turn_button = Point(1478, 570)
    card_activate_button = Point(1160, 265)

    #reset
    pag.moveTo(rest.x, rest.y)
    pag.click()

    #Click play all button
    play_all_scan = SL.HScanLine(Point(330, 715), Point(331, 715))
    resultP = play_all_scan.ScanLine(screen, RGB(15, 65, 100),
                                     RGB(30, 90, 140), 1)
    if (play_all_scan.IsValidResult(resultP)):
        ap = Hooks.GetScreenPos(global_game_coords, resultP)
        pag.click(ap.x, ap.y)
        pag.moveTo(rest.x, rest.y)
        time.sleep(2)
        print("Play All Button Clicked")
        return

    #Try to Buy the Boss
    #1389, 248 //check for color 40-70r, 0-20g, 90-120b
    #785,730 -> buy boss Button
    boss_scan = SL.HScanLine(Point(1390, 248), Point(1420, 248))
    resultP = boss_scan.ScanLine(screen, RGB(40, 0, 90), RGB(70, 20, 120), 1)
    if (boss_scan.IsValidResult(resultP)):
        #click boss
        ap = Hooks.GetScreenPos(global_game_coords, Point(1480, 375))
        pag.click(ap.x, ap.y)
        time.sleep(.1)
        #click buy boss
        ap = Hooks.GetScreenPos(global_game_coords, Point(785, 730))
        pag.moveTo(ap.x, ap.y)
        pag.click(ap.x, ap.y)
        time.sleep(5)
        #wait for animation
        pag.moveTo(rest.x, rest.y)
        time.sleep(.1)
        print("Play All Button Clicked")
        return

    #Handle Card Effects (in hand)
    card_hand_effect_scan = SL.HScanLine(Point(520, 700), Point(1120, 700))
    #Blue
    resultP = card_hand_effect_scan.ScanLine(screen, RGB(200, 200, 255),
                                             RGB(240, 255, 255), 1)
    if (card_hand_effect_scan.IsValidResult(resultP)):
        ActivateCard(resultP, 50, card_activate_button, rest)
        print("Played Card")
        return
    #Blue also
    resultP = card_hand_effect_scan.ScanLine(screen, RGB(0, 255, 255),
                                             RGB(0, 255, 255), 1)
    if (card_hand_effect_scan.IsValidResult(resultP)):
        ActivateCard(resultP, 50, card_activate_button, rest)
        print("Played Card")
        return
    #Yellow?
    resultP = card_hand_effect_scan.ScanLine(screen, RGB(180, 180, 60),
                                             RGB(220, 220, 100), 1)
    if (card_hand_effect_scan.IsValidResult(resultP)):
        ActivateCard(resultP, 50, card_activate_button, rest)
        print("Played Card")
        return
    #Purple?
    resultP = card_hand_effect_scan.ScanLine(screen, RGB(200, 20, 240),
                                             RGB(255, 60, 255), 1)
    if (card_hand_effect_scan.IsValidResult(resultP)):
        ActivateCard(resultP, 50, card_activate_button, rest)
        print("Played Card")
        return
    #Orange
    resultP = card_hand_effect_scan.ScanLine(screen, RGB(210, 70, 70),
                                             RGB(255, 100, 100), 1)
    if (card_hand_effect_scan.IsValidResult(resultP)):
        ActivateCard(resultP, 50, card_activate_button, rest)
        print("Played Card")
        return

    #Look for upgradable cards and upgrade them
    play_area_scan = SL.HScanLine(Point(300, 620), Point(1080, 620))
    resultP = play_area_scan.ScanLine(screen, RGB(50, 50, 255),
                                      RGB(254, 254, 255), 1)
    if (play_area_scan.IsValidResult(resultP)):
        ActivateCard(resultP, 30, card_activate_button, rest)
        print("Upgraded Card")
        return

    #Buy cards (and handle effects in the buy area)
    buy_area_scan = SL.HScanLine(Point(270, 460), Point(1250,
                                                        460))  #bottom of card
    resultP = buy_area_scan.ScanLine(screen, RGB(250, 250, 90),
                                     RGB(255, 255, 130), 1)
    if (buy_area_scan.IsValidResult(resultP)):
        ActivateCard(resultP, 50, card_activate_button, rest)
        print("Bought Card")  # not accurate name but good for testing the line
        return

        #This one is causeing problems
        #it's a light blue that happens when a card is going to be placed on the top of deck after purchase
        #the issue is some cards can also be a very similar shade of this blue, neither is a super common thing (5ish cards are the color, 4 ish cards cause the color)
        #or maybe it's purple, wah
        #no wait I think this was coverting white gosh durnit
        #the buy area is complex
        #and now I made it purple
    resultP = buy_area_scan.ScanLine(screen, RGB(255, 20, 255),
                                     RGB(255, 70, 255), 1)
    if (buy_area_scan.IsValidResult(resultP)):
        ActivateCard(resultP, 50, card_activate_button, rest)
        print("Bought Card")
        return

    resultP = buy_area_scan.ScanLine(screen, RGB(150, 100, 255),
                                     RGB(250, 255, 255), 1)
    if (buy_area_scan.IsValidResult(resultP)):
        ActivateCard(resultP, 50, card_activate_button, rest)
        print("Bought Card")
        return

    #click end turn button (has to be held down on occasion)
    end_turn_scan = SL.HScanLine(Point(1478, 570), Point(1479, 570))
    resultP = end_turn_scan.ScanLine(screen, RGB(0, 50, 80), RGB(50, 100, 140),
                                     1)
    if (end_turn_scan.IsValidResult(resultP)):
        ap = Hooks.GetScreenPos(global_game_coords, resultP)
        pag.moveTo(ap.x, ap.y)
        pag.mouseDown()
        time.sleep(1)
        pag.mouseUp()
        pag.moveTo(rest.x, rest.y)
        time.sleep(.1)
        print("Played Card")
        return

    return
Beispiel #50
0
pyautogui.moveTo(148, 767, 0.5)
pyautogui.click(148, 767, interval=0.50)
pyautogui.typewrite('Paint', interval=0.05)
time.sleep(2)

pyautogui.click(157, 263, interval=1.50)
time.sleep(2)

x, y = pyautogui.locateCenterOnScreen('ic.png', grayscale=True)
print(x, y)
pyautogui.click(x, y)

pyautogui.mouseDown(button='left', x=207, y=608)
pyautogui.mouseDown(button='left', x=467, y=283)
pyautogui.mouseDown(button='left', x=849, y=593)
pyautogui.mouseUp(button='left', x=207, y=608)

pyautogui.alert(text='Triangle Drawn, Type Try in TextBox to Continue...',
                title='Triangle Drawn',
                button='OK')
pwd = pyautogui.password(text='Triangle Drawn, Type in TextBox to Continue...',
                         title='Triangle Drawn',
                         default='',
                         mask='*')

print(pwd)

# https://pyautogui.readthedocs.io/en/latest/mouse.html
# https://pyautogui.readthedocs.io/en/latest/keyboard.html
Beispiel #51
0
#  按住鼠标左键,用2秒钟把鼠标拖拽到(300, 400)位置
pyautogui.dragTo(300, 400, 2, button='left')
#  按住鼠标左键,用0.2秒钟把鼠标向上拖拽
pyautogui.dragRel(0, -60, duration=0.2)

# pyautogui.click(x=moveToX, y=moveToY, clicks=num_of_clicks, interval=secs_between_clicks, button='left')
# 其中,button属性可以设置成left,middle和right。
pyautogui.click(10, 20, 2, 0.25, button='left')
pyautogui.click(x=100, y=200, duration=2)  # 先移动到(100, 200)再单击
pyautogui.click()  # 鼠标当前位置点击一下
pyautogui.doubleClick()  # 鼠标当前位置左击两下
pyautogui.doubleClick(x=100, y=150, button="left")  # 鼠标在(100,150)位置左击两下
pyautogui.tripleClick()  # 鼠标当前位置左击三下

pyautogui.mouseDown()  # 鼠标左键按下再松开
pyautogui.mouseUp()
pyautogui.mouseDown(button='right')  # 按下鼠标右键
pyautogui.mouseUp(button='right', x=100, y=200)  # 移动到(100, 200)位置,然后松开鼠标右键

# scroll函数控制鼠标滚轮的滚动,amount_to_scroll参数表示滚动的格数。正数则页面向上滚动,负数则向下滚动
# pyautogui.scroll(clicks=amount_to_scroll, x=moveToX, y=moveToY)
pyautogui.scroll(5, 20, 2)
pyautogui.scroll(10)  # 向上滚动10格
pyautogui.scroll(-10)  # 向下滚动10格
pyautogui.scroll(10, x=100, y=100)  # 移动到(100, 100)位置再向上滚动10格

# 缓动/渐变函数可以改变光标移动过程的速度和方向。通常鼠标是匀速直线运动,这就是线性缓动/渐变函数。
# PyAutoGUI有30种缓动/渐变函数,可以通过pyautogui.ease*?查看。
#  开始很慢,不断加速
pyautogui.moveTo(100, 100, 2, pyautogui.easeInQuad)
#  开始很快,不断减速
def performAction(yp, rc, bc, action, drag, perform):
    if perform:
        cursor[0] = 4 * (yp[0] - 110)
        cursor[1] = 4 * (yp[1] - 120)
        if action == 'move':

            if yp[0] > 110 and yp[0] < 590 and yp[1] > 120 and yp[1] < 390:
                pyautogui.moveTo(cursor[0], cursor[1])
            elif yp[0] < 110 and yp[1] > 120 and yp[1] < 390:
                pyautogui.moveTo(8, cursor[1])
            elif yp[0] > 590 and yp[1] > 120 and yp[1] < 390:
                pyautogui.moveTo(1912, cursor[1])
            elif yp[0] > 110 and yp[0] < 590 and yp[1] < 120:
                pyautogui.moveTo(cursor[0], 8)
            elif yp[0] > 110 and yp[0] < 590 and yp[1] > 390:
                pyautogui.moveTo(cursor[0], 1072)
            elif yp[0] < 110 and yp[1] < 120:
                pyautogui.moveTo(8, 8)
            elif yp[0] < 110 and yp[1] > 390:
                pyautogui.moveTo(8, 1072)
            elif yp[0] > 590 and yp[1] > 390:
                pyautogui.moveTo(1912, 1072)
            else:
                pyautogui.moveTo(1912, 8)

        elif action == 'left':
            pyautogui.click(button='left')

        elif action == 'right':
            pyautogui.click(button='right')
            time.sleep(0.3)

        elif action == 'up':
            pyautogui.scroll(5)
#			time.sleep(0.3)

        elif action == 'down':
            pyautogui.scroll(-5)


#			time.sleep(0.3)

        elif action == 'drag' and drag == 'true':
            global y_pos
            drag = 'false'
            pyautogui.mouseDown()

            while (1):

                k = cv2.waitKey(10) & 0xFF
                changeStatus(k)

                _, frameinv = cap.read()
                # flip horizontaly to get mirror image in camera
                frame = cv2.flip(frameinv, 1)

                hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

                b_mask = makeMask(hsv, blue_range)
                r_mask = makeMask(hsv, red_range)
                y_mask = makeMask(hsv, yellow_range)

                py_pos = y_pos

                b_cen = drawCentroid(frame, b_area, b_mask, showCentroid)
                r_cen = drawCentroid(frame, r_area, r_mask, showCentroid)
                y_cen = drawCentroid(frame, y_area, y_mask, showCentroid)

                if py_pos[0] != -1 and y_cen[0] != -1:
                    y_pos = setCursorPos(y_cen, py_pos)

                performAction(y_pos, r_cen, b_cen, 'move', drag, perform)
                cv2.imshow('Frame', frame)

                if distance(y_pos, r_cen) > 60 or distance(
                        y_pos, b_cen) > 60 or distance(r_cen, b_cen) > 60:
                    break

            pyautogui.mouseUp()
Beispiel #53
0
 def fire_process(self):
     if (self.isButtonDown('b1')): pg.mouseDown(button='left')
     elif (self.isButtonUp('b1')): pg.mouseUp(button='left')
     return
Beispiel #54
0
def rightRelease():
    pyautogui.mouseUp(button='right')
Beispiel #55
0
#combo position
com_1_icon_pos = {'left': 861, 'top': 593, 'width': 18, 'height': 18}
com_2_icon_pos = {'left': 837, 'top': 593, 'width': 18, 'height': 18}
com_3_icon_pos = {'left': 815, 'top': 593, 'width': 18, 'height': 18}
com_4_icon_pos = {'left': 791, 'top': 593, 'width': 18, 'height': 18}
com_5_icon_pos = {'left': 746, 'top': 593, 'width': 18, 'height': 18}

#combo note count
com1 = 5
com2 = 6
com3 = 7
com4 = 8
com5 = 10

pag.moveTo(x=200, y=200, duration=0.0)
pag.mouseDown()
pag.mouseUp()

kb.press_and_release('1')
print("jam is now on!")
time.sleep(1)

kb.press_and_release('f1')
print("go!")

#freestyle_jam(com1,com_1_icon_pos)
#freestyle_jam(com2,com_2_icon_pos)
#freestyle_jam(com3,com_3_icon_pos)
#freestyle_jam(com4,com_4_icon_pos)
freestyle_jam(com5, com_5_icon_pos)
Beispiel #56
0
        else:
            st.stop()
        if zoomChange == "Yes":
            st.write("Zooming in by ", zoom, "notches")
        else:
            st.write("No zoom change ", zoom, "notches")

        st.image(drawImg(imgExtracted, lengthChangeX, lengthChangeY))

        runNewCalc = st.button("Run Changes")

        if runNewCalc:
            ms.moveTo(int(x2 / 2), int(y2 / 2), duration=0.5)
            ms.mouseDown(button='left')
            ms.moveRel(lengthChangeX, lengthChangeY, duration=1)
            ms.mouseUp(button='left')

            for i in range(zoom):
                ms.scroll(1)
                time.sleep(0.1)
            ms.typewrite(["n", "u", "r"])
            time.sleep(2)
            imgExtractedNew = ms.screenshot()
            st.write("New Image")
            st.image(imgExtractedNew)
        #"""
st.header('Run Calculations')
st.write(
    'This process uses a control of the mouse on your screen to calculate all the data. Please don\'t touch the mouse during the process'
)
Beispiel #57
0
def locate_target(targets):
    # compute the center of the contour
    global autoshotOn
    global singleUseHeadshot
    global startTimeMouseMove
    global lastXMove
    global lastYMove
    closestDistance = 10000
    closestX = 10000
    closestY = 10000
    closestSplitWidth = 0
    closestSplitHeight = 0    
    
    i = 0
    for target in targets:   
        if target is targets[0]:
            continue
        if i >= 4:
            break
        i = i + 1    
        
        moment = cv2.moments(target)   
        x,y,w,h = cv2.boundingRect(target)    
        if moment["m00"] == 0:
            return
            
        width = w * 1/2
        height = h * 1/3
        
        if headshotOn or singleUseHeadshot:
            adjustY = int(height/4)
        
        cx = int(moment["m10"] / moment["m00"])
        cy = int(moment["m01"] / moment["m00"])

        mid = SQUARE_SIZE / 2
        x = -(mid - cx) if cx < mid else cx - mid
        y = -(mid - cy) if cy < mid else cy - mid

        if headshotOn: 
            y = y - int(h/4)

        target_size = cv2.contourArea(target)
        distance = sqrt(pow(x, 2) + pow(y, 2))
        
        if distance <= closestDistance:
            closestDistance = distance
            closestSplitWidth = width/2
            closestSplitHeight = height/2

            # There's definitely some sweet spot to be found here
            # for the sensitivity in regards to the target's size
            # and distance
            slope = ((1.0 / 3.0) - 1.0) / (MAX_TARGET_DISTANCE / target_size)
            multiplier = ((MAX_TARGET_DISTANCE - distance) / target_size) * slope + 1
            targetX = int(x * multiplier)     
            targetY = int(y * multiplier * -1)
                
    currentTime = int(round(time.time() * 1000))
    
    if is_activated():
        mouse_move(targetX, targetY)
        if autoshotOn and x <= closestSplitWidth and x >= closestSplitWidth*-1 and y <= closestSplitHeight and y >= closestSplitHeight*-1:
            pyautogui.mouseDown()
            pyautogui.mouseUp()
            singleUseHeadshot = False
Beispiel #58
0
def clickControlButton(x, y):
    pyautogui.mouseUp()
    pyautogui.moveTo(x, y, tween='linear')
    pyautogui.mouseDown(duration=0.2)
    pyautogui.mouseUp()
Beispiel #59
0
def rightRelease():
    print("test2")
    pyautogui.mouseUp(button='right')
Beispiel #60
-30
 def shield_charge(self, duration):
     """Shield Charge moves player forward and knocks back the enemies"""
     duration = random.uniform(duration - 1.5, duration + 1.5)
     pyautogui.mouseDown(self.F)
     time.sleep(duration)
     pyautogui.mouseUp()
     self.heal()