I am starting an application from my Blazor server side app.
Normally if this application is started manually, there comes a dialog box and I have to press to an “OK” button. After pressing the button the app continues working.
When I start the app from my C# app, the application runs unavoidable in the background and waits again for the confirmation.But there is no interface (dailog box) any more visible.
How can I confirm this dialog box, that is no more visible, programatically in my code?
I have following code for starting the application:
public void SDB()
{
Process_Backup = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = app_path,
Arguments = "",
CreateNoWindow = false
}
};
Process_Backup.Start();
//code needed for confirming the hidden dialog box
}
Update-1:
I have written following Javascript interop code to my host.cshtml of my Blazor server side app, but have problem with bringing the app in the background to foreground:
public async Task SDB()
{
Process_Backup = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = app_path,
Arguments = "",
CreateNoWindow = false
}
};
Process_Backup.Start();
await JS.InvokeVoidAsync("simulateKeyPress", "enter");
}
added code in host.cshtml (injected in my razor page)
<script>
window.simulateKeyPress = function (key) {
window.focus();
var event = new KeyboardEvent('keydown', { key: key });
document.dispatchEvent(event);
};
</script>
5