I've scripted some *dirty* autokey scripts to incredible fast add new
cards with cloze deletion and images. Maybe this is useful to someone.

Take a look at the videos, to get an imagination of the usage:
http://uru.ch/mnemosyne/screencast_addImage.ogv
http://uru.ch/mnemosyne/screencast_clozeDeletion.ogv

The code for autokey (http://code.google.com/p/autokey/) is here:
http://uru.ch/mnemosyne/addImageCode.txt
http://uru.ch/mnemosyne/clozeDeletionCode.txt

The code of the scripts is also attached below the fold for archival

Br
dandelo

PS. autokey is for linux, if you use windows take a look at autohotkey
(http://www.autohotkey.com/)

--
#
# AutoKey (http://code.google.com/p/autokey/) script for mnemosyne
written by dandelo <[email protected]>
#
# function of this script: prepares an image flashcard from a selected
file browser item
# saving something: no, just prepares the Q and A fields
# prerequisites: mnemosyne is running, add cards dialog is open,
cursor is placed in question field, the target image file is marked in
the file browser window
#

import time

time.sleep(0.1)
#change focus to filename and copy to answer
keyboard.send_key("<f2>")
time.sleep(0.1)
answer = clipboard.get_selection()
#mark whole filename and copy to fiename
keyboard.send_keys("<ctrl>+a")
time.sleep(0.1)
filename = clipboard.get_selection()
#change to path
keyboard.send_keys("<ctrl>+l<home>")
#unmark leading path to make relative: /home/mindestens/.mnemosyne/
(28 Chars)
for i in range(1, 4):
    keyboard.send_keys("<ctrl>+<right>")
keyboard.send_keys("<right><shift>+<end>")
time.sleep(0.1)
relativePath = clipboard.get_selection()
#change window to Add cards
window.activate("Add cards")
if window.wait_for_focus("Add cards"):
    #wrap img code anfang um link: <img src="
    keyboard.send_keys("<img src=\"")
    #paste relativePath/
    keyboard.send_keys("%s/" % relativePath)
    #paste filename
    keyboard.send_keys("%s" % filename)
    #wrap img code ende um link: ">
    keyboard.send_keys("\">")
    #change focus to answer and paste answer, then change focus to 0
field
    keyboard.send_keys("<tab>%s<tab><tab>" % answer)


#
# AutoKey (http://code.google.com/p/autokey/) script for mnemosyne
written by dandelo <[email protected]>
#
# function of this script: produces a cloze deletion flashcard by
taking the selected text as question
# saving something: yes, saves the card and returns to gedit
# prerequisites: mnemosyne is running, add cards dialog is open, text
is prepared in gedit and the desired cloze text is marked
#
import time

#collect question and answer
time.sleep(0.1)
answer = clipboard.get_selection()
keyboard.send_key("<delete>")
keyboard.send_keys("...")
keyboard.send_keys("<ctrl>+a")
time.sleep(0.1)
question = clipboard.get_selection()
# change window focus to add cars
window.activate("Add cards")
if window.wait_for_focus("Add cards"):
     keyboard.send_keys("%s" % question)
     keyboard.send_key("<tab>")
     keyboard.send_keys("%s" % answer)
     # save the card (there is a space after the two tabs
     keyboard.send_keys("<tab><tab> ")
# return to gedit and undo twice
window.activate("gedit")
if window.wait_for_focus(".*gedit"):
    keyboard.send_keys("<ctrl>+z")
    keyboard.send_keys("<ctrl>+z")

-- 
You received this message because you are subscribed to the Google Groups 
"mnemosyne-proj-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/mnemosyne-proj-users?hl=en.

Reply via email to