1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | $codigo=' [DllImport("user32.dll", EntryPoint = "FindWindowEx")]public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("User32.dll")]public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam); ' Start-Process wordpad $acciones=Add-Type -MemberDefinition $codigo -Name Texto -PassThru [void][reflection.assembly]::loadwithpartialname('system.speech') $rec = New-Object 'System.Speech.Recognition.SpeechRecognitionEngine' $rec.RecognizerInfo.Description $rec.LoadGrammar((New-Object 'System.Speech.Recognition.DictationGrammar')) $rec.SetInputToWaveFile("C:\Users\PROFESOR\Downloads\1618332743341.wav") do { $cadena=$rec.Recognize().Text $cadenaconvert=[String]$cadena.ToString() $almacenarcadena=$almacenarcadena+$cadenaconvert $almacenarcadena $hwd=(Get-Process wordpad | Select-Object Name,MainWindowHandle).MainWindowHandle $acciones::SendMessage([IntPtr]$acciones::FindWindowEx($hwd, [IntPtr]::Zero, "RICHEDIT50W", $null), 0x000C, 0, $almacenarcadena) }while($rec.AudioFormat) |