triggering show answer button by code

daniham's Avatar

daniham

03 Aug, 2019 04:19 PM

Hi friends;
Is there any way to trigger the "show answer" button by code?

  1. 1 Posted by ijg on 08 Aug, 2019 03:54 PM

    ijg's Avatar

    by which code? python or js? for js maybe try pycmd("ans"); (check the source of reviewer.py

  2. 2 Posted by daniham on 08 Aug, 2019 04:00 PM

    daniham's Avatar

    Hi;
    thank you for the reply;
    What I meant was JS. I know a little bit of JS, but I don't know Python.
    Is there any way to do it in JS?
    tanks

  3. 3 Posted by daniham on 08 Aug, 2019 04:03 PM

    daniham's Avatar

    I assume it would be easier to do it in Python. right?

  4. 4 Posted by ijg on 08 Aug, 2019 04:07 PM

    ijg's Avatar

    it's what I wrote: for javascript maybe try pycmd("ans"); (check the source of reviewer.py

    the main window contents, the reviewer and the editor (in the add window, bottom of the browser) are html sites with html buttons. So you can use (and sometimes need) javascript. This javascript communicates with python/the main anki program using the pycmd command.

    With python it should be easier but with javascript it should also work.

  5. 5 Posted by ijg on 08 Aug, 2019 04:08 PM

    ijg's Avatar

    if you use anki 2.1:

    You can now debug the webviews using an external Chrome instance, by setting the env var QTWEBENGINE_REMOTE_DEBUGGING to 8080 prior to starting Anki, then surfing to localhost:8080 in Chrome.

    https://apps.ankiweb.net/docs/addons.html#webview-changes

  6. 6 Posted by daniham on 08 Aug, 2019 04:13 PM

    daniham's Avatar

    Thanks, man;
    I'll give it a try and see if it works.
    my problem with Anki 2.1 is that I use so many add-ons that haven't been updated yet for this version. otherwise, I would use the new version gladly.
    Thank you for your time and quick reply
    best

  7. 7 Posted by ijg on 08 Aug, 2019 04:50 PM

    ijg's Avatar

    in 2.0 it's not pycmd but something like py.link("ans"). I have stopped using 2.0 so I can't say.

    Maybe useful: https://www.reddit.com/r/Anki/comments/c88vww/alternatives_for_21_f...

  8. 8 Posted by daniham on 08 Aug, 2019 04:51 PM

    daniham's Avatar

    Thank you for the update man.
    I appreciate it!

Comments are closed, but you can start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac