Allow file explorer in Microsoft.Web.WebView2.WinForms.WebView2 - vb.net

I have a Winforms app with a webview but the file explorer do not open when fired inside the webview (works fine on browser) i alredy tried the following :
Dim oEnvironment As Microsoft.Web.WebView2.Core.CoreWebView2Environment
Dim opts As CoreWebView2EnvironmentOptions = New CoreWebView2EnvironmentOptions()
'opts.AdditionalBrowserArguments = "--allow-file-access-from-files"
opts.AdditionalBrowserArguments = "--disable-web-security"
oEnvironment = Await Microsoft.Web.WebView2.Core.CoreWebView2Environment.CreateAsync(String.Empty, System.IO.Path.GetTempPath(), opts)
Await browser.EnsureCoreWebView2Async(environment:=oEnvironment)
The page do nor return any error.
How can i give permissions to open that?
Update:
I have a file picker like this below, if i drag and drop the files it works, if i click "Browse" nothing appen in the webview (on browser all woks fine)

Related

Selenide can't download PDF

I had some trouble using Selenide's download function. This is my flow:
click on button
button opens new tab which shows pdf file and url is:
blob:https://hostname.apps.something.else/9365b3ab-f0ad-45e9-85d2-db7e2fb5fd2e
So basically the new tab is opened in Chrome PDF Viewer.
I tried to click on the hidden download button in the new tab but no luck.
My thinking got me to the idea of when I click that button, this new tab shouldn't open, the download should start. That would mean settings some Configuration preferences like I did below:
Configuration.browserCapabilities = new DesiredCapabilities();
Configuration.browserSize = "1920x1080";
Configuration.fileDownload = FileDownloadMode.FOLDER;
Configuration.downloadsFolder = "./src/pdfs";
Configuration.proxyHost = "30.40.34.82";
Configuration.proxyPort = 8080;
Configuration.proxyEnabled = true;
Configuration.fileDownload = FileDownloadMode.PROXY;
Configuration.browserCapabilities.setCapability("plugins.always_open_pdf_externally", true);
Configuration.browserCapabilities.setCapability("download.prompt_for_download", false);
Configuration.browserCapabilities.setCapability("pdfjs.disabled", true);
The problem is that, this still opens new tab, and I get no such element found
File file = applicationList.printButton.download(30000);
Why do you first set Configuration.fileDownload to FOLDER and then to PROXY? No need to set it twice.
I think you cannot download the file via PROXY because links of type blob: don't fetch file content from the server.
I think you can just remove all these lines:
Configuration.proxyHost = "30.40.34.82";
Configuration.proxyPort = 8080;
Configuration.proxyEnabled = true;
Configuration.fileDownload = FileDownloadMode.PROXY;
Configuration.browserCapabilities.setCapability("plugins.always_open_pdf_externally", true);
Configuration.browserCapabilities.setCapability("download.prompt_for_download", false);
Configuration.browserCapabilities.setCapability("pdfjs.disabled", true);
Selenide method FOLDER should download the file without all these tricky settings.
Try it
System.setProperty("chromeoptions.prefs", "plugins.always_open_pdf_externally=true")

Open Camera app installed from a UWP app and capture image

Instead of creating a Windows built-in camera UI (CameraCaptureUI) or using a custom MediaCapture control and capture picture I want to open any Camera App downloaded in the device to capture an image and get the result.
I have used
string uriToLaunch = "microsoft.windows.camera:";
var uri = new Uri(uriToLaunch);
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
But this just opens the camera app, I need to get the result file back to the app and save it.
Is there a way to do this?
The method you are using:
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
just opens the default camera, nothing more, the result is a boolean with information if the application has been opened successfully, nothing more.
With CameraCaptureUI you don't need to create camera - this seems to be designed for the task like you have described. With lines:
var captureUI = new CameraCaptureUI();
captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;
captureUI.PhotoSettings.CroppedSizeInPixels = new Size(200, 200);
var photo = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo);
you just launch the camera app and your app waits for the photo, which you can process further/save.
If you don't want to use it or implement own camera capture, you can think of sharing a picture taken by other app. This is described well at app-to-app communication at MSDN. In this case user will have to click Share button and choose your app as a target. That will invoke OnShareTargetActivated event where you can process the received content.

Can't use a title's Class to automate Windows file upload using AutoIt

I am trying to use AutoIt for Windows file upload. I am clicking a browse button which will open file upload popup. I want AutoIt to type the location of the file and click open.
I need to use FF, Chrome, and IE for testing. I am able to get this to work if I use the Title, but the problem is that each browser has a different title. I would like to use class, as it is #32700 for all browsers. I've tried using class instead of the title, but its not working.
When I use title, everything works fine. Below is an example for Firefox. In this script, the file name is entered and open is clicked.
ControlFocus("File Upload","","Edit1")
ControlSetText("File Upload", "", "Edit1", "SomeFile.txt")
ControlClick("File Upload", "","Button1");
When I try to use class, text is not being entered and the open button is not getting clicked. There are no errors in the AutoIt script editor, so I'm not sure why this isn't working.
ControlFocus("[CLASS:#32770]","","Edit1")
ControlSetText("[CLASS:#32770]", "", "Edit1", "SomeFile.txt")
ControlClick("[CLASS:#32770]", "","Button1");
I've also tried to add all three browser titles to 1 AutoIt script. The below script is working for Firefox and IE, but doesn't do anything in Chrome.
Local $OrgFile = "SomeFile.csv"
Local $ControlIDText = "Edit1"
Local $ControlIDButton = "Button1"
Local $Title_FF = "File Upload"
Local $Title_Chrome = "Open"
Local $Title_IE = "Choose File to Upload"
;Firefox Import
ControlFocus($Title_FF,"",$ControlIDText)
ControlSetText($Title_FF, "", $ControlIDText, $OrgFile)
ControlClick($Title_FF, "",$ControlIDButton);
;Chrome Import
ControlFocus($Title_Chrome,"",$ControlIDText)
ControlSetText($Title_Chrome, "", $ControlIDText, $OrgFile)
ControlClick($Title_Chrome, "",$ControlIDButton);
;IE Import
ControlFocus($Title_IE,"",$ControlIDText)
ControlSetText($Title_IE, "", $ControlIDText, $OrgFile)
ControlClick($Title_IE, "",$ControlIDButton);
You need to set WinTitleMatchMode option to 4 if you want to use advanced title matching (eg. CLASS).
#RequireAdmin ;Will give your script a permission elevation (sometimes its needed)
Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
ControlFocus("[CLASS:#32770]","","Edit1")
ControlSetText("[CLASS:#32770]", "", "Edit1", "SomeFile.txt")
ControlClick("[CLASS:#32770]", "","Button1");

c# on button click open pdf in new tab insted of downloading

I have a .aspx page and it has a button on click of which a radwindow opens .The radwindow has a new page with content including a button onclick of which a pdf is created and downloaded.I want the pdf to open in a new tab or window , so i made changes to my code -changed attachment to inline
Hashtable deviceInfo = new Hashtable();
deviceInfo.Add("FontEmbedding", "Subset");
deviceInfo.Add("DocumentTitle", String.Format("TrackitManager - {0}", reportToExport.DocumentName));
deviceInfo.Add("DocumentAuthor", "Trackit Systems Pty Ltd");
ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, deviceInfo);
if (String.IsNullOrEmpty(filename))
filename = result.DocumentName;
context.Response.Clear();
context.Response.ContentType = result.MimeType;
context.Response.Cache.SetCacheability(HttpCacheability.Private);
context.Response.Expires = -1;
context.Response.Buffer = true;
//context.Response.TransmitFile("~/Handlers/EnrollmentPDF.ashx");
context.Response.AppendHeader("Content-Disposition", string.Format("attachment; filename=\"{0}.pdf\"", filename));
context.Response.BinaryWrite(result.DocumentBytes);
context.Response.End();
But this is opening the pdf inside the radwindow itself.I want it to open in a new window but outside the radwindow.
you have to give the correct header and mimeType to tell the browser to download the file
for that you just have to add this line to replace :
context.Response.ContentType = result.MimeType;
by this line :
Response.ContentType = "application/octectstream";

Adding a new tab in a web brower supplied with VFP that uses the IE control

I am using a class supplied with VFP that uses the IE7 control _webview to open up a web browser and it does not have a function to add a new tab withen the browser , if I am clicking on link in a current page it will open it in IE , is there a way that the new page should open up on the foxpro browser ,
and How can I add a new tab in the browser for a new search
also is there a class that will open up a web browser in foxpro based on a more updated internet broweser
There is no tab in the control. you need to create new tabs in response of the NewWindow2 event from the webbrowser control, put a new webbrowser control on the tab, then tell the event that the new webbrowser control should be used to display the new window. Your event handler looks like this:
LPARAMETERS ppdisp, cancel
*creating new tab
newTab.ADDOBJECT("Olecontrol1", "OLEControl", "shell.explorer.2")
With newTab
.olecontrol1.Top = 0
.olecontrol1.Width = .Width
.olecontrol1.Left = 0
.olecontrol1.Height = .Height
.olecontrol1.visible = .T.
.olecontrol1.RegisterAsBrowser = .T.
.Visible = .T.
Endwith
ppDisp = newTab.olecontrol1.Object
By default the webbrowser control operates in IE7 mode. To opt-in to a new version, add a FEATURE_BROWSER_EMULATION registry key in your program's installer.