How do you run code every minute?

Title pretty much says it all but I will elaborate.

I’ve been desperate for a way to get windows notifications as soon as a card is due so I slapped together some code. I’ve managed to make a button in Anki that sends notifications but to finish it I need a way to run a line of code every minute or so.

Are there any hooks that are already run at fairly constant intervals?
One that runs whenever a card becomes due would also work.

Any help would be appreciated.

1 Like

maybe you can adjust some of this?

I haven’t tried this.

This definitely seems to be what I need and I’ll see if I can figure it out.

That said I really have a miniscule amount of experience so I’m just gonna spitfire some questions before I continue to fumble around for hours.

Would I need to recompile something to edit this or is there a file that I could easily open and edit in the anki installation.

Or could I call that that self.progress.timer fuction from within an addon somehow?

make a new folder 00000 in your addons21 folder. in it make a text file

Put this into the file:

from aqt import mw
from aqt.utils import tooltip

def myfunc()
    tooltip("some message", parent=mw)

mw.progress.timer(15000, myfunc, True)

restart anki.

This should show a tooltip every 15 seconds in the main window


Thanks that’s perfect, I almost had it by the time I read it but I wrote “self.progress.timer” instead so you still ended up saving me.