Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def pasteIntoTextField(value, removePreviousContents=True, useClipboard=True, layout="de"):
"""
@brief paste value into current text field
"""
print(value)
# remove previous content
if removePreviousContents:
typeTwoKeys('ctrl', 'a')
time.sleep(DELAY_KEY)
if useClipboard:
# use copy & paste (due problems with certain characters, for example '|')
pyperclip.copy(value)
pyautogui.hotkey('ctrl', 'v')
else:
pyautogui.typewrite(translateKeys(value, layout))
def NumberProcess(start, inputLastPageList):
for page in range(start, len(NumberList), 2):
pyautogui.hotkey('ctrl', 'p', interval = 0.25)
pyautogui.press('tab', 2, interval = 0.25)
pyautogui.press('delete', 5, interval = 0.25)
pyautogui.typewrite(NumberList[page], interval = 0.25)
pyautogui.press('tab', interval = 0.25)
pyautogui.press('delete', 5, interval = 0.25)
pyautogui.typewrite(NumberList[page + 1])
pyautogui.typewrite(['tab', 'tab', 'enter', 'enter'], interval = 0.75)
pyautogui.typewrite("File2", interval = 0.5)
pyautogui.press('enter', interval = 0.5)
time.sleep(5)
while (os.path.isfile(filedir + "Ebook.pdf") != True):
time.sleep(2)
while (os.path.isfile(filedir + "File2.pdf") != True):
time.sleep(2)
try:
pdf1File = open(filedir + 'Ebook.pdf', 'rb')
pdf2File = open(filedir + 'File2.pdf', 'rb')
except:
while (os.path.isfile(filedir + Ebook.pdf) != True):
time.sleep(10)
while (os.path.isfile(filedir + File2.pdf) != True):
time.sleep(10)
try:
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(item_completed.bought_at)
item_completed.set_bought_at(buy_price)
print(item_completed.bought_at)
time.sleep(1)
pyautogui.click(pyautogui.locateCenterOnScreen('images/grandexchangetab.png'))
time.sleep(1)
pyautogui.click(pyautogui.center(pyautogui.locateOnScreen('images/sellbag.png', region=(item_completed.box_loc))))
time.sleep(1)
pyautogui.click(1159, 431) #location of item in inv
time.sleep(1)
pyautogui.click(987, 524) #location of price box hard coded
time.sleep(1)
pyautogui.typewrite(str(item_completed.bought_at), interval=random.random()/4)
time.sleep(1)
pyautogui.press('enter')
time.sleep(3)
pyautogui.click(pyautogui.center(pyautogui.locateOnScreen('images/allbutton.png')))
time.sleep(3)
pyautogui.click(pyautogui.locateCenterOnScreen('images/confirmofferbutton.png'))
time.sleep(1)
item_to_buy.set_bought_at(item_to_buy.bought_at - 1)
item_to_buy.set_sold_at(item_to_buy.sold_at + 1)
print(string_of_item,'values used are now bought at', item_to_buy.bought_at, 'sold at', item_to_buy.sold_at)
#time to turn a profit
pyautogui.click(buy_bag_loc[0], buy_bag_loc[1])
time.sleep(2)
pyautogui.typewrite(string_of_item, interval=random.random()/4)
time.sleep(2)
pyautogui.click(pyautogui.locateCenterOnScreen(item_to_buy.image_path))
time.sleep(1)
pyautogui.click(727, 524) #location of quantity box hard coded
time.sleep(1)
#finding a number to buy that fits our cash stack. This could be done better with keeping track of our cash stack and spending it accordingly buying some cheap and expensive items at the same time
item_to_buy.set_number_to_buy(int(min(item_to_buy.available_to_buy, (amount_of_money/item_to_buy.sold_at)/len(list_of_locations_of_offer_boxes))))
amount_of_money -= item_to_buy.number_to_buy*item_to_buy.sold_at
pyautogui.typewrite(str(item_to_buy.number_to_buy), interval=random.random()/4)
#pyautogui.typewrite(str(item_to_buy.limit), interval=0.25) the way that worked@@@@@@@@@@@@
time.sleep(1)
pyautogui.press('enter')
time.sleep(3)
pyautogui.click(987, 524) #location of price box hard coded
time.sleep(1)
pyautogui.typewrite(str(item_to_buy.sold_at), interval=random.random()/4)
time.sleep(1)
pyautogui.press('enter')
time.sleep(3)
pyautogui.click(pyautogui.locateCenterOnScreen('images/confirmofferbutton.png'))
print('amount of money', amount_of_money)
item_to_buy.set_time_placed_buy_offer_at(time.time())
time.sleep(5)
in_use_boxes.append(list_of_locations_of_offer_boxes[offer_box_index])
item_to_buy.set_box_containing_item(list_of_locations_of_offer_boxes[offer_box_index])
os.remove(filedir + 'File2.pdf')
os.rename(filedir + 'Ebook1.pdf', filedir + 'Ebook.pdf')
print("Page: " + str(page + 2) + ' of ' + str(len(RomanBookList)))
print("\nRoman Numerals Done\n")
else:
PageEntry1 = NumberList[0]
PageEntry2 = NumberList[1]
pyautogui.hotkey('ctrl', 'p')
pyautogui.press(keys = 'tab', presses = 2, interval = 0.25)
pyautogui.press('delete', 5)
pyautogui.typewrite(PageEntry1)
pyautogui.press('tab')
pyautogui.press('delete', 5)
pyautogui.typewrite(PageEntry2)
pyautogui.typewrite(['tab', 'tab', 'enter', 'enter'], interval = 0.25 )
pyautogui.typewrite("Ebook", interval = 0.50)
pyautogui.press('enter', interval = 0.5)
time.sleep(0.25)
def NumberProcess(start):
for page in range(start, len(NumberList), 2):
pyautogui.hotkey('ctrl', 'p', interval = 0.25)
pyautogui.press('tab', 2, interval = 0.25)
pyautogui.press('delete', 5, interval = 0.25)
pyautogui.typewrite(NumberList[page], interval = 0.25)
pyautogui.press('tab', interval = 0.25)
pyautogui.press('delete', 5, interval = 0.25)
pyautogui.typewrite(NumberList[page + 1])
pyautogui.typewrite(['tab', 'tab', 'enter', 'enter'], interval = 0.75)
pyautogui.typewrite("File2", interval = 0.5)
def locate_gmail():
#Sleep for a while and wait for Firefox to open
time.sleep(2)
# Printing message
msg(1,'Opening Gmail...')
# Typing the website on the browser
pyautogui.keyDown('ctrlleft'); pyautogui.typewrite('a'); pyautogui.keyUp('ctrlleft')
pyautogui.typewrite('https://accounts.google.com/SignUp?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F<mpl=default')
pyautogui.typewrite('\n')
# Wait for a while until the website responds
time.sleep(3)
# Print a simple message
msg(1,'Locating the form...')
# Locate the form
_gmail_=pyautogui.locateOnScreen('images/gmail_form.png')
_form_=pyautogui.center(_gmail_)
# Check and print message
if not pyautogui.click(_form_):
msg(1,'Located the form.')
else:
def prepare_dota_client():
while True:
if _is_dota_launched():
_focus_dota_window()
break
else:
gui.click(x=STEAM_LIBRARY['x'], y=STEAM_LIBRARY['y'], pause=PAUSE)
gui.click(x=STEAM_SEARCH['x'], y=STEAM_SEARCH['y'])
game_search_name = 'dota'
for i in range(len(game_search_name)):
gui.press('backspace')
gui.typewrite(game_search_name, interval=TYPEWRITE_INT)
if not __wait_until_image_is_displayed('images/dota_is_found.png'):
continue
gui.click(x=STEAM_PLAY['x'], y=STEAM_PLAY['y'], pause=30)
calibrate_dota_client()
start_game()
break
pyautogui.typewrite(_password_+'\t'+_password_+'\t')
msg(2,'\x1b[0;33;40mPassword:\x1b[0m %s' % _password_)
# Date of birth
_month_=randomize('-m',1)
_day_=randomize('-d',1)
_year_=randomize('-y',1)
pyautogui.typewrite(_month_+'\t'+str(_day_)+'\t'+str(_year_)+'\t')
msg(2,'\x1b[0;33;40mDate of birth:\x1b[0m %s/%d/%d' % (_month_,_day_,_year_))
# Gender (set to 'Rather not say')
pyautogui.typewrite('R\t')
msg(2,'\x1b[0;33;40mGender:\x1b[0m Rather not say')
# Skip the rest
pyautogui.typewrite('\t\t\t\t\n')
pyautogui.typewrite(['tab', 'tab', 'enter', 'enter'], interval = 0.25 )
pyautogui.typewrite("Ebook", interval = 0.50)
pyautogui.press('enter', interval = 0.5)
time.sleep(0.25)
print("Page: " + '1' + ' of ' + str(len(RomanBookList) ))
for page in range(2, len(RomanBookList), 2):
pyautogui.hotkey('ctrl', 'p', interval = 0.25)
pyautogui.press('tab', 2, interval = 0.25)
pyautogui.press('delete', 6, interval = 0.25)
pyautogui.typewrite(RomanBookList[page], interval = 0.25)
pyautogui.press('tab', interval = 0.25)
pyautogui.press('delete', 6, interval = 0.25)
pyautogui.typewrite(RomanBookList[page + 1])
pyautogui.typewrite(['tab', 'tab', 'enter', 'enter'], interval = 0.75)
pyautogui.typewrite("File2", interval = 0.5)
pyautogui.press('enter', interval = 0.5)
while (os.path.isfile(filedir + "Ebook.pdf") != True):
time.sleep(2)
while (os.path.isfile(filedir + "File2.pdf") != True):
time.sleep(2)
try:
pdf1File = open(filedir + 'Ebook.pdf', 'rb')
pdf2File = open(filedir + 'File2.pdf', 'rb')
except:
while (os.path.isfile(filedir + Ebook.pdf) != True):
time.sleep(10)
while (os.path.isfile(filedir + File2.pdf) != True):
time.sleep(10)
try: #not ideal handling , but it works. A bug that yields OSError(22, 'Invalid argument') should be investigated
pdf1Reader = PyPDF2.PdfFileReader(pdf1File)
'Mithril arrow', 'Teak plank', 'Thread', 'Oak plank', 'Dark arrow', 'Grimy dwarf weed', 'Dragon arrowheads', 'Grimy lantadyme', 'Airut bones', 'Gleaming energy',
'Infernal ashes', 'Frost dragon bones', 'Living minerals', 'Chitin scraps', 'Green dragon leather', 'Red chinchompa', 'Rune arrowheads', 'Clean lantadyme', 'Rune essence', 'Raw tuna',
'Hydrix bolt tips', 'Yew seed', 'Palm tree seed', 'Teleport to house', 'Wine of Zamorak', 'Potion flask', 'Prayer potion (4)', 'Super restore (4)', 'Saradomin brew (4)',
'Aggression potion (4)', 'Prayer renewal (4)']
list_of_file_names = []
for i in range(len(list_of_items)):
list_of_file_names.append(list_of_items[i].replace(' ', '_')+'.png')
for i in range(len(list_of_items)):
file_name_1 = 'screenshots/items/nxt_items/'+list_of_file_names[i]
file_name_2 = 'screenshots/temp_items/'+list_of_file_names[i]
if os.path.isfile(file_name_1):
print('file exists', file_name_1)
continue
x = len(list_of_items[i])
pyautogui.typewrite(list_of_items[i], random.random()/10)
time.sleep(4)
pyautogui.screenshot(file_name_2, region=(box_2_coords))
for x in range(x):
pyautogui.press('backspace')
time.sleep(random.random()/10)
time.sleep(1)