klts

Untitled

Aug 3rd, 2020 (edited)
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'URL of internet radio source
  2. 'strURL = "http://www.bbc.co.uk/radio/player/bbc_radio_two"
  3. strURL = "http://www.internetradiouk.com/bbc-2/"
  4. 'strURL = "http://www.internetradiouk.com/bbc-6/"
  5. 'URL of offline audio file
  6. strMP3 = "C:\Windows\Media\Alarm02.wav"
  7. 'Time in Mins
  8. intWait = 59
  9. 'WLAN Profile Name
  10. strWLANProf = "MySSID"
  11. 'Volume to run at (%)
  12. intVolMax = 90
  13.  
  14. set objShell = createobject("wscript.shell")
  15. set objFSO = createobject("scripting.filesystemobject")
  16.  
  17. strSkip = objfso.GetParentFolderName(WScript.ScriptFullName) & "\SkipNext"
  18.  
  19. if objFSO.fileexists(strSkip) then
  20.     objfso.deletefile strSkip, true
  21.     wscript.quit
  22. end if
  23.  
  24. 'Set system volume to 0, but unmuted
  25. objshell.run "nircmd setsysvolume 0"
  26. objshell.run "nircmd mutesysvolume 0"
  27.  
  28. 'intStopMinute = minute(now) + intWait
  29. 'if intStopMinute >= 60 then intStopMinute = intStopMinute - 60
  30.  
  31. datStopTime = DateAdd("n",intWait,now())
  32.  
  33. 'Reset WLAN (try to fix that annoying issue)
  34. 'objshell.run "cmd.exe /C " & chr(34) & "netsh wlan disconnect" & chr(34),0,true
  35. 'wscript.sleep 2000
  36. 'objshell.run "cmd.exe /C " & chr(34) & "netsh wlan connect " & strWLANProf & chr(34),0,true
  37. 'wscript.sleep 60000
  38.  
  39. 'Find out if we're online
  40. boolOnline = Ping("8.8.8.8")
  41. 'boolonline = false
  42.  
  43. 'Online = internet radio, offline = mp3
  44. if boolOnline = true then
  45.    
  46.     'Create an instance of IE (because it's VB-able), open the internet radio URL
  47.     Set objIE = CreateObject("InternetExplorer.Application")
  48.     objIE.navigate strURL
  49.     objIE.visible = 1
  50.  
  51.     'Wait a while to give it time to load the stream. Reload it because it glitches out occasionally.
  52.     'Do
  53.     'Loop Until objIE.ReadyState = READYSTATE_COMPLETE
  54.     wscript.sleep 5000
  55.     objIE.Refresh
  56.     'Do
  57.     'Loop Until objIE.ReadyState = READYSTATE_COMPLETE
  58.     wscript.sleep 15000
  59.  
  60.     'Gradually increase volume to the limit
  61.     intPercent = 0
  62.     do while not intPercent = intVolMax
  63.         intPercent = intPercent + 1
  64.         intVol = (65535 / 100) * intPercent
  65.         objshell.run "nircmd setsysvolume " & intVol
  66.         wscript.sleep 150
  67.     loop
  68.  
  69.     'Wait for the length of the alarm
  70.     'intCount = intWait
  71.     'do while intCount > 0
  72.     '   wscript.sleep 60000
  73.     '   intCount = intCount - 1
  74.     'loop
  75.  
  76.     'Wait 5 seconds. If we're at or after the stop time, stop.
  77.     do
  78.         wscript.sleep 5000
  79.     loop while now() <= datStopTime
  80.  
  81.     'Close IE
  82.     on error resume next
  83.     objIE.quit
  84. else
  85.     'Set volume to the maximum set
  86.     intVol = (65535 / 100) * intVolMax
  87.     objshell.run "nircmd setsysvolume " & intVol
  88.  
  89.     'Wait a minute
  90.     'wscript.sleep 60000
  91.    
  92.     'Load media player
  93.     Set objWMP = createobject("wmplayer.ocx.7")
  94.     intStop = 0
  95.    
  96.     'Keep playing the mp3, over and over again
  97.     objWMP.url = strMP3
  98.     do while intStop <> 1
  99.         if objwmp.playstate = 1 then
  100.             objWMP.url = strMP3
  101.         elseif objwmp.playstate = 9 then
  102.             intStop = objshell.popup("Stop?",1,"Alarm Clock",&H20 + &H2000)
  103.         end if
  104.  
  105.         'if minute(now) = intStopMinute then intStop = 1
  106.         if now() >= datStopTime then intstop = 1
  107.     loop
  108. end if
  109.  
  110. 'Googled ping function
  111. Function Ping(strHost)
  112.     Dim objSh, strCommand, intWindowStyle, blnWaitOnReturn
  113.  
  114.     blnWaitOnReturn = True
  115.     intWindowStyle = 0
  116.     strCommand = "%ComSpec% /C %SystemRoot%\system32\ping.exe -n 1 " _
  117.     & strHost & " | " & "%SystemRoot%\system32\find.exe /i " _
  118.     & Chr(34) & "TTL=" & Chr(34)
  119.  
  120.     Set objSh = WScript.CreateObject("WScript.Shell")
  121.     Ping = Not CBool(objSh.Run(strCommand, intWindowStyle, blnWaitOnReturn))
  122.     Set objSh = Nothing
  123. End Function
  124.  
Add Comment
Please, Sign In to add comment