Skip to content

Instantly share code, notes, and snippets.

@Burekasim
Created April 13, 2020 13:42
Show Gist options
  • Save Burekasim/877a8374c1c48aea5c8b5207759a5a9c to your computer and use it in GitHub Desktop.
Save Burekasim/877a8374c1c48aea5c8b5207759a5a9c to your computer and use it in GitHub Desktop.
Namecode
import pyautogui
from time import sleep
from pynput.mouse import Button, Controller
import random
import string
# generate random file name
def randomString(stringLength=10):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))
# required for MacOS
mouse = Controller()
# use this with your mouse to get the positions for namecode pdf file
# while True:
# print(pyautogui.position())
# sleep(1)
# namecode pdf positions
position = {'a': [[481, 286], [448, 237]],
'b': [[444, 448], [435, 391]],
'c': [[441, 594], [430, 555]],
'd': [[437, 754], [437, 716]],
'e': [[652, 769], [683, 710]],
'f': [[700, 606], [696, 562]],
'g': [[687, 431], [686, 382]],
'h': [[693, 277], [695, 224]],
'i': [[954, 231], [947, 282]],
'j': [[943, 383], [942, 440]],
'k': [[941, 556], [941, 604]],
'l': [[953, 706], [954, 761]],
'm': [[1202, 232], [1207, 279]],
'n': [[1196, 377], [1200, 452]],
'o': [[1191, 551], [1197, 610]],
'p': [[1194, 727], [1198, 765]]}
words = '/path/to/word_file'
with open(words, 'r') as words2:
for iiiii in range(25):
for k, pos in position.items():
for worda in words2:
# move to first word position
pyautogui.moveTo(x=pos[0][0], y=pos[0][1])
mouse.click(Button.left)
pyautogui.write(worda)
# move to second word position
pyautogui.moveTo(x=pos[1][0], y=pos[1][1])
mouse.click(Button.left)
pyautogui.write(worda)
break
# Browser - PRINT
pyautogui.hotkey('command', 'p')
sleep(0.6)
# Browser - Save as PDF
pyautogui.hotkey('enter')
sleep(0.8)
# Browser - Type random name file
pyautogui.write('a' + randomString(3))
sleep(0.8)
# Browser - Save the pdf
pyautogui.hotkey('enter')
sleep(0.6)
# Browser - Refresh screen
pyautogui.hotkey('command', 'r')
sleep(1.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment