CefSharp links that open specific application doesnt work

64 Views Asked by At

CefSharp links that open specific application doesnt work

Im trying to make my winform web browser be able to open specific applications like on roblox or other websites that run specific application

Im new to programming so i have no idea how to do stuff like this,any help is appreciated

this is my code:

using CefSharp;
using CefSharp.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lunarium
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }

        private void txtUrl_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
                browser.Load(txtUrl.Text);
        }

        ChromiumWebBrowser browser;
        private void btnGo_Click(object sender, EventArgs e)
        {
            browser.Load(txtUrl.Text);
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {
            browser = new ChromiumWebBrowser(txtUrl.Text);
            browser.Dock = DockStyle.Fill;
            this.pContainer.Controls.Add(browser);
            browser.TitleChanged += Browser_TitleChanged;
        }
        public void favicon()
        {
            Uri url = new Uri("https://" + new Uri(browser.Address).Host + "/favicon.ico");
            try
            {
                Icon img = new Icon(new System.IO.MemoryStream(new
                WebClient().DownloadData(url)));
                this.Icon = img;
            }
            catch (Exception)
            {
                this.Icon = Properties.Resources.tempIcon;
                //change tempIcon to your desired icon, extension is .ico 
            }
        }
        private void Browser_TitleChanged(object sender, TitleChangedEventArgs e)
        {
            this.Invoke(new MethodInvoker(() =>
            {
                Text = e.Title;
                favicon();
            }));
        }
    }
}
0

There are 0 best solutions below