160 lines
5.8 KiB
HTML
160 lines
5.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en-us">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<title>PyAutoGUI for simplifying anki routine</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
<link href="https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,400;0,500;0,700;1,300&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://redeyes.club/css/basic.css">
|
|
|
|
|
|
</head>
|
|
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<header class="logo--wrapper">
|
|
<a href="/posts/pyautogui-for-simplifying-anki-routine/"><pre class="logo toilet-logo" title="Home">
|
|
░█▀▄░█░░░█▀█░█▀▀
|
|
░█▀▄░█░░░█░█░█░█
|
|
░▀▀░░▀▀▀░▀▀▀░▀▀▀
|
|
|
|
</pre></a>
|
|
<nav>
|
|
<ul class="page-list">
|
|
|
|
<li class="page-link"><a href="/music/">
|
|
░█▄█░█░█░█▀▀░▀█▀░█▀▀
|
|
░█░█░█░█░▀▀█░░█░░█░░
|
|
░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀▀▀
|
|
|
|
</a></li>
|
|
|
|
<li class="page-link"><a href="/portfolio/">
|
|
░█▀█░█▀█░█▀▄░▀█▀░█▀▀░█▀█░█░░░▀█▀░█▀█
|
|
░█▀▀░█░█░█▀▄░░█░░█▀▀░█░█░█░░░░█░░█░█
|
|
░▀░░░▀▀▀░▀░▀░░▀░░▀░░░▀▀▀░▀▀▀░▀▀▀░▀▀
|
|
|
|
</a></li>
|
|
|
|
<li class="page-link"><a href="/posts/">
|
|
░█▀▄░█░░░█▀█░█▀▀
|
|
░█▀▄░█░░░█░█░█░█
|
|
░▀▀░░▀▀▀░▀▀▀░▀▀▀
|
|
|
|
</a></li>
|
|
|
|
|
|
<li class="page-link"><a href="https://redeyes.club/">░█▄█░█▀█░▀█▀░█▀█░▄▀░░▀▄░
|
|
|
|
░█░█░█▀█░░█░░█░█░█░░░░█░
|
|
░▀░▀░▀░▀░▀▀▀░▀░▀░░▀░░▀░░</a></li>
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
</header>
|
|
|
|
|
|
<main>
|
|
<style>
|
|
audio {height:200px;
|
|
width:300px;
|
|
background-image:url("");
|
|
background-position: center;
|
|
background-size: 550px 425px;
|
|
border-radius: 10px;
|
|
}
|
|
</style>
|
|
<article class="blog-post">
|
|
<h1 class="blog-header">PyAutoGUI for simplifying anki routine</h1>
|
|
<sub><small><time>21.01.2021 10:26</time></small></sub>
|
|
<div>
|
|
<p>I had been adding some cards to Anki.
|
|
It was lowercase word and word with stress in russian. like <em>торты тОрты.</em></p>
|
|
|
|
<p>I’m lazy and i wrote two simple scripts. All what i have to do is input words with stress into a file.<br />
|
|
First script for creating file with list of sequence of word with stress and lowercase word</p>
|
|
|
|
<pre><code class="language-python">import os
|
|
f = open("/home/horhik/text.txt", 'r+')
|
|
lines = f.readlines()
|
|
for ind, line in enumerate(lines):
|
|
print(line.lower(), " ", line)
|
|
</code></pre>
|
|
|
|
<p>After, i just pushed output to file and opened it it Emacs.</p>
|
|
|
|
<p>Second script automatizing adding cards to A<strong>nki</strong>.<br />
|
|
I split my window by <strong>Anki</strong> “add card” window and <strong>Emacs</strong>. As i use <code>evil</code> mode in Emacs, script looks like that:</p>
|
|
|
|
<pre><code class="language-python">import pyautogui
|
|
|
|
import os
|
|
while(True):
|
|
pyautogui.hotkey("winleft", 'j') # toggle window
|
|
pyautogui.press(["v", "$", "y"]) # copy string
|
|
pyautogui.hotkey("winleft", 'j') # toggle window
|
|
pyautogui.hotkey("ctrl", 'v') # past text
|
|
pyautogui.press("tab") # next input field
|
|
pyautogui.hotkey("winleft", 'j') # toggle window
|
|
pyautogui.press(["j","0", "w", "v" , "$", "y", "0", "j", "j" ])
|
|
# move to next line beginning, copy it and go to next occurence
|
|
pyautogui.hotkey("winleft", 'j') # toggle window
|
|
pyautogui.hotkey("ctrl", 'v') # paste text
|
|
pyautogui.press("tab") # ...
|
|
pyautogui.press("tab") # ...
|
|
pyautogui.press("tab") # ...
|
|
pyautogui.press("tab") # ... way to submit button
|
|
pyautogui.press("space") # pressing submit button
|
|
</code></pre>
|
|
|
|
<p><code>while(true)</code> was my mistake. I launched script in terminal, with <code>sleep</code> 3 seconds before.<br />
|
|
But i couldn’t shut script down without any strange effect when i opening not only 2 windows in my Window Manager.<br />
|
|
Some strange things happen before I cached terminal and pressed <code>Ctrl+C</code></p>
|
|
|
|
</div>
|
|
|
|
|
|
</article>
|
|
</main>
|
|
|
|
<footer>
|
|
<ul class="contacts">
|
|
<li><a href="https://github.com/horhik" class=" contact-link" title="github">
|
|
<pre>
|
|
┏━╸╻╺┳╸╻ ╻╻ ╻┏┓
|
|
┃╺┓┃ ┃ ┣━┫┃ ┃┣┻┓
|
|
┗━┛╹ ╹ ╹ ╹┗━┛┗━┛</pre></a></li>
|
|
<li><a href="https://mastodon.ml/web/accounts/74403" class=" contact-link" title="mastodon: @horhik@mastodon.ml">
|
|
<pre>
|
|
┏┳┓┏━┓┏━┓╺┳╸┏━┓╺┳┓┏━┓┏┓╻
|
|
┃┃┃┣━┫┗━┓ ┃ ┃ ┃ ┃┃┃ ┃┃┗┫
|
|
╹ ╹╹ ╹┗━┛ ╹ ┗━┛╺┻┛┗━┛╹ ╹
|
|
|
|
</pre></a></li>
|
|
<li><a href="mailto:horhik@tuta.io" class=" contact-link" title="Mail">
|
|
<pre>
|
|
┏┳┓┏━┓╻╻
|
|
┃┃┃┣━┫┃┃
|
|
╹ ╹╹ ╹╹┗━╸</pre></a></li>
|
|
</ul>
|
|
<p class="copyright">©2021 <a href="https://redeyes.club/">Horhik</a></p>
|
|
</footer>
|
|
|
|
</body>
|
|
</html>
|