Hi,
I’m creating my first add-on, and I need some help, please.
I want to have a file executed every time I finish revising a deck and get to the congratulations screen. Furthermore, I want that the file opens, and then window focus immediately goes back to the Anki window.
For now, I have this working:
import os
from aqt import gui_hooks
import win32gui
import time
def myfunc():
window_hwnd = win32gui.GetForegroundWindow()
os.startfile("C:\Program Files (x86)\Hourglass\Hourglass2.exe.lnk")
time.sleep(0.25)
win32gui.SetForegroundWindow(window_hwnd)
gui_hooks.reviewer_will_end.append(myfunc)
The only problem is that it also activates when I go directly from the review screen to the decks screen.
I tried to get inspiration from the Confetti add-on (link to the relevant code line), because it does have the behavior that I want. But, it’s too difficult for me to understand. It uses _show_finished_screen
, but I don’t know how to use it.
Please, help.
Thanks,