-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanki.py
36 lines (31 loc) · 903 Bytes
/
anki.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import time
import pyautogui
import pyperclip
import sys
_, file_name, deck = sys.argv
with open(file_name, encoding="utf-8") as f:
paragraphs = iter(f.read().split("\n\n"))
questions = ((question, next(paragraphs)) for question in paragraphs)
pyautogui.hotkey("alt", "tab")
time.sleep(1)
for front, back in questions:
pyautogui.hotkey("esc")
pyautogui.typewrite("f")
time.sleep(1)
pyautogui.typewrite("e")
pyperclip.copy(deck)
pyautogui.hotkey("ctrl", "a")
pyautogui.hotkey("ctrl", "v")
pyautogui.hotkey("tab")
pyperclip.copy(front)
pyautogui.hotkey("ctrl", "a")
pyautogui.hotkey("ctrl", "v")
pyautogui.hotkey("tab")
pyperclip.copy(back)
pyautogui.hotkey("ctrl", "a")
pyautogui.hotkey("ctrl", "v")
pyautogui.hotkey("tab")
pyautogui.hotkey("tab")
pyautogui.hotkey("enter")
time.sleep(1)
pyautogui.hotkey("alt", "tab")