Problem with the hook 'main_window_did_init'

I need to run a query to check the due cards. That’s okay and it’s working. However, this code iniates whenever the first anki window opens, not the main window. Meaning if someone has multiple profiles, the code throws an error in the profile choosing window because it’s running a query on a database that hasn’t been chosen yet. How can I fix this and run my code only once the user choses his profile and/or the main window is fully open?

The profile_did_open hook is suitable for these cases.

1 Like