Advertisement
Guest User

randyman

a guest
Feb 19th, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. function Invoke-Sidious{
  2. Add-Type -TypeDefinition @'
  3. using System.Runtime.InteropServices;
  4.  
  5. [Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  6. interface IAudioEndpointVolume {
  7. // f(), g(), ... are unused COM method slots. Define these if you care
  8. int f(); int g(); int h(); int i();
  9. int SetMasterVolumeLevelScalar(float fLevel, System.Guid pguidEventContext);
  10. int j();
  11. int GetMasterVolumeLevelScalar(out float pfLevel);
  12. int k(); int l(); int m(); int n();
  13. int SetMute([MarshalAs(UnmanagedType.Bool)] bool bMute, System.Guid pguidEventContext);
  14. int GetMute(out bool pbMute);
  15. }
  16. [Guid("D666063F-1587-4E43-81F1-B948E807363F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  17. interface IMMDevice {
  18. int Activate(ref System.Guid id, int clsCtx, int activationParams, out IAudioEndpointVolume aev);
  19. }
  20. [Guid("A95664D2-9614-4F35-A746-DE8DB63617E6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  21. interface IMMDeviceEnumerator {
  22. int f(); // Unused
  23. int GetDefaultAudioEndpoint(int dataFlow, int role, out IMMDevice endpoint);
  24. }
  25. [ComImport, Guid("BCDE0395-E52F-467C-8E3D-C4579291692E")] class MMDeviceEnumeratorComObject { }
  26.  
  27. public class Audio {
  28. static IAudioEndpointVolume Vol() {
  29. var enumerator = new MMDeviceEnumeratorComObject() as IMMDeviceEnumerator;
  30. IMMDevice dev = null;
  31. Marshal.ThrowExceptionForHR(enumerator.GetDefaultAudioEndpoint(/*eRender*/ 0, /*eMultimedia*/ 1, out dev));
  32. IAudioEndpointVolume epv = null;
  33. var epvid = typeof(IAudioEndpointVolume).GUID;
  34. Marshal.ThrowExceptionForHR(dev.Activate(ref epvid, /*CLSCTX_ALL*/ 23, 0, out epv));
  35. return epv;
  36. }
  37. public static float Volume {
  38. get {float v = -1; Marshal.ThrowExceptionForHR(Vol().GetMasterVolumeLevelScalar(out v)); return v;}
  39. set {Marshal.ThrowExceptionForHR(Vol().SetMasterVolumeLevelScalar(value, System.Guid.Empty));}
  40. }
  41. public static bool Mute {
  42. get { bool mute; Marshal.ThrowExceptionForHR(Vol().GetMute(out mute)); return mute; }
  43. set { Marshal.ThrowExceptionForHR(Vol().SetMute(value, System.Guid.Empty)); }
  44. }
  45. }
  46. '@
  47. Add-Type -AssemblyName System.Speech
  48.  
  49. # Identify current Mute status and Volume Level
  50. $CurrentMute = [Audio]::Mute
  51. $CurrentVol = [Audio]::Volume
  52.  
  53. # Un-mute if needed
  54. [Audio]::Mute = $False
  55. # If Volume is under 25%, change to 75%
  56. [Audio]::Volume = .25
  57.  
  58. # Intialize voice
  59. $Voice = New-Object System.Speech.Synthesis.SpeechSynthesizer
  60.  
  61. # Get current rate of speech. Probably set to 0(default)
  62. $CurrentRate = $Voice.Rate
  63.  
  64. # Change rate of speech
  65. $Voice.Rate = -2
  66. # Speak
  67.  
  68.  
  69.  
  70.  
  71. $Voice.Speak("Who can take a Computer, Get it to reboot
  72. Cover it with anti virus and a miracle or two
  73. The Randy Man, oh the Randy Man can
  74. The Randy Man can cause he Reboots it with love and makes the world take a pause
  75.  
  76. Who can take a Laptop, Reprogram it with a sigh
  77. Soak it in the sun and make a groovy lemon pie
  78. The Randy Man, the Randy Man can
  79. The Randy Man can cause he Reboots it with love and makes the world take a pause
  80.  
  81. The Randy Man makes everything he Reboots satisfying and delicious
  82. Now you talk about your childhood wishes, Rebooting everything for his missus
  83.  
  84. Oh, who can take tomorrow, dip it in a dream
  85. Separate the sorrow and collect up all the Screams
  86. The Randy Man, oh the Randy Man can
  87. The Randy Man can cause he reboots it with love and makes the world take a pause
  88.  
  89. The Randy Man makes everything he Reboots satisfying and delicious
  90. Talk about your childhood wishes, Rebooting everything for his missus
  91.  
  92. Yeah, yeah, yeah
  93. Who can take tomorrow, dip it in a dream
  94. Separate the sorrow and collect up all the screams
  95. The Randy Man, the Randy Man can
  96. The Randy Man can cause he Reboots it with love and makes the world taste good
  97. Yes, the Randy Man can cause he Reboots it with love and makes the world take a pause
  98. a- Randy Man, a- Randy Man, a- Randy Man
  99. Randy Man, a-Randy Man, a-Randy Man
  100. Randy Man, a-Randy Man, a-Randy Man ")
  101.  
  102. # Change Rate,Volume,Mute values back to what they were set to originally
  103. $Voice.Rate = $CurrentRate
  104. [Audio]::Volume = $CurrentVol
  105. [Audio]::Mute = $CurrentMute
  106.  
  107. # Dispose of voice
  108. $Voice.Dispose()
  109.  
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement