Created
August 20, 2022 19:14
-
-
Save Riduidel/ea0739acb134cc51ea355bc9453e0829 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import codecs | |
import json | |
import pyautogui | |
import pyperclip | |
def main(): | |
words = list() | |
with codecs.open("words.txt", "r", "utf-8") as f: | |
words = f.readlines() | |
for text in words: | |
# Don't forget this prefix is the pin prefix, not the classical one | |
text_field_location_prefix = pyautogui.locateOnScreen("pedantix_word_text_field_prefix.png") | |
if not text_field_location_prefix: | |
raise Exception("Can't find the pinned prefix. Is the pedantix window unpinned?") | |
text_field_location_suffix = pyautogui.locateOnScreen("pedantix_word_text_field_suffix.png") | |
if not text_field_location_prefix: | |
raise Exception("Unable to locate prefix") | |
if not text_field_location_suffix: | |
raise Exception("Unable to locate suffix") | |
x = (text_field_location_prefix.left+text_field_location_suffix.left+text_field_location_suffix.width)/2 | |
y = (text_field_location_prefix.top+text_field_location_suffix.top+text_field_location_suffix.height)/2 | |
# print("Prefix is at %s\nSuffix is at %s\nSeems like text field should be at (%d, %d)" % | |
# (text_field_location_prefix, text_field_location_suffix, x, y)) | |
text = text.strip() | |
pyautogui.click(x, y) | |
# Mind you, pyautogui only handle keyboard keys, and not french accents | |
# So I prefer to copy word in clipboard, then paste it | |
print("Testing \"%s\""%(text)) | |
pyperclip.copy(text) | |
pyautogui.click() | |
pyautogui.hotkey("ctrl", "v") | |
pyautogui.press('enter') | |
def handle_accents(letter): | |
if letter in REPLACEMENTS: | |
REPLACEMENTS[letter] | |
else: | |
letter | |
if __name__ == "__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment