Exemplo n.º 1
0
        private void FocusEditor()
        {
            JSObject module = _webControl.ExecuteJavascriptWithResult("Crystalbyte.Paranoia");

            using (module) {
                const string function = "focusEditor";
                module.Invoke(function);
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //webBrowser.Source = "ya.ru".ToUri();
            // var js = Utils.GetRequest("https://api-secure.solvemedia.com/papi/challenge.script?k=K2I613-R5myEA75I4wvGOiR3VG372-zW", null, null);
            // MessageBox.Show(js);
            //  MessageBox.Show(webBrowser.ExecuteJavascriptWithResult(js));


            webBrowser.Source = regRef.ToUri();

            while (webBrowser.IsLoading)
            {
                Application.DoEvents();
                Thread.Sleep(20);
            }
            ;

            string page = webBrowser.ExecuteJavascriptWithResult("document.getElementsByTagName('html')[0].innerHTML");

            if (!page.Contains("application/x-shockwave"))
            {
                var surface = webBrowser.Surface as ImageSurface;
                var captcha = Utils.cropImage(surface.Image, new Rectangle(44, 898, 300, 132));
                pictureBox1.Image = captcha;
                // surface.Image.Save("result.png");
                textBox1.Text = DoTesseract(captcha);
            }
            else
            {
                MessageBox.Show("flash");
                var imgLink = Regex.Match(page, "(?<=flash\" data=\")(.*)(?=\" style=\"width:100%)", RegexOptions.Singleline).ToString();
                MessageBox.Show(imgLink);

                WebClient wClient   = new WebClient();
                byte[]    flashByte = wClient.DownloadData(imgLink);
                InitFlashMovie(axShockwaveFlash1, flashByte);

                while (axShockwaveFlash1.ReadyState != 4)
                {
                    Thread.Sleep(50);
                    Application.DoEvents();
                }


                Application.DoEvents();
                MessageBox.Show(axShockwaveFlash1.ReadyState.ToString());
                Graphics g              = axShockwaveFlash1.CreateGraphics();
                Bitmap   bmp            = new Bitmap(axShockwaveFlash1.Size.Width, axShockwaveFlash1.Size.Height, g);
                Graphics memoryGraphics = Graphics.FromImage(bmp);
                IntPtr   dc             = memoryGraphics.GetHdc();
                bool     success        = PrintWindow(axShockwaveFlash1.Handle, dc, 0);
                memoryGraphics.ReleaseHdc(dc);
                pictureBox1.Image = bmp;
            }
        }
Exemplo n.º 3
0
        public static void copyAuctionCategories(WebControl wc)
        {
            string jsLib = getMyJavascript();
              try
              {
            //Создание таблицы categories, если таковой еще нет
            MySqlConnection con = new MySqlConnection(connectionString);
            string dbCommand = "CREATE TABLE IF NOT EXISTS categories (browserValue VARCHAR(15) PRIMARY KEY, categoryName VARCHAR(50));";
            MySqlCommand comm = new MySqlCommand(dbCommand, con);
            con.Open();
            comm.ExecuteNonQuery();
            con.Close();

            //Функции javascript
            JSValue categoryData = wc.ExecuteJavascriptWithResult(jsLib);
            JSValue[] records;
            records = (JSValue[])categoryData;
            JSValue[] catName = (JSValue[])records[0];
            JSValue[] browVal = (JSValue[])records[1];
            addCategoryData(catName, browVal);
              }
              catch(Exception exception)
              {
            MessageBox.Show(exception.Message);
              }
        }
Exemplo n.º 4
0
Arquivo: API.cs Projeto: burnbaby/Dwar
        public static void login (WebControl webControl1)
        {
            try
            {
                dynamic document = (JSObject)webControl1.ExecuteJavascriptWithResult("document");
                if (document == null)
                    throw new Exception("document has null value");
                dynamic element = document.getElementById("userEmail");
                if (element == null)
                    throw new Exception("email has null value");
                element.value = "*****@*****.**";
                element = document.getElementById("userPassword");
                element.value = "ee34nf3o";

                element = document.getElementsByTagName("input");
                for (int i = 0; i < element.length; i++)
                {
                    if (element[i].getAttribute("src") == "images/go_btn.png") ;
                    {
                        element[i].click();
                        break;
                    }
                }
                Thread.Sleep(2000);
                webControl1.Source = new Uri("http://w1.dwar.ru/area_auction.php");
            }
            catch (Exception exception)
            {
               MessageBox.Show(exception.Message);
            }   
        }
Exemplo n.º 5
0
 public static dynamic GetElementsByTagName(WebControl webBrowser, String type)
 {
     try {
         if (webBrowser != null)
         {
             var answer = webBrowser.Invoke(new Func <JSObject>(() => {
                 dynamic document = ( JSObject )webBrowser.ExecuteJavascriptWithResult("document");
                 using ( document ) {
                     try {
                         return(document.getElementsByTagName(type));
                     }
                     catch (Exception exception) {
                         exception.Error();
                     }
                     return(null);
                 }
             }));
             return(answer);
         }
     }
     catch (Exception exception) {
         exception.Error();
     }
     return(null);
 }
Exemplo n.º 6
0
        public string GetAtribInDivInDiv(WebControl webControl, GetElementBy getElementBy, string Atrribute, int count, GetElementBy getElementBy2, string Atrribute2, int count2, string Atrrib)
        {
            string js_code;

            if (getElementBy == GetElementBy.Id)
            {
                if (getElementBy2 == GetElementBy.Id)
                {
                    js_code = "document." + Elements[getElementBy] + "('" + Atrribute + "')." + Elements[getElementBy2] + "('" + Atrribute2 + "')." + Atrrib;
                }
                else
                {
                    js_code = "document." + Elements[getElementBy] + "('" + Atrribute + "')." + Elements[getElementBy2] + "('" + Atrribute2 + "')[" + count2 + "]." + Atrrib;
                }
            }
            else
            {
                if (getElementBy2 == GetElementBy.Id)
                {
                    js_code = "document." + Elements[getElementBy] + "('" + Atrribute + "')[" + count + "]." + Elements[getElementBy2] + "('" + Atrribute2 + "')." + Atrrib;
                }
                else
                {
                    js_code = "document." + Elements[getElementBy] + "('" + Atrribute + "')[" + count + "]." + Elements[getElementBy2] + "('" + Atrribute2 + "')[" + count2 + "]." + Atrrib;
                }
            }
            return(webControl.ExecuteJavascriptWithResult(js_code));
            // return js_code;
        }
Exemplo n.º 7
0
        private int GetTotalPosts(WebControl webCtrl)
        {
            var    javascript = @"document.querySelectorAll('div[data-itemid^=\'update\']>div').length";
            string result     = webCtrl.ExecuteJavascriptWithResult(javascript.Trim());
            int    num        = 0;

            int.TryParse(result, out num);
            return(num);
        }
Exemplo n.º 8
0
 public string GetDocumentText()
 {
     if (webBrowser.InvokeRequired)
     {
         return(webBrowser.Invoke(new GetStringHandler(GetDocumentText)) as string);
     }
     else
     {
         if (webBrowser.IsDocumentReady)
         {
             return(webBrowser.ExecuteJavascriptWithResult("document.getElementsByTagName('html')[0].innerHTML"));
         }
         else
         {
             return(string.Empty);
         }
     }
 }
Exemplo n.º 9
0
 public string JsFireEvent(WebControl webCtrl, string getElementQuery, string eventName)
 {
     return(webCtrl.ExecuteJavascriptWithResult(@"
                 function fireEvent(element,event) {
                     var evt = document.createEvent('HTMLEvents');
                     evt.initEvent(event, true, true ); // event type,bubbling,cancelable
                     element.dispatchEvent(evt);                                 
                 }
                 " + String.Format("fireEvent({0}, '{1}');", getElementQuery, eventName)));
 }
Exemplo n.º 10
0
Arquivo: API.cs Projeto: burnbaby/Dwar
 private static dynamic getCategories(WebControl webControl1)
 {
     try
     {
         dynamic document = (JSObject)webControl1.ExecuteJavascriptWithResult("document");
         dynamic filter = document.getElementsByName("_filter[kind]");
         dynamic categories = filter[0].getElementsByTagName("*");
         return categories;
     }
     catch (Exception exception)
     {
         return null;
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// </summary>
 /// <param name="webBrowser"></param>
 /// <param name="javascript"></param>
 /// <param name="result"></param>
 /// <returns></returns>
 public static Boolean GetJavascriptWithResult(WebControl webBrowser, String javascript, out JSValue result)
 {
     result = default(JSValue);
     if (webBrowser == null)
     {
         return(false);
     }
     try {
         result = ( JSValue )webBrowser.Invoke(new Func <JSValue>(() => webBrowser.ExecuteJavascriptWithResult(javascript)));
         return(true);
     }
     catch (Exception exception) {
         exception.Error();
     }
     return(false);
 }
Exemplo n.º 12
0
 public static dynamic PushButton(WebControl webBrowser, String type, int index)
 {
     try {
         if (webBrowser != null)
         {
             var answer = webBrowser.Invoke(new Func <JSObject>(() => {
                 dynamic document = ( JSObject )webBrowser.ExecuteJavascriptWithResult(String.Format("document.getElementsByTagName('submit')[{0}].click();", index));
                 return(document);
             }));
             return(answer);
         }
     }
     catch (Exception exception) {
         exception.Error();
     }
     return(null);
 }
Exemplo n.º 13
0
        private void WebControl_LoadingFrameComplete(object sender, Awesomium.Core.FrameEventArgs e)
        {
            status.Content = "Загрузка завершена";
            string promotion = string.Empty;

            if (isload)
            {
                WebControl_promo.Source = new Uri(link.Text);
                WebControl_promo.LoadingFrameComplete += (obj, evt) =>
                {
                    string script = @"(function() { for (var i in g_config.promotion.promoData) { return g_config.promotion.promoData[i][0].price } }())";
                    promotion = WebControl_promo.ExecuteJavascriptWithResult(script);

                    if (promotion != "undefined")
                    {
                        price.Text = promotion.Trim('"').Replace('.', ',');
                    }


                    if (promotion == "undefined")
                    {
                        Findprice();
                    }

                    WebControl_promo.Visibility = Visibility.Hidden;
                };

                content = WebControl.ExecuteJavascriptWithResult("document.getElementsByTagName('html')[0].innerHTML");

                Findname();

                Findseller();

                Findmaterial();

                Get_images();

                isload = false;

                perc.Text = "7";
            }
        }
Exemplo n.º 14
0
        internal void HideDiv(WebControl webControl, GetElementBy getElementBy, string Atrribute, int count, string display)
        {
            string js_code;

            if (getElementBy == GetElementBy.Id)
            {
                js_code = "document." + Elements[getElementBy] + "('" + Atrribute + "').setAttribute('style','display:" + display + ";');";
            }
            else
            {
                if (count == -1)//все элементы скрыть
                {
                    js_code = "var appBanners = document." + Elements[getElementBy] + "('" + Atrribute + "'), i; for (var i = 0; i < appBanners.length; i ++) { appBanners[i].setAttribute('style','display:" + display + ";');}";
                }
                else
                {
                    js_code = "document." + Elements[getElementBy] + "('" + Atrribute + "')[" + count + "].setAttribute('style','display:" + display + ";');";
                }
            }

            webControl.ExecuteJavascriptWithResult(js_code);
        }
Exemplo n.º 15
0
        public void ExecuteScript(WebControl webCtrl, string js)
        {
            //dynamic document = (JSObject)webCtrl.ExecuteJavascriptWithResult("document");

            //using (document)
            //{
            //    try
            //    {
            //        dynamic divList =  document.querySelectorAll("div[data-itemid^=\'update\']>div");
            //       /// Console.WriteLine(divList.length.ToString());
            //        divList[0].onclick();
            //    }
            //    catch (Exception)
            //    {

            //    }

            //}

            string result = webCtrl.ExecuteJavascriptWithResult(js.Trim());

            Console.WriteLine(result);
        }
Exemplo n.º 16
0
 public static dynamic GetElementsByTagName( WebControl webBrowser, String type ) {
     try {
         if ( webBrowser != null ) {
             var answer = webBrowser.Invoke( new Func<JSObject>( () => {
                 dynamic document = ( JSObject )webBrowser.ExecuteJavascriptWithResult( "document" );
                 using ( document ) {
                     try {
                         return document.getElementsByTagName( type );
                     }
                     catch ( Exception exception ) {
                         exception.Error();
                     }
                     return null;
                 }
             } ) );
             return answer;
         }
     }
     catch ( Exception exception ) {
         exception.Error();
     }
     return null;
 }
Exemplo n.º 17
0
 public static string[] getItems(WebControl wc)
 {
     string[] results = new string[10];
       string jsFunction = @"function hui(){var scriptTags = $(""script"", document.body.table);
             var results = [];
             for(var i = 0; i < scriptTags.length; i++)
             {
                 if(scriptTags[i].innerText.substring(0, 7) == ""art_alt"")
                 {
                     results.push(scriptTags[i].innerText);
                 }
             }
       return results;} hui();";
       JSValue itemStrings = wc.ExecuteJavascriptWithResult(jsFunction);
       JSValue[] itemStringsArray = (JSValue[])itemStrings;
       //foreach
       return results;
 }
Exemplo n.º 18
0
 /// <summary>
 /// </summary>
 /// <param name="webBrowser"></param>
 /// <param name="javascript"></param>
 /// <param name="result"></param>
 /// <returns></returns>
 public static Boolean GetJavascriptWithResult( WebControl webBrowser, String javascript, out JSValue result ) {
     result = default( JSValue );
     if ( webBrowser == null ) {
         return false;
     }
     try {
         result = ( JSValue )webBrowser.Invoke( new Func<JSValue>( () => webBrowser.ExecuteJavascriptWithResult( javascript ) ) );
         return true;
     }
     catch ( Exception exception ) {
         exception.Error();
     }
     return false;
 }
Exemplo n.º 19
0
        public static void login(WebControl wc)
        {
            try
              {
            dynamic document = (JSObject)wc.ExecuteJavascriptWithResult("document");
            if (document == null)
              throw new Exception("document has null value");
            dynamic element = document.getElementById("userEmail");
            if (element == null)
              throw new Exception("email has null value");
            element.value = "*****@*****.**";
            element = document.getElementById("userPassword");
            element.value = "ee34nf3o";

            element = document.getElementsByTagName("input");
            element[0].click();
            Thread.Sleep(2000);
            wc.Source = new Uri("http://w1.dwar.ru/area_auction.php");
              }
              catch(Exception exception)
              {
            MessageBox.Show(exception.Message);
              }
        }
Exemplo n.º 20
0
 public static dynamic PushButton( WebControl webBrowser, String type, int index ) {
     try {
         if ( webBrowser != null ) {
             var answer = webBrowser.Invoke( new Func<JSObject>( () => {
                 dynamic document = ( JSObject )webBrowser.ExecuteJavascriptWithResult( String.Format( "document.getElementsByTagName('submit')[{0}].click();", index ) );
                 return document;
             } ) );
             return answer;
         }
     }
     catch ( Exception exception ) {
         exception.Error();
     }
     return null;
 }