Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_pause(self):
oldValue = pyautogui.PAUSE
startTime = time.time()
pyautogui.PAUSE = 0.35 # there should be a 0.35 second pause after each call
pyautogui.moveTo(1, 1)
pyautogui.moveRel(0, 1)
pyautogui.moveTo(1, 1)
elapsed = time.time() - startTime
self.assertTrue(1.0 < elapsed < 1.1, "Took %s seconds, expected 1.0 < 1.1 seconds." % (elapsed))
pyautogui.PAUSE = oldValue # restore the old PAUSE value
def click_until(*images):
pyautogui.PAUSE = 0.2 * PAUSE_TIME
while True:
for pos, image in enumerate(images):
if image_is_on_screen(image):
pyautogui.PAUSE = PAUSE_TIME
wait(0.5)
return pos
for _ in range(10):
touch(**LEFT_EDGE)
def relaunch(self):
tmp = pg.PAUSE
UI = self.bot.get_UI()
pg.PAUSE = 2
x, y = UI.BACK_TO_DASHBOARD; pg.click(x, y, button="left")
x, y = UI.DISCONNECT; pg.click(x, y, button="left")
x, y = UI.YES_DISCONNECT; pg.click(x, y, button="left")
x, y = UI.PLAY_DOTA; pg.click(x, y, button="left")
x, y = UI.CREATE_LOBBY; pg.click(x, y, button="left")
pg.PAUSE = 12
x, y = UI.START_GAME; pg.click(x, y, button="left")
pg.PAUSE = 2
x, y = UI.BREWMASTER; pg.click(x, y, button="left")
x, y = UI.LOCK_IN; pg.click(x, y, button="left")
pg.PAUSE = 10
x, y = self.bracer; pg.click(x, y, button="right")
pg.PAUSE = 1
x, y = self.iron_branch; pg.click(x, y, button="right", clicks=3, interval=0.5)
refX, refY, _, _ = pyautogui.locateOnScreen('editbtn.png')
except:
try:
refX, refY, _, _ = pyautogui.locateOnScreen('editbtn_large.png')
except:
raise SyntaxError('Make sure the league client is visible on screen, with the rune editor open')
# Change name
pyautogui.moveTo(refX, refY)
pyautogui.click(button=button)
pyautogui.moveTo(refX + ratio * 100, refY)
pyautogui.click(button=button)
pyautogui.hotkey('ctrl', 'a')
pyautogui.typewrite(page[0], interval=0.005)
pyautogui.PAUSE = 0.08
# Primary path
pyautogui.moveTo(refX + ratio * (90 + 38 * (page[1] - 1)), refY + ratio * 90)
pyautogui.click(button=button)
# Keystone
pyautogui.moveTo(refX + ratio * (90 + 70 * (page[2] - 1)), refY + ratio * 200)
pyautogui.click(button=button)
# Primary R1
pyautogui.moveTo(refX + ratio * (90 + 70 * (page[3] - 1)), refY + ratio * 300)
pyautogui.click(button=button)
# Primary R2
pyautogui.moveTo(refX + ratio * (90 + 70 * (page[4] - 1)), refY + ratio * 400)
pyautogui.click(button=button)
def relaunch(self):
tmp = pg.PAUSE
UI = self.bot.get_UI()
pg.PAUSE = 2
x, y = UI.BACK_TO_DASHBOARD; pg.click(x, y, button="left")
x, y = UI.DISCONNECT; pg.click(x, y, button="left")
x, y = UI.YES_DISCONNECT; pg.click(x, y, button="left")
x, y = UI.PLAY_DOTA; pg.click(x, y, button="left")
x, y = UI.CREATE_LOBBY; pg.click(x, y, button="left")
pg.PAUSE = 12
x, y = UI.START_GAME; pg.click(x, y, button="left")
pg.PAUSE = 2
x, y = UI.BREWMASTER; pg.click(x, y, button="left")
x, y = UI.LOCK_IN; pg.click(x, y, button="left")
pg.PAUSE = 10
x, y = self.bracer; pg.click(x, y, button="right")
pg.PAUSE = 1
x, y = self.iron_branch; pg.click(x, y, button="right", clicks=3, interval=0.5)
x, y = UI.SKIP_AHEAD; pg.click(x, y, button="left")
## reset the time
self.bot.env.over_time = 0
## move to the battle field
pg.PAUSE = 10
x, y = self.battle_field; pg.click(x, y, button="right")
pg.PAUSE = 95
pg.click(button="right")
import utils
# from tensorforce.agents import DQNAgent
from matplotlib import pyplot as plt
from threading import Thread
import os
from PyQt5.QtWidgets import QApplication, QWidget, QGridLayout, QPushButton, QMainWindow,\
QGraphicsView, QGraphicsScene, QVBoxLayout, QHBoxLayout, QTextEdit
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from PyQt5.QtCore import Qt, pyqtSignal, QObject
import PyQt5.QtCore as QtCore
import pyqtgraph as pg
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # or any {'0', '1', '2'}
pyautogui.PAUSE = 0.01
pyautogui.FAILSAFE = False
class QSignalViewer(pg.PlotWidget):
emitter = pyqtSignal(object)
def __init__(self, num_signals):
super().__init__()
# save number of signals
self.nplots = num_signals
# set number of samples to be displayed per signal at a time
self.nsamples = 500
# connect the signal to be emitted by the feeder to the slot of the plotWidget that will update the signals
self.emitter.connect(lambda values: self.update(values))
# buffer to store the data from all signals
self.buff = np.zeros((self.nplots, self.nsamples))
def relaunch(self):
tmp = pg.PAUSE
UI = self.bot.get_UI()
pg.PAUSE = 2
x, y = UI.BACK_TO_DASHBOARD; pg.click(x, y, button="left")
x, y = UI.DISCONNECT; pg.click(x, y, button="left")
x, y = UI.YES_DISCONNECT; pg.click(x, y, button="left")
x, y = UI.PLAY_DOTA; pg.click(x, y, button="left")
x, y = UI.CREATE_LOBBY; pg.click(x, y, button="left")
pg.PAUSE = 12
x, y = UI.START_GAME; pg.click(x, y, button="left")
pg.PAUSE = 2
x, y = UI.BREWMASTER; pg.click(x, y, button="left")
x, y = UI.LOCK_IN; pg.click(x, y, button="left")
pg.PAUSE = 10
x, y = self.bracer; pg.click(x, y, button="right")
pg.PAUSE = 1
x, y = self.iron_branch; pg.click(x, y, button="right", clicks=3, interval=0.5)
x, y = UI.SKIP_AHEAD; pg.click(x, y, button="left")
## reset the time
self.bot.env.over_time = 0
## move to the battle field
pg.PAUSE = 10
x, y = self.battle_field; pg.click(x, y, button="right")
pg.PAUSE = 95
pg.click(button="right")
pg.PAUSE = tmp
x, y = UI.THIRD_ABILITY; pg.click(x, y, button="left")
import os
import sys
import time
from PIL import Image
from os import environ
import cv2
import numpy as np
import pyautogui as pg
pg.PAUSE = 0
#for mac or windows users:
from PIL import ImageGrab
#for ubuntu users:
#import pyscreenshot as ImageGrab
#(x,y) to represent left-top corner of the rectangle, little away from dino
#(x+w,y+h) bottom-right corner of the rectangle enclosing dino and coming cactus.
x, y, w, h = 585, 327, 244, 100
while True:
img = ImageGrab.grab()
img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import tornado.websocket
import unidecode
from pynput import keyboard, mouse
from pynput.keyboard import Controller
from tornado.platform.asyncio import AnyThreadEventLoopPolicy
from listeners import Listener
from universalVK import keyCodes
key = Controller()
pyautogui.PAUSE = 0
serialPort = None
ctrlListener = None
INITIALIZED = False
CLIENT_CONNECTED = False
CLIENT = None
PING_SENDED = False
Grappe = None
Recording = False
Events = []
doubleClickChecker = None
lastClickedTime = 0
lastSpecialKeyTime = 0
lastKeyTime = 0
handledString = ''
def __init__(self):
center_hero()
self.views = [np.array(pg.screenshot())]
tmp = pg.PAUSE
pg.PAUSE = 0.05
self.views.append(np.array(pg.screenshot()))
pg.PAUSE = tmp
self.UI = DotaUI(self.views[-1])
self.reward = 0
self.over_time = self.UI.check_time()
self.hp = self.UI.get_hp()
self.gold = self.UI.get_gold()
self.lvl = self.UI.get_lvl()
self.ability = self.UI.unlock_ability()