Args2Str() public static method

public static Args2Str ( List args ) : string
args List
return string
Exemplo n.º 1
0
        public static void open_url(Browser b, bool incognito = false)
        {
            var args = new List <string>();

            if (!string.IsNullOrEmpty(b.additionalArgs))
            {
                args.Add(b.additionalArgs);
            }
            if (incognito)
            {
                args.Add(b.private_arg);
            }
            if (b.exec.ToLower().EndsWith("brave.exe"))
            {
                args.Add("--");
            }
            args.Add(Program.url.Replace("\"", "%22"));

            if (b.exec.EndsWith("iexplore.exe") && !incognito)
            {
                // IE tends to open in a new window instead of a new tab
                // code borrowed from http://stackoverflow.com/a/3713470/1461004
                bool         found = false;
                ShellWindows iExplorerInstances = new ShellWindows();
                foreach (InternetExplorer iExplorer in iExplorerInstances)
                {
                    if (iExplorer.Name.EndsWith("Internet Explorer"))
                    {
                        iExplorer.Navigate(Program.url, 0x800);
                        // for issue #10 (bring IE to focus after opening link)
                        ForegroundAgent.RestoreWindow(iExplorer.HWND);
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    Process.Start(b.exec, Program.Args2Str(args));
                }
            }
            else
            {
                ProcessStartInfo startInfo = new ProcessStartInfo(b.exec);
                // Clicking MS Edge takes more than 4 seconds to load, even with an existing window
                // Disabling UseShellExecute to create the process directly from the browser executable file
                startInfo.UseShellExecute = false;
                startInfo.Arguments       = Program.Args2Str(args);
                Process.Start(startInfo);
            }
            Application.Exit();
        }
Exemplo n.º 2
0
        public static void open_url(Browser b, bool incognito = false)
        {
            var args = new List <string>();

            if (!string.IsNullOrEmpty(b.additionalArgs))
            {
                args.Add(b.additionalArgs);
            }
            if (incognito)
            {
                args.Add(b.private_arg);
            }
            if (b.exec.ToLower().EndsWith("brave.exe"))
            {
                args.Add("--");
            }
            args.Add(Program.url.Replace("\"", "%22"));

            if (b.exec.EndsWith("iexplore.exe") && !incognito)
            {
                // IE tends to open in a new window instead of a new tab
                // code borrowed from http://stackoverflow.com/a/3713470/1461004
                bool         found = false;
                ShellWindows iExplorerInstances = new ShellWindows();
                foreach (InternetExplorer iExplorer in iExplorerInstances)
                {
                    if (iExplorer.Name.EndsWith("Internet Explorer"))
                    {
                        iExplorer.Navigate(Program.url, 0x800);
                        // for issue #10 (bring IE to focus after opening link)
                        ForegroundAgent.RestoreWindow(iExplorer.HWND);
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    Process.Start(b.exec, Program.Args2Str(args));
                }
            }
            else
            {
                Process.Start(b.exec, Program.Args2Str(args));
            }
            Application.Exit();
        }
Exemplo n.º 3
0
        public static void open_url(Browser b, bool incognito = false)
        {
            var args = new List <String>();

            if (incognito)
            {
                args.Add(b.private_arg);
            }
            args.Add(Program.url.Replace("\"", "%22"));

            if (b.exec == "edge")
            {
                //edge is a universal app , which means we can't just run it like other browsers
                Process.Start("microsoft-edge:" + Program.url
                              .Replace(" ", "%20")
                              .Replace("\"", "%22"));
            }
            else if (b.exec.EndsWith("iexplore.exe") && !incognito)
            {
                // IE tends to open in a new window instead of a new tab
                // code borrowed from http://stackoverflow.com/a/3713470/1461004
                bool         found = false;
                ShellWindows iExplorerInstances = new ShellWindows();
                foreach (InternetExplorer iExplorer in iExplorerInstances)
                {
                    if (iExplorer.Name.EndsWith("Internet Explorer"))
                    {
                        iExplorer.Navigate(Program.url, 0x800);
                        // for issue #10 (bring IE to focus after opening link)
                        ForegroundAgent.RestoreWindow(iExplorer.HWND);
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    Process.Start(b.exec, Program.Args2Str(args));
                }
            }
            else
            {
                Process.Start(b.exec, Program.Args2Str(args));
            }

            Application.Exit();
        }