설명 없음

ChatGPT-AudioTester.ps1 3.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # Bypass execution policy
  2. if (!(Test-Path -Path "$env:windir\system32\WindowsPowerShell\v1.0\powershell.exe")) {
  3. # PowerShell 2.0 and below
  4. Set-ExecutionPolicy Bypass -Scope Process
  5. } else {
  6. # PowerShell 3.0 and above
  7. powershell.exe -ExecutionPolicy Bypass -Command "&{}"
  8. }
  9. # Import the System.Windows.Forms assembly
  10. Add-Type -AssemblyName System.Windows.Forms
  11. # Create the GUI form
  12. $form = New-Object System.Windows.Forms.Form
  13. $form.Text = "EF Audio Tester"
  14. $form.Width = 300
  15. $form.Height = 150
  16. # Create the Record button
  17. $recordButton = New-Object System.Windows.Forms.Button
  18. $recordButton.Text = "Record"
  19. $recordButton.Width = 75
  20. $recordButton.Height = 25
  21. $recordButton.Location = New-Object System.Drawing.Point(10,10)
  22. $recordButton.Add_Click({
  23. # Code to run when the Record button is clicked
  24. # Play a 400hz beep sound
  25. (New-Object Media.SoundPlayer -ArgumentList "C:\Windows\Media\Windows Notify.wav").PlaySync()
  26. $audioFile = "$env:userprofile\AudioTest.wav"
  27. $audioFile = $audioFile.Replace("\\","\")
  28. $audioFile = $audioFile.Replace("/","\")
  29. $audioFile = [System.IO.Path]::GetFullPath($audioFile)
  30. $audioFile | Add-Member -MemberType NoteProperty -Name Attributes -Value ([System.IO.FileAttributes]::Hidden)
  31. # Record audio from the default audio recording device into the temporary file
  32. $rec = New-Object System.Media.SoundPlayer
  33. $rec.SoundLocation = $audioFile
  34. $rec.Open()
  35. $rec.Play()
  36. })
  37. $form.Controls.Add($recordButton)
  38. # Create the Stop Recording button
  39. $stopButton = New-Object System.Windows.Forms.Button
  40. $stopButton.Text = "Stop Recording"
  41. $stopButton.Width = 75
  42. $stopButton.Height = 25
  43. $stopButton.Location = New-Object System.Drawing.Point(100,10)
  44. $stopButton.Add_Click({
  45. # Code to run when the Stop Recording button is clicked
  46. # Play a 400hz beep sound
  47. (New-Object Media.SoundPlayer -ArgumentList "C:\Windows\Media\Windows Notify.wav").PlaySync()
  48. $rec.Stop()
  49. $rec.Dispose()
  50. })
  51. $form.Controls.Add($stopButton)
  52. # Create the Playback button
  53. $playbackButton = New-Object System.Windows.Forms.Button
  54. $playbackButton.Text = "Playback"
  55. $playbackButton.Width = 75
  56. $playbackButton.Height = 25
  57. $playbackButton.Location = New-Object System.Drawing.Point(190,10)
  58. $playbackButton.Add_Click({
  59. # Code to run when the Playback button is clicked
  60. # Play a 400hz beep sound
  61. (New-Object Media.SoundPlayer -ArgumentList "C:\Windows\Media\Windows Notify.wav").PlaySync()
  62. $audioFile = "$env:userprofile\AudioTest.wav"
  63. $audioFile = $audioFile.Replace("\\","\")
  64. $audioFile = $audioFile.Replace("/","\")
  65. $audioFile = [System.IO.Path]::GetFullPath($audioFile)
  66. # Play the temporary file
  67. (New-Object Media.SoundPlayer -ArgumentList $audioFile).PlaySync()
  68. })
  69. $form.Controls.Add($playbackButton)
  70. # Create the Cleanup button
  71. $cleanupButton = New-Object System.Windows.Forms.Button
  72. $cleanupButton.Text = "Cleanup"
  73. $cleanupButton.Width = 75
  74. $cleanupButton.Height = 25
  75. $cleanupButton.Location = New-Object System.Drawing.Point(10,50)
  76. $cleanupButton.Add_Click({
  77. # Code to run when the Cleanup button is clicked
  78. # Play a 400hz beep sound
  79. (New-Object Media.SoundPlayer -ArgumentList "C:\Windows\Media\Windows Notify.wav").PlaySync()
  80. $audioFile = "$env:userprofile\AudioTest.wav"
  81. $audioFile = $audioFile.Replace("\\","\")
  82. $audioFile = $audioFile.Replace("/","\")
  83. $audioFile = [System.IO.Path]::GetFullPath($audioFile)
  84. # Delete the temporary file
  85. Remove-Item $audioFile -Force
  86. # Display a message indicating that the file has been deleted
  87. [System.Windows.Forms.MessageBox]::Show("AudioTest.wav has been deleted.")
  88. })
  89. $form.Controls.Add($cleanupButton)
  90. # Show the GUI form
  91. $form.ShowDialog() | Out-Null

Powered by TurnKey Linux.