private static void ListenForJavascript(WebView view, int startLine)
        {
            Console.Write("> ");
            string userInput = Console.ReadLine();

            if (userInput.ToLower() == "back")
            {
                // Queue the destruction of the view and return.
                WebCore.QueueWork(view, view.Dispose);
                // Clear Console and Reset cursor.
                ConsoleBuffer.ClearLines(startLine, Console.CursorTop);
                Console.SetCursorPosition(0, startLine);
                // Back to menu.
                return;
            }
            else if (userInput.ToLower() == "save")
            {
                int messageLine = WriteMessageBox();
                ReplaceLine("Saving JavaScript Console Page", messageLine);

                // Queue TakeSnapshots to be executed on Awesomium's thread.
                WebCore.QueueWork(() => TakeSnapshots(view, messageLine, false));
                // Back to JavaScript Console.
                ListenForJavascript(view, startLine);
                return;
            }

            // This check is here only for demonstration.
            // Awesomium is running on its own thread and
            // attempting to access the view from another thread,
            // requires that we use Invoke/BeginInvoke so
            // InvokeRequired will return true.
            string result = view.InvokeRequired ?
                            (string)view.Invoke((Func <WebView, String, String>)ExecuteJavascript, view, userInput) :
                            ExecuteJavascript(view, userInput);

            // If we got a valid result, print it.
            if (!String.IsNullOrEmpty(result))
            {
                Console.WriteLine("> " + result);
            }

            // Loop until the user exits the JS console.
            ListenForJavascript(view, startLine);
        }
        private static void ListenForURL()
        {
            int messageLine = WriteMessageBox();

            // Print message.
            Console.Write("Type a URL to take snapshots or type \"back\" to return to menu: ");
            // Wait for user input.
            string userInput = Console.ReadLine();

            if (userInput.ToLower() == "back")
            {
                // Clear Console and Reset cursor.
                ConsoleBuffer.ClearLines(Console.CursorTop - 7, Console.CursorTop);
                Console.SetCursorPosition(0, Console.CursorTop - 7);
                // Back to menu.
                return;
            }

            // Get the URL. ToUri is a String extension provided
            // by Awesomium.Core.Utilities that can help you easily
            // convert strings to a URL.
            Uri url = userInput.ToUri();

            // ToUri is errors-free. If an invalid string is specified,
            // a blank URI (about:blank) will be returned that can be
            // checked with IsBlank, a helper Uri extension.
            if (url.IsBlank())
            {
                ReplaceLine("Badly formatted URL!", messageLine);
                // Go back.
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                ListenForURL();
                return;
            }

            // We demonstrate using WebCore.QueueWork to queue
            // work to be executed on Awesomium's thread.
            WebCore.QueueWork(() => NavigateAndTakeSnapshots(url, messageLine));

            // Go back.
            Console.SetCursorPosition(0, Console.CursorTop - 1);
            ListenForURL();
        }
 private static void GotoMenuStart()
 {
     ConsoleBuffer.ClearLines(Console.CursorTop - 5, Console.CursorTop);
     Console.SetCursorPosition(0, Console.CursorTop - 5);
 }