Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Pick the point dropdown
move_to_et_click(dimension['draw_on_map'])
time.sleep(sleep)
# Draw a counding box for line test
start_point = dimension['map_point']
direction = 80
move_right = (start_point[0] + direction, start_point[1])
move_down = (move_right[0], move_right[1] - direction)
move_left = (move_down[0] - direction, move_down[1])
move_up = (move_left[0], move_left[1] + direction)
move_to_et_click(dimension['map_point'])
move_to_et_click(move_right)
move_to_et_click(move_down)
move_to_et_click(move_left)
move_to_et_click(move_up)
gui.click(move_up)
time.sleep(plot_render_sleep)
gui.alert('Conducting test...', 'Wait', timeout=4000)
# Find expected plot
image_loc = gui.locateCenterOnScreen(
paths['line_index'], confidence=0.3, grayscale=True)
if image_loc is None:
gui.alert(text='Line index not found!', title='UI test', button='OK', timeout=box_timeout)
# Retry the test in case of slow network connection
retry_location_test(paths['line_index'], 'Line Index')
else:
gui.alert(text='Line UI test complete!', title='UI test', button='Close', timeout=box_timeout)
# Close index sub-tab
time.sleep(.30)
gui.click(dimension['close_index'])
def move_et_click(position):
"""
Function to move to a postion and click
*reduce duplicated codes.
"""
gui.moveTo(position)
gui.click()
for key in arg:
pyautogui.keyDown(key)
for key in reversed(arg):
pyautogui.keyUp(key)
s.sendall('[+]Injected keyboard shortcut' + End)
else:
pyautogui.hotkey(arg)
s.sendall('[+]Injected keyboard shortcut' + End)
elif injection_type == 'valids':
tar_list = '|/'.join(valid_keys)
s.sendall(tar_list + End)
elif injection_type == 'click_left':
pyautogui.click(button='left')
s.sendall('[+]Injected left mouse click' + End)
elif injection_type == 'click_right':
pyautogui.click(button='right')
s.sendall('[+]Injected right mouse click' + End)
elif injection_type == 'move_to':
if not arg:
s.sendall('[-]Supply a key as an arg'+End)
return
try:
arg = arg.split(' ')
cord_one = int(arg[0])
cord_two = int(arg[1])
pyautogui.moveTo(x=cord_one, y=cord_two)
s.sendall('[+]Injected mouse movement' + End)
except:
s.sendall('[-]Input X and Y coordinates as integers' + End)
return
elif injection_type == 'dimensions':
dimensions = pyautogui.size()
if x not in BUTTONS:
print('Not found: "{}"'.format(x))
continue
if x in CACHE_POS_BUTTON:
pos = CACHE_POS_BUTTON[x]
else:
file_name = BUTTONS[x]
pos = pyautogui.locateCenterOnScreen(file_name)
if not pos:
continue
CACHE_POS_BUTTON[x] = pos
print(x, pos)
pyautogui.click(pos)
x = px + x
y = py + y
pyautogui.moveTo(x, y, t, pyautogui.easeOutQuad)
return
if t.data == "mouse":
cs = []
for c in t.children:
cs.append(do(c))
pyautogui.moveTo(*cs, pyautogui.easeOutQuad)
return
if t.data == "click":
pyautogui.click()
return
if t.data == "btnclick":
btn = do(t.children[0])
pyautogui.click(button=btn)
return
if t.data == "btndown":
btn = do(t.children[0])
pyautogui.mouseDown(button=btn)
return
if t.data == "btnup":
btn = do(t.children[0])
pyautogui.mouseUp(button=btn)
return
pyautogui.click(1091, 638) #loc of collect offer button 2 hard coded in
time.sleep(0.3)
pyautogui.click(1034, 636) #loc of collect offer button 1 hard coded in
time.sleep(1)
pyautogui.click(pyautogui.locateCenterOnScreen('images/salehistorytab.png'))
time.sleep(2)
#add check here to make sure the item was actually bought using pytesser probs
buy_price = tesser_image(screengrab_as_numpy_array((1179, 427, 1306, 455))) #location of price hard coded in
print(buy_price)
item_to_buy.set_bought_at(buy_price)
time.sleep(1)
pyautogui.click(pyautogui.locateCenterOnScreen('images/grandexchangetab.png'))
time.sleep(2)
pyautogui.click(pyautogui.locateCenterOnScreen('images/sellbag.png', region=(list_of_locations_of_offer_boxes[offer_box_index][0],list_of_locations_of_offer_boxes[offer_box_index][1], list_of_locations_of_offer_boxes[offer_box_index][2], list_of_locations_of_offer_boxes[offer_box_index][3])))
time.sleep(2)
pyautogui.click(1159, 431)#clicking item in inv hard coded
time.sleep(1)
decrease_offer_loc = pyautogui.locateCenterOnScreen('images/-5percbutton.png')
for i in range(random.randint(35,45)):
pyautogui.click(decrease_offer_loc)
time.sleep(random.random()/30)
pyautogui.click(pyautogui.locateCenterOnScreen('images/confirmofferbutton.png'))
#time.sleep(5)
#pyautogui.click(pyautogui.locateCenterOnScreen('images/completedoffer.png', region=(list_of_locations_of_offer_boxes[offer_box_index][0],list_of_locations_of_offer_boxes[offer_box_index][1], list_of_locations_of_offer_boxes[offer_box_index][2], list_of_locations_of_offer_boxes[offer_box_index][3])))
#print(pyautogui.locateCenterOnScreen('images/completedoffer.png', region=(list_of_locations_of_offer_boxes[offer_box_index][0],list_of_locations_of_offer_boxes[offer_box_index][1], list_of_locations_of_offer_boxes[offer_box_index][2], list_of_locations_of_offer_boxes[offer_box_index][3])))
time.sleep(5)
pyautogui.click(pyautogui.locateCenterOnScreen('images/completedoffer.png', region=(list_of_locations_of_offer_boxes[offer_box_index][0],list_of_locations_of_offer_boxes[offer_box_index][1], list_of_locations_of_offer_boxes[offer_box_index][2], list_of_locations_of_offer_boxes[offer_box_index][3])))
time.sleep(3)
pyautogui.click(1091, 638) #loc of collect offer button 2 hard coded in
time.sleep(0.3)
pyautogui.click(1034, 636) #loc of collect offer button 1 hard coded in
time.sleep(1)
ingredButtons = {'1': [500 + winLeft, 220 + winTop], # shrimp
'3': [500 + winLeft, 270 + winTop], # nori
'5': [500 + winLeft, 320 + winTop], # salmon
'4': [550 + winLeft, 270 + winTop], # roe
'6': [550 + winLeft, 220 + winTop]} # unagi
cancelButton = [580 + winLeft, 330 + winTop]
deliveryButton = [500 + winLeft, 300 + winTop]
phoneRegion = [440 + winLeft, 190 + winTop, 200, 200]
# navigate through start screen
pyautogui.click(320 + winLeft, 200 + winTop) # click on Play button
pyautogui.click(300 + winLeft, 380 + winTop) # click on Continue button
pyautogui.click(550 + winLeft, 450 + winTop) # click on Skip
pyautogui.click(300 + winLeft, 380 + winTop) # click on Continue button
pyautogui.click(botWindow) # click back on bot window
def clickIngredients(coordinates):
# click on all the coordinates in the coordinates list, then click the mat
for c in coordinates:
pyautogui.click(c)
pyautogui.click(mat)
def clearPlates():
# clear the plates by clicking on them
for platex in range(80, 581, 100):
pyautogui.click(platex + winLeft, 200 + winTop)
pyautogui.click(botWindow) # put bot window back into focus
# The main program loop will constantly ask the user for a command until
# they enter "quit".
while True:
x, y = self._get_location(direction, location, offset)
try:
clicks = int(clicks)
except ValueError:
raise MouseException('Invalid argument "%s" for `clicks`')
if button not in ['left', 'middle', 'right']:
raise MouseException('Invalid button "%s" for `button`')
try:
interval = float(interval)
except ValueError:
raise MouseException('Invalid argument "%s" for `interval`')
LOGGER.info('Clicking %d time(s) at (%d, %d) with '
'%s mouse button at interval %f' % (clicks, x, y,
button, interval))
ag.click(x, y, clicks=clicks, button=button, interval=interval)
def mouse_click(inx, iny):
pymouse.click(inx, iny)
def wait_for(image, runescape_window):
# adding a possible failsafe in here
time_entered = time.time()
# could add a failsafe in here incase we misclick or something, this
# should be something to come back to
while(True):
found = pyautogui.locateOnScreen(image, region=(runescape_window.top_left_corner[0], runescape_window.top_left_corner[1], runescape_window.bottom_right_corner[
0] - runescape_window.top_left_corner[0], runescape_window.bottom_right_corner[1] - runescape_window.top_left_corner[1]))
if found != None:
break
elif time.time()-time_entered > 5 :
print('We appear to be stuck so attempting to click again and see if this fixes it')
pyautogui.click()
time_entered = time.time()