Geckobrowser dediğiniz Firefox tarafından geliştirilen GeckoDriver mı?
Eğer öyleyse bir yöntem Firefox profili oluşturup içerisine dosya sormayı engelleyecek ayar ekleyebilirsiniz.
Diğer yöntem ise JS kodu çalıştırarak otomatik dosya soran fonksiyonu manipüle edebilirsiniz.
Hangi dilde çalıştığınızı yazarsanız daha net yardımcı olabilirim.
Tekrar merhaba
c# ile masa üstü programı yazıyorum. Evet firefox'un tabanını kullanan gecko Browser 'i kullanıyorum.
c# da açık olan formlara bakıyorum file upload görünmüyor, açık olan exe lere bakıyorum orada da görünmüyor.
Aşağıda ki kod bloğu file upload açıkken uploader i kullanmadan direkt olarak siteye istediğim resmi gönderiyor. Bu sayede file upload a gerek kalmıyor.
Lakin file upload açık kaldığı için forma geri dönüpte ileri gidemiyorum.
Bahsettiğim kod şu ;
GeckoHtmlElement el = geckoWebBrowser1.DomDocument.GetElementsByTagName( "input").FirstOrDefault(elz => elz.GetAttribute("type") == "file");
var fileNames = new IntPtr[1];
string path = System.IO.Path.GetDirectoryName(Assembly.GetExecut ingAssembly().Location);
string ana = Path.Combine(path, "Resimler");
string spec_folder_source = Path.Combine(path, ana);
string gelenResim = "1.jpg";
string sonuc = Path.Combine(spec_folder_source, gelenResim);
fileNames[0] = new Gecko.CustomMarshalers.WStringMarshaler().MarshalM anagedToNative(sonuc);
//fileNames[0] = new Gecko.CustomMarshalers.WStringMarshaler().MarshalM anagedToNative(@"C:UsersuserpcDesktopinstaroitinst aroitbinDebugProfil6.jpg");
var domInput = Xpcom.QueryInterface<nsIDOMHTMLInputElement>(el.DO MHtmlElement);
domInput.MozSetFileNameArray(fileNames, (uint)fileNames.Length);
Marshal.ReleaseComObject(domInput);
DomEventArgs ev = geckoWebBrowser1.Document.CreateEvent("HTMLEvents" );
var webEvent = new Event(geckoWebBrowser1.Window.DomWindow, ev.DomEvent as nsISupports);
webEvent.InitEvent("change", true, true);
el.GetEventTarget().DispatchEvent(ev);
Sorunu 1 hafta sonunda nihayet çözdüm
WEbbrowser içinde açılan bir file upload ı kapatmak isteyen arkadaşlar olursa çözüm şu;
public static void Execute()
{
// Enumerate windows to find dialogs
EnumThreadWndProc callback = new EnumThreadWndProc(checkWindow);
EnumThreadWindows(GetCurrentThreadId(), callback, IntPtr.Zero);
GC.KeepAlive(callback);
}
private static bool checkWindow(IntPtr hWnd, IntPtr lp)
{
// Checks if <hWnd> is a Windows dialog
StringBuilder sb = new StringBuilder(260);
GetClassName(hWnd, sb, sb.Capacity);
if (sb.ToString() == "#32770")
{
// Close it by sending WM_CLOSE to the window
SendMessage(hWnd, 0x0010, IntPtr.Zero, IntPtr.Zero);
}
return true;
}
private delegate bool EnumThreadWndProc(IntPtr hWnd, IntPtr lp);
[DllImport("user32.dll")]
private static extern bool EnumThreadWindows(int tid, EnumThreadWndProc callback, IntPtr lp);
[DllImport("kernel32.dll")]
private static extern int GetCurrentThreadId();
[DllImport("user32.dll")]
private static extern int GetClassName(IntPtr hWnd, StringBuilder buffer, int buflen);
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
File upload ı kapatmak istediğiniz kod bloğuna Execute(); yazmanız yeterli olacaktır.
Ben 1 hafta uğraştım, aynı sorunu yaşayanlar çabucak bu sorunu aşsın diye paylaşıyorum