private bool InitCEF() { Cef.EnableHighDPISupport(); var exitCode = Cef.ExecuteProcess(); if (exitCode >= 0) { return(false); } scheme = new CefCustomScheme() { DomainName = "local.com", IsCorsEnabled = false, IsCSPBypassing = true, IsSecure = false, SchemeName = "http", SchemeHandlerFactory = new AppScheme(Program.BasePath, "http://local.com") }; settings = new CefSettings() { RemoteDebuggingPort = 54477, IgnoreCertificateErrors = true, }; settings.RegisterScheme(scheme); CefSharpSettings.WcfEnabled = true; CefSharpSettings.WcfTimeout = TimeSpan.FromSeconds(10); CefSharpSettings.LegacyJavascriptBindingEnabled = true; Cef.Initialize(settings); return(true); }
private void bunifuImageButton1_Click(object sender, EventArgs e) { try { chrom.Reload(); } catch (Exception) { } Cef.ExecuteProcess(); Cef.Shutdown(); Process currentProcess = Process.GetCurrentProcess(); string pid = (currentProcess.Id).ToString(); System.Diagnostics.Process f_r4 = new System.Diagnostics.Process(); f_r4.StartInfo.FileName = "cmd.exe"; f_r4.StartInfo.RedirectStandardInput = true; f_r4.StartInfo.RedirectStandardOutput = true; f_r4.StartInfo.CreateNoWindow = true; f_r4.StartInfo.UseShellExecute = false; f_r4.Start(); f_r4.StandardInput.WriteLine("cd/ & cd windows & cd system32 & TASKKILL.exe /F /pid " + pid); f_r4.StandardInput.Flush(); f_r4.StandardInput.Close(); //this.Close(); }
public static int Main(string[] args) { //Until https://bitbucket.org/chromiumembedded/cef/issues/1995/ is resolved it's nessicary to //deal with the spawning of the crashpad process here as it's not possible to configure which exe it uses var exitCode = Cef.ExecuteProcess(); //crashpadHandlerExitCode will be -1 for normal process execution, only when running as a subprocess will it be greater if (exitCode >= 0) { return(exitCode); } Console.WriteLine("This example application will load {0}, take a screenshot, and save it to your desktop.", TestUrl); Console.WriteLine("You may see a lot of Chromium debugging output, please wait..."); Console.WriteLine(); // You need to replace this with your own call to Cef.Initialize(); CefExample.Init(true, multiThreadedMessageLoop: true, browserProcessHandler: new BrowserProcessHandler()); MainAsync("cachePath1", 1.0); //Demo showing Zoom Level of 3.0 //Using seperate request contexts allows the urls from the same domain to have independent zoom levels //otherwise they would be the same - default behaviour of Chromium //MainAsync("cachePath2", 3.0); // We have to wait for something, otherwise the process will exit too soon. Console.ReadKey(); // Clean up Chromium objects. You need to call this in your application otherwise // you will get a crash when closing. Cef.Shutdown(); //Success return(0); }
public static int Main(string[] args) { const bool simpleSubProcess = false; Cef.EnableHighDPISupport(); //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process. //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function if (simpleSubProcess) { var exitCode = Cef.ExecuteProcess(); if (exitCode >= 0) { return(exitCode); } #if DEBUG if (!System.Diagnostics.Debugger.IsAttached) { MessageBox.Show("When running this Example outside of Visual Studio" + "please make sure you compile in `Release` mode.", "Warning"); } #endif var settings = new CefSettings(); settings.BrowserSubprocessPath = "CefSharp.WinForms.Example.exe"; Cef.Initialize(settings); var browser = new XForm(); Application.Run(browser); } else { #if DEBUG if (!System.Diagnostics.Debugger.IsAttached) { MessageBox.Show("When running this Example outside of Visual Studio" + "please make sure you compile in `Release` mode.", "Warning"); } #endif const bool multiThreadedMessageLoop = true; var browser = new XForm(); IBrowserProcessHandler browserProcessHandler; browserProcessHandler = new BrowserProcessHandler(); CefInitialization.Init(osr: false, multiThreadedMessageLoop: multiThreadedMessageLoop, browserProcessHandler: browserProcessHandler); Application.Run(browser); } return(0); }
public static void ShutDown(bool sleep = true) { Cef.GetGlobalRequestContext()?.Dispose(); Cef.Shutdown(); Cef.ExecuteProcess(); if (!sleep) { return; } Thread.Sleep(150); }
public static int Main(string[] args) { //For self hosted BrowserSubProcess this must be the first thing out application executes var exitCode = Cef.ExecuteProcess(); if (exitCode >= 0) { return(exitCode); } var app = new App(); var win = new MainWindow(); //Do WPF init and start windows message pump. return(app.Run(win)); }
public static int Main(string[] args) { //Until https://bitbucket.org/chromiumembedded/cef/issues/1995/ is resolved it's nessicary to //deal with the spawning of the crashpad process here as it's not possible to configure which exe it uses //When running from within VS and using the vshost process you'll see an error in the log and this won't get called. var crashpadHandlerExitCode = Cef.ExecuteProcess(); //crashpadHandlerExitCode will be -1 for normal process execution, only when running as a subprocess will it be greater if (crashpadHandlerExitCode >= 0) { return(crashpadHandlerExitCode); } var application = new App(); application.InitializeComponent(); return(application.Run()); }
private static void initCef() { Cef.ExecuteProcess(); CefSettings settings = new CefSettings(); // Set BrowserSubProcessPath based on app bitness at runtime settings.BrowserSubprocessPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, Environment.Is64BitProcess ? "x64" : "x86", "CefSharp.BrowserSubprocess.exe"); settings.FocusedNodeChangedEnabled = true; if (!Cef.IsInitialized) //Cef should only initialized once { Cef.Initialize(settings, false, null); } Cef.EnableHighDPISupport(); CefSharpSettings.LegacyJavascriptBindingEnabled = true; }
public static int Main(string[] args) { const bool simpleSubProcess = false; //Until https://bitbucket.org/chromiumembedded/cef/issues/1995/ is resolved it's nessicary to //deal with the spawning of the crashpad process here as it's not possible to configure which exe it uses //When running from within VS and using the vshost process you'll see an error in the log and this won't get called. var crashpadHandlerExitCode = Cef.ExecuteProcess(); //crashpadHandlerExitCode will be -1 for normal process execution, only when running as a subprocess will it be greater if (crashpadHandlerExitCode >= 0) { return(crashpadHandlerExitCode); } Cef.EnableHighDPISupport(); //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process. //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function if (simpleSubProcess) { var exitCode = Cef.ExecuteProcess(); if (exitCode >= 0) { return(exitCode); } #if DEBUG if (!System.Diagnostics.Debugger.IsAttached) { MessageBox.Show("When running this Example outside of Visual Studio" + "please make sure you compile in `Release` mode.", "Warning"); } #endif var settings = new CefSettings(); settings.BrowserSubprocessPath = "CefSharp.WinForms.Example.exe"; Cef.Initialize(settings); var browser = new SimpleBrowserForm(); Application.Run(browser); } else { #if DEBUG if (!System.Diagnostics.Debugger.IsAttached) { MessageBox.Show("When running this Example outside of Visual Studio" + "please make sure you compile in `Release` mode.", "Warning"); } #endif const bool multiThreadedMessageLoop = true; var browser = new BrowserForm(multiThreadedMessageLoop); //var browser = new SimpleBrowserForm(); //var browser = new TabulationDemoForm(); IBrowserProcessHandler browserProcessHandler; if (multiThreadedMessageLoop) { browserProcessHandler = new BrowserProcessHandler(); } else { //Get the current taskScheduler (must be called after the form is created) var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); browserProcessHandler = new WinFormsBrowserProcessHandler(scheduler); } CefExample.Init(osr: false, multiThreadedMessageLoop: multiThreadedMessageLoop, browserProcessHandler: browserProcessHandler); Application.Run(browser); } return(0); }
public static int Main(string[] args) { const bool simpleSubProcess = false; Cef.EnableHighDPISupport(); //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process. //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function if (simpleSubProcess) { var exitCode = Cef.ExecuteProcess(); if (exitCode >= 0) { return(exitCode); } #if DEBUG if (!System.Diagnostics.Debugger.IsAttached) { MessageBox.Show("When running this Example outside of Visual Studio " + "please make sure you compile in `Release` mode.", "Warning"); } #endif var settings = new CefSettings(); settings.BrowserSubprocessPath = "CefSharp.WinForms.Example.exe"; Cef.Initialize(settings); var browser = new SimpleBrowserForm(true); Application.Run(browser); } else { #if DEBUG if (!System.Diagnostics.Debugger.IsAttached) { MessageBox.Show("When running this Example outside of Visual Studio " + "please make sure you compile in `Release` mode.", "Warning"); } #endif //When multiThreadedMessageLoop = true then externalMessagePump must be set to false // To enable externalMessagePump set multiThreadedMessageLoop = false and externalMessagePump = true const bool multiThreadedMessageLoop = true; const bool externalMessagePump = false; var browser = new BrowserForm(multiThreadedMessageLoop); //var browser = new SimpleBrowserForm(multiThreadedMessageLoop); //var browser = new TabulationDemoForm(); IBrowserProcessHandler browserProcessHandler; if (multiThreadedMessageLoop) { browserProcessHandler = new BrowserProcessHandler(); } else { if (externalMessagePump) { //Get the current taskScheduler (must be called after the form is created) var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); browserProcessHandler = new ScheduleMessagePumpBrowserProcessHandler(scheduler); } else { //We'll add out WinForms timer to the components container so it's Diposed browserProcessHandler = new WinFormsBrowserProcessHandler(browser.Components); } } var settings = new CefSettings(); settings.MultiThreadedMessageLoop = multiThreadedMessageLoop; settings.ExternalMessagePump = externalMessagePump; CefExample.Init(settings, browserProcessHandler: browserProcessHandler); Application.Run(browser); } return(0); }
public static int Main(string[] args) { const bool simpleSubProcess = false; Cef.EnableHighDPISupport(); //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process. //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function if (simpleSubProcess) { var exitCode = Cef.ExecuteProcess(); if (exitCode >= 0) { return(exitCode); } #if DEBUG if (!System.Diagnostics.Debugger.IsAttached) { MessageBox.Show("When running this Example outside of Visual Studio" + "please make sure you compile in `Release` mode.", "Warning"); } #endif var settings = new CefSettings(); settings.BrowserSubprocessPath = "CefSharp.WinForms.Example.exe"; Cef.Initialize(settings); var browser = new SimpleBrowserForm(); Application.Run(browser); } else { #if DEBUG if (!System.Diagnostics.Debugger.IsAttached) { MessageBox.Show("When running this Example outside of Visual Studio" + "please make sure you compile in `Release` mode.", "Warning"); } #endif const bool multiThreadedMessageLoop = true; CefExample.Init(false, multiThreadedMessageLoop: multiThreadedMessageLoop); if (multiThreadedMessageLoop == false) { //http://magpcss.org/ceforum/apidocs3/projects/%28default%29/%28_globals%29.html#CefDoMessageLoopWork%28%29 //Perform a single iteration of CEF message loop processing. //This function is used to integrate the CEF message loop into an existing application message loop. //Care must be taken to balance performance against excessive CPU usage. //This function should only be called on the main application thread and only if CefInitialize() is called with a CefSettings.multi_threaded_message_loop value of false. //This function will not block. Application.Idle += (s, e) => Cef.DoMessageLoopWork(); } var browser = new BrowserForm(); //var browser = new SimpleBrowserForm(); //var browser = new TabulationDemoForm(); Application.Run(browser); } return(0); }
public static int Main() { const bool simpleSubProcess = true; //AppDomain.CurrentDomain.AppendPrivatePath("CEF"); //增加DLL搜索路径 Cef.EnableHighDPISupport(); //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process. //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function if (simpleSubProcess) { var exitCode = Cef.ExecuteProcess(); if (exitCode >= 0) { return(exitCode); } //#if DEBUG // if (!System.Diagnostics.Debugger.IsAttached) // { // MessageBox.Show("When running this Example outside of Visual Studio" + // "please make sure you compile in `Release` mode.", "Warning"); // } //#endif IMClient.Controls.StaticClass.XMPPCrack(); var settings = new CefSettings(); //settings.LocalesDirPath = Application.StartupPath + @"\CEF\locales"; //settings.BrowserSubprocessPath = "NetDLims.exe"; //settings.BrowserSubprocessPath = "CefSharp.BrowserSubprocess.exe"; settings.MultiThreadedMessageLoop = true; settings.AcceptLanguageList = "zh-CN"; settings.CachePath = "caches"; //加上特定版本的FLASH支持 settings.Locale = "zh-CN"; //settings.CefCommandLineArgs.Add("ppapi-flash-path", Application.StartupPath + "\\CEF\\PepperFlash\\pepflashplayer.dll"); //指定flash的版本,不使用系统安装的flash版本 //settings.CefCommandLineArgs.Add("ppapi-flash-version", "22.0.0.192"); bool ret = Cef.Initialize(settings, true, false); //var browser = new SimpleBrowserForm(); //Application.Run(browser); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Program.MainWindow = new BaseTemplateForm(); AppDomain.CurrentDomain.SetData("MainWindow", Program.MainWindow); Application.Run(Program.MainWindow); } else { //#if DEBUG // if (!System.Diagnostics.Debugger.IsAttached) // { // MessageBox.Show("When running this Example outside of Visual Studio" + // "please make sure you compile in `Release` mode.", "Warning"); // } //#endif const bool multiThreadedMessageLoop = true; //CefExample.Init(false, multiThreadedMessageLoop: multiThreadedMessageLoop); if (multiThreadedMessageLoop == false) { //http://magpcss.org/ceforum/apidocs3/projects/%28default%29/%28_globals%29.html#CefDoMessageLoopWork%28%29 //Perform a single iteration of CEF message loop processing. //This function is used to integrate the CEF message loop into an existing application message loop. //Care must be taken to balance performance against excessive CPU usage. //This function should only be called on the main application thread and only if CefInitialize() is called with a CefSettings.multi_threaded_message_loop value of false. //This function will not block. Application.Idle += (s, e) => Cef.DoMessageLoopWork(); } //var browser = new BrowserForm(); //var browser = new SimpleBrowserForm(); //var browser = new TabulationDemoForm(); //Application.Run(browser); } return(0); }
public static int Main(string[] args) { const bool simpleSubProcess = false; Cef.EnableHighDPISupport(); string externalDomain = "http://10.0.106.33:8081"; //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process. //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function if (simpleSubProcess) { var exitCode = Cef.ExecuteProcess(); if (exitCode >= 0) { return(exitCode); } #if DEBUG if (!System.Diagnostics.Debugger.IsAttached) { MessageBox.Show("When running this Example outside of Visual Studio" + "please make sure you compile in `Release` mode.", "Warning"); } #endif var settings = new CefSettings(); settings.BrowserSubprocessPath = "AgileBrowser.WinForms.exe"; Cef.Initialize(settings); var browser = new SimpleBrowserForm(externalDomain); Application.Run(browser); } else { #if DEBUG if (!System.Diagnostics.Debugger.IsAttached) { MessageBox.Show("When running this Example outside of Visual Studio" + "please make sure you compile in `Release` mode.", "Warning"); } #endif const bool multiThreadedMessageLoop = true; var browser = new BrowserForm(multiThreadedMessageLoop, externalDomain); //var browser = new SimpBrowserForm(externalDomain); //var browser = new TabulationDemoForm(externalDomain); IBrowserProcessHandler browserProcessHandler; if (multiThreadedMessageLoop) { browserProcessHandler = new BrowserProcessHandler(); } else { //Get the current taskScheduler (must be called after the form is created) var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); browserProcessHandler = new WinFormsBrowserProcessHandler(scheduler); } AgileBrowser.Init(osr: false, multiThreadedMessageLoop: multiThreadedMessageLoop, browserProcessHandler: browserProcessHandler, externalDomain: externalDomain); Application.Run(browser); } return(0); }
public static int Main(string[] args) { System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es-419"); Application.ThreadException += new ExceptionHandler().ApplicationThreadException; AppDomain.CurrentDomain.UnhandledException += new ExceptionHandler().DomainUnhandledException; InitiateLogging(); Cef.EnableHighDPISupport(); //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process. //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function int exitCode = Cef.ExecuteProcess(); if (exitCode >= 0) { return(exitCode); } //var browser = new BrowserForm(multiThreadedMessageLoop); //var browser = new SimpleBrowserForm(); //var browser = new TabulationDemoForm(); //var browser = new ToolbarFormBrowser(); FormTabbedMDIBrowser browser = new FormTabbedMDIBrowser(); IBrowserProcessHandler browserProcessHandler; if (multiThreadedMessageLoop) { browserProcessHandler = new BrowserProcessHandler(); } else { //Get the current taskScheduler (must be called after the form is created) TaskScheduler scheduler = TaskScheduler.FromCurrentSynchronizationContext(); browserProcessHandler = new WinFormsBrowserProcessHandler(scheduler); } // cache path //To get the location the assembly normally resides on disk or the install directory string path = System.Reflection.Assembly.GetExecutingAssembly().CodeBase; string directory = Path.GetDirectoryName(path); string localpath = new Uri(directory).LocalPath; if (!Directory.Exists(localpath)) { Directory.CreateDirectory(localpath); } // need to make default/first cache folder localpath += "\\cachetab1"; if (!Directory.Exists(localpath)) { Directory.CreateDirectory(localpath); } CefSettings cefsetting = new CefSettings { MultiThreadedMessageLoop = multiThreadedMessageLoop, ExternalMessagePump = !multiThreadedMessageLoop, AcceptLanguageList = "es-419, es;q=0.8", Locale = "es", IgnoreCertificateErrors = true, UserAgent = userAgentWin10, CachePath = localpath, }; #if DEBUG cefsetting.LogSeverity = LogSeverity.Verbose; LogInfo("Running .exe Debug Version"); #else cefsetting.LogSeverity = LogSeverity.Error; #endif Cef.Initialize(cefsetting, true, browserProcessHandler: browserProcessHandler); Thread.Sleep(3000); //time to start Cef Application.Run(browser); LogInfo("shutdown..."); //Shutdown before your application exists or it will hang. Cef.Shutdown(); // save user settings Properties.User.Default.Save(); // close pending threats Environment.Exit(Environment.ExitCode); return(0); }