Python winsound.Beep() Examples

The following are 15 code examples of winsound.Beep(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module winsound , or try the search function .
Example #1
Source File: very_secret_script.py    From ultra_secret_scripts with GNU General Public License v3.0 7 votes vote down vote up
def beep_on():
    winsound.Beep(2000, 100) 
Example #2
Source File: very_secret_script.py    From ultra_secret_scripts with GNU General Public License v3.0 6 votes vote down vote up
def beep_off():
    winsound.Beep(1000, 100) 
Example #3
Source File: very_secret_script.py    From ultra_secret_scripts with GNU General Public License v3.0 6 votes vote down vote up
def beep_exit():
    winsound.Beep(500, 500) 
Example #4
Source File: Commands.py    From roc with MIT License 6 votes vote down vote up
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() 
Example #5
Source File: pattern_generator.py    From ultra_secret_scripts with GNU General Public License v3.0 5 votes vote down vote up
def beep():
    winsound.Beep(2000, 100) 
Example #6
Source File: pattern_generator.py    From ultra_secret_scripts with GNU General Public License v3.0 5 votes vote down vote up
def beep_exit():
    winsound.Beep(500, 500) 
Example #7
Source File: cnn_daily_load.py    From Bidirectiona-LSTM-for-text-summarization- with MIT License 5 votes vote down vote up
def announcedone():
    duration=2000
    freq=440
    ws.Beep(freq,duration)


########################################################### 
Example #8
Source File: messenger.py    From Crypto-Trading-Bot with MIT License 5 votes vote down vote up
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) 
Example #9
Source File: log_tail_v2.py    From You-are-Pythonista with GNU General Public License v3.0 5 votes vote down vote up
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') 
Example #10
Source File: test_winsound.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_errors(self):
        self.assertRaises(TypeError, winsound.Beep)
        self.assertRaises(ValueError, winsound.Beep, 36, 75)
        self.assertRaises(ValueError, winsound.Beep, 32768, 75) 
Example #11
Source File: test_winsound.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
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 
Example #12
Source File: test_winsound.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_increasingfrequency(self):
        if _have_soundcard():
            for i in xrange(100, 2000, 100):
                winsound.Beep(i, 75) 
Example #13
Source File: e1m1.py    From bfg9000 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _do_play(track):
        for freq, ms in track:
            winsound.Beep(freq, ms) 
Example #14
Source File: Bot.py    From poeai with MIT License 4 votes vote down vote up
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 
Example #15
Source File: recipe-578216.py    From code with MIT License 4 votes vote down vote up
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")