本文整理汇总了Python中winsound.Beep方法的典型用法代码示例。如果您正苦于以下问题:Python winsound.Beep方法的具体用法?Python winsound.Beep怎么用?Python winsound.Beep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类winsound
的用法示例。
在下文中一共展示了winsound.Beep方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_work
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def do_work(self):
sleep(3)
coord = ImageCoordinate.is_on_screen(
'images/is_antibot_active')
if coord:
winsound.Beep(2500, 1500)
print('Antibot! Antibot! Antibot!')
clicker.click(coord)
if ImageCoordinate.is_on_screen('images/verify_button'):
print('Verify the bot test please')
coord = ImageCoordinate.coords('images/verify_button')
clicker.click(coord)
sleep(10)
usethis = ImageCoordinate.is_on_screen('images/usethis')
confirmgee = ImageCoordinate.is_on_screen('images/confirmgee')
print(usethis)
print(confirmgee)
solvegee(usethis, confirmgee)
else:
print('Verification is not required. Continue...')
else:
print('Bot test is not active, continue playing game.')
self.next()
示例2: main
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def main():
while 1:
try:
os.system("CLS")
os.system("COLOR 07")
print("\n\n\n\n\n\n\n\n\n\n\n ")
time.sleep(0.05)
os.system("CLS")
os.system("COLOR 08")
print("\n\n\n\n\n\n\n\n\n\n\n This is a test string to check fading...")
time.sleep(0.05)
os.system("CLS")
os.system("COLOR 07")
print("\n\n\n\n\n\n\n\n\n\n\n This is a test string to check fading...")
time.sleep(0.05)
os.system("CLS")
os.system("COLOR 0F")
print("\n\n\n\n\n\n\n\n\n\n\n This is a test string to check fading...")
time.sleep(0.05)
os.system("CLS")
os.system("COLOR 07")
print("\n\n\n\n\n\n\n\n\n\n\n This is a test string to check fading...")
time.sleep(0.05)
os.system("CLS")
os.system("COLOR 08")
print("\n\n\n\n\n\n\n\n\n\n\n This is a test string to check fading...")
time.sleep(0.05)
except KeyboardInterrupt: break
while 1:
try:
os.system("COLOR C0")
os.system("CLS")
print("\n\n\n\n\n\n\n\n\n\n\n DANGER!!!")
winsound.Beep(1333,600)
os.system("COLOR 0C")
os.system("CLS")
print("\n\n\n\n\n\n\n\n\n\n\n DANGER!!!")
winsound.Beep(1000,600)
except KeyboardInterrupt: break
os.system("COLOR 0F")
os.system("CLS")
示例3: beep_on
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def beep_on():
winsound.Beep(2000, 100)
示例4: beep_off
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def beep_off():
winsound.Beep(1000, 100)
示例5: beep_exit
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def beep_exit():
winsound.Beep(500, 500)
示例6: beep
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def beep():
winsound.Beep(2000, 100)
示例7: announcedone
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def announcedone():
duration=2000
freq=440
ws.Beep(freq,duration)
###########################################################
示例8: play_beep
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def play_beep(self, frequency=1000, duration=1000):
"""
Used to play a beep sound
:param frequency: The frequency of the beep
:type frequency: int
:param duration: The duration of the beep
:type duration: int
"""
if not self.sound or winsound is None:
return
winsound.Beep(frequency, duration)
示例9: window
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def window(q, handler, interval, width):
"""
滑动窗口,显示数据
:param q: 接收队列数据(本来是source,接收单条,引入队列后,持续接受
:param handler: 处理数据
:param interval: 多久处理一次
:param width: 每次处理多少行日志
"""
# 窗口初始化时间
start_time = datetime.datetime.now()
datas = []
while True:
try:
data = q.get_nowait()
# data = q.get()
except Exception:
data = None
if data:
datas.append(data)
# 当前时间-开始时间 > 时间间隔 应该更新窗口内容
current_time = datetime.datetime.now() # 当前时间
if (current_time - start_time).seconds >= interval:
print('*' * 10+' Start monitor the log. '+'*' * 10+'\n')
# 更新时间
start_time = current_time
# 处理数据
# 每次处理列表中的前 width 个数据
for i in range(width):
log = handler(datas.pop(0))
print('remote:{0}|| datetime:{1}\nmethod:{2}|| url:{3} || protocol:{4}\nstatus:{5}|| size:{6}\nreferences: {7}\nuseragent:{8}\n'
.format(log['remote'].ljust(15), log['datetime'], log['request']['method'].ljust(15), log['request']['url'].ljust(15), log['request']['protocol'], log['status'].ljust(15), log['size'], log['references'], log['useragent']))
# 判断访问是否成功,否则报警,并停顿5秒
if int(log['status']) > 200:
winsound.Beep(600, 1000)
# 其中600表示声音大小,1000表示发生时长,1000为1秒
time.sleep(5)
print('=' * 10+' OVER! wait for a moment.'+'=' * 10+'\n')
示例10: test_errors
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def test_errors(self):
self.assertRaises(TypeError, winsound.Beep)
self.assertRaises(ValueError, winsound.Beep, 36, 75)
self.assertRaises(ValueError, winsound.Beep, 32768, 75)
示例11: test_extremes
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def test_extremes(self):
if _have_soundcard():
winsound.Beep(37, 75)
winsound.Beep(32767, 75)
else:
# The behaviour of winsound.Beep() seems to differ between
# different versions of Windows when there's either a) no
# sound card entirely, b) legacy beep driver has been disabled,
# or c) the legacy beep driver has been uninstalled. Sometimes
# RuntimeErrors are raised, sometimes they're not. Meh.
try:
winsound.Beep(37, 75)
winsound.Beep(32767, 75)
except RuntimeError:
pass
示例12: test_increasingfrequency
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def test_increasingfrequency(self):
if _have_soundcard():
for i in xrange(100, 2000, 100):
winsound.Beep(i, 75)
示例13: _do_play
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def _do_play(track):
for freq, ms in track:
winsound.Beep(freq, ms)
示例14: Run
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import Beep [as 别名]
def Run(self):
if not self.sv.GetHWND(self.wname): #Get the window handle for the game
print("Failed to find window.")
self.Start()
cv, M_ITER = 0, 64 #Counter value and max number of loops
while True:
if cv >= M_ITER and self.state != Const.HOME0:
self.state = Const.HOME0
cv = 0
if self.state == Const.HOME0 and cv >= M_ITER:
break
OBS, ECP, MOV, LW, PH, PM = self.ts.ProcessScreen(*self.sv.GetScreenWithPrev())
if (PH < Const.HLOW).any(): #Life is lower than 75%; use potion
self.UseHealthPotion()
if (PM < Const.MLOW).any(): #Mana is lower than 25%; user potion
self.UseManaPotion()
MSF = self.UpdatePosition(LW)
if MSF == Const.MOVE_INPR: #Bot is still moving; don't try to move now
#print('Moving.')
time.sleep(0.01)
continue
self.UpdateState(MSF == Const.MOVE_OKAY, (PH < Const.HLOW).any(), MSF == Const.MOVE_FAIL, (ECP & MOV).sum() > 0)
print(Const.STN[self.state])
if MSF == Const.MOVE_OKAY: #If LW is predicted to be occuring
cv += 1
print("Moved to: " + str(self.cpe))
#winsound.Beep(600, 250)
elif MSF == Const.MOVE_FAIL:
print("Move Failed.")
#winsound.Beep(440, 250)
elif MSF == Const.MOVE_NONE:
print("Not moving")
else:
print("Move Unknown.")
WP, PP = self.pm.GridIter() #Update map with current predictions
PPCI = self.ts.PixelToCell(PP)
CPCT, IGC = self.ts.CellLookup(PPCI)
for i, IGCi, in enumerate(IGC):
self.mm.InsertCell(WP[IGCi], CPCT[i], (not self.ts.IsEdgeCell(*PPCI[IGCi])) or (CPCT[i] == Const.PL_C))
#Check for items on the screen. Doesn't work well!!
#self.PickupItem()
if self.state == Const.ATCK0 or self.state == Const.ATCK1:
self.Attack() #Attack if in appropriate state
continue #Don't try to move in attacking state
if self.state == Const.EVAD0:
self.Evade()
continue
if self.PathDone(): #If there is no route current; find a new path
if self.state == Const.HOME0 and self.mm.AtHome():
self.ClickOnDoor() #Back to start
#elif self.pt == 1:
# self.PickupItem() #Pickup item on screen
self.GetPath()
OWP, OPP = WP[IGC], PP[IGC]
ci = np.square(OWP - self.p).sum(axis = 1).argmin()
self.cpe, l2d = OWP[ci], OPP[ci]
#Get pixel location on screen of 3d cell to go to
l2d = tuple(int(k) for k in l2d.round())
self.GoToPosition(l2d) #Perform lightning-warp