How disable the window of media always-on-top?

Is it possible to make the Anki main window always-on-top, not the media window?
Because I like to learning cards by shortcut keys on my Windows 10 laptop, 1,2,3,4, but on the current version 2.1.49 the media window will be on the top when it auto plays. I tried to search a way to fix it, but none of them worked…

If you haven’t already, it might be worthwhile to test out the Always On Top - AnkiWeb add-on.

Yes, I tried. But it was not what I want.

This addon will make all the windows from Anki always on top, so the media window will be the top over the Anki main window when learning cards.

I also tried AHK, not worked either.

I just want to make the Main window of Anki always on top.

Back in the day, I used to use a software called DeskPins to pin windows on top. Maybe you could give it a shot.

It seems the only way is to set the media window not on top when it pops up… But I did not find where I can set this in Anki.
All the other software or scrips will pin all windows from Anki on top, not only the main window.

You can do that in one line of lua code.

  • Go to anki’s appdata folder, see this link https://docs.ankiweb.net/files.html#file-locations
  • Inside this folder create a new folder named scripts.
  • Click in to scripts, create a new file named notOnTop.lua or anything else end with .lua
  • Open this lua file with any editor, and paste following code:
    mp.set_property_native("ontop", false)
  • Save this file and restart anki.
3 Likes

It worked on my Mac! I really appreciate for your help :smiley: !

I tried it on my Windows10 laptop, unfortunately it did not work…
Is there anything need to take care on Windows than on MacOS?

Just make sure you put the lua script in the right folder:

%APPDATA%\Anki2\scripts

If you don’t have this scripts folder, you need to create it. This worked on my win10.

Yes, I created the scripts folder, and I am using Anki 2.1.60- qt6.


This is weird, we have the same version. Are you using any addons that can manipulate the window?

Below are the addons I installed, none of them can manipulate the window.

Check your addons install folder, is it ...\AppData\Roaming\Anki2\addons21?

Yes, the addons folder is:
C:\Users\****\AppData\Roaming\Anki2\addons21

OK, let’s try one more thing. I think maybe the problem is your mpv player. Go to anki’s install location, check the "Date modifed" of "mpv.exe". See if the mpv is too old because old mpvs didn’t enable lua script.

Recent Anki versions use mpv 0.34 on Windows.

The mpv.exe was updated at 2023-2-22, and the version is 0.34.0.

I can’t see the problem now, but I still have one backup plan. Since your addons work fine, we can download this addon called Advanced MPV Player and modify it’s code to change mpv’s behavior.

First install the addon, then click View Files to open its source folder. And open __int__.py, find this line:

class MpvManager2(MpvManager):

And add one more line under it, make it looks like this:

class MpvManager2(MpvManager):
    MPVBase.default_argv.remove("--ontop")

Save this file and restart anki. Let me know if this works.

3 Likes

It works! Thanks a lot for your patience and help!