Windows 사용자의 경우 ANKI SRS의 음악 피들러 추가 기능을 조정하려고합니다. Anki는 pyw가 아닌 .py로 끝나는 추가 기능 만 실행합니다. 코드를 실행할 때 자동으로 팝업되는 콘솔을 숨길 수있는 방법이 있습니까?py-file 전용 (pyw 없음) [ANKI add-on]
그렇지 않은 경우, 콘솔 창을 선택 취소 할 수있는 방법이 없습니다 (기본적으로 다시 닫힌 콘솔이 선택 항목이기 때문에 5 초마다 기본 anki 창을 클릭해야합니다).
내가 창을 여는 지금까지 사용하는 명령은, 예를 들면 : os.system을 (' "nircmd.exe changesysvolume"'+ 변경)
전체 코드는 아래는 콘솔이 nircmd.exe를 실행 시스템 사운드가 변경되어야하는 볼륨 단위의 수입니다. 코드를 조정할 수 있습니까?
# -*- coding: utf-8 -*-
# Music-Fiddler (a plugin for Anki)
# coded by D_Malik, [email protected]
# Version 1
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
"""
A simple plugin that fiddles with music volume to reinforce quick reviewing.
Before using:
- This plugin was made for Linux. It will require modification to work on another OS.
- Ensure that the "amixer" command works on your computer. If it doesn't, you're going to need to modify the code somehow. Don't ask me how.//Amixer has been replaced by nircmd.exe for windows
- Change all lines (in the plugin source) marked with "CHANGEME" according to your preferences.
"""
import os
from aqt import mw
from aqt.utils import showInfo
from os import system
from aqt.qt import *
from anki.hooks import addHook
def resetMusicTimer():
"Boosts volume back up and starts the music timer."
#CHANGEME: The next lines are a python dictionary associating deck names with times (in milliseconds) between volume-decrements.
#Eg, when using the deck "brainscience", volume will decrement every 5 seconds. When using a deck without a listed name, "other" is used.
#Change this according to your decks. Decks with shorter, easier cards need less time.
deckMusicTimes = {
"rocketsurgery" : 3000,
"brainscience" : 5000,
"other" : 5000,
}
if mw.col.decks.current()['name'] in deckMusicTimes:
mw.musicTimeToDecrement = deckMusicTimes[mw.col.decks.current()['name']]
else:
mw.musicTimeToDecrement = deckMusicTimes["other"]
boostMusicVolume()
mw.musicTimer = QTimer(mw)
mw.musicTimer.setSingleShot(True)
mw.musicTimer.start(mw.musicTimeToDecrement)
mw.connect(mw.musicTimer, SIGNAL("timeout()"), decrementMusicVolume)
#showInfo(mw.state)
def changeMusicVolume(change):
"Changes volume according to string; can be either absolute ('40') or change ('2%-')."
os.system('"nircmd.exe changesysvolume"'+ change) #CHANGEME somehow, if amixer doesn't work
def boostMusicVolume():
#showInfo("boosted") #To test changes, you can uncomment this line.
os.system('"nircmd.exe changesysvolume 50000"') #CHANGEME somehow, if amixer doesn't work
#CHANGEME: Set to however high you want your volume to go each time it's boosted back.
#Protip: your music-playing program might have its own "volume multiplier" that you can adjust easily.
def killMusicVolume():
#showInfo("killed") #To test changes, you can uncomment this line.
os.system('"nircmd.exe mutesysvolume 1"') #CHANGEME somehow, if amixer doesn't work
#CHANGEME: Set to how low volume should go when it dies, eg due to undoing a card.
def decrementMusicVolume():
"When reviewing, decrements volume, then sets a timer to call itself. When not reviewing, kills volume and stops timer."
if mw.state == "review":
#showInfo("music volume goes down") #To test changes, you can uncomment this line.
os.system('"nircmd.exe changesysvolume -5000"') #CHANGEME somehow, if amixer doesn't work
mw.musicTimer.start(mw.musicTimeToDecrement) #(start the timer again)
else:
killMusicVolume()
mw.musicTimer = None #(kill the timer if you're not reviewing)
addHook("showQuestion", resetMusicTimer)