protected override void Execute(NativeActivityContext context)
 {
     try
     {
         //ThreadInvoker.Instance.RunByUiThread(() =>
         //{
         string ScreenPath = ImagePath.Get(context);
         if ((ScreenPath != null) && (ScreenPath != string.Empty))
         {
             if (File.Exists(ScreenPath))
             {
                 string           sValue         = SetText.Get(context);
                 GetSetClick      getSetClick    = new GetSetClick();
                 ImageRecognition imgRecognition = new ImageRecognition();
                 getSetClick = GetSetClick.Set;
                 bool result = imgRecognition.GetSetClickImage(ScreenPath, getSetClick, sValue, 10000, accuracy);
                 Result.Set(context, result);
             }
         }
         //});
     }
     catch (Exception ex)
     {
         Logger.Log.Logger.LogData(ex.Message + " in activity Image_FindAndSetText", Logger.LogLevel.Error);
         if (!ContinueOnError)
         {
             context.Abort();
         }
     }
 }
        protected override void Execute(NativeActivityContext context)
        {
            try
            {
                string sImagePath = ImagePath.Get(context);
                bool   result     = false;

                if (File.Exists(sImagePath))
                {
                    GetSetClick      getSetClick    = new GetSetClick();
                    ImageRecognition imgRecognition = new ImageRecognition();
                    getSetClick = GetSetClick.Click;
                    result      = imgRecognition.GetSetClickImage(sImagePath, getSetClick, "", 10000, Accuracy);
                    Result.Set(context, result);
                }
                //});
            }
            catch (Exception ex)
            {
                Logger.Log.Logger.LogData(ex.Message + " in activity Image_FindAndClick", Logger.LogLevel.Error);
                if (!ContinueOnError)
                {
                    context.Abort();
                }
            }
        }
Esempio n. 3
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            // Find the window that contains the control

            // Find the window that contains the control
            // Minimize
            window.WindowState = WindowState.Minimized;
            height             = window.Height;
            width         = window.Width;
            window.Height = 0;
            window.Width  = 0;
            Thread.Sleep(1000);
            Bitmap bmp = null;
            // Image_FindAndClick owa = null;
            // owa = (Image_FindAndClick)this.ModelItem.GetCurrentValue();
            double accuracy         = owa.Accuracy;
            string processDirectory = SelectHelper.ProjectLocation + "\\Images";

            if (!Directory.Exists(processDirectory))
            {
                Directory.CreateDirectory(processDirectory);
            }
            string ScreenPath = processDirectory + "\\" + owa.ImageId + ".png";

            if ((ScreenPath != null) && (ScreenPath != string.Empty))
            {
                if (File.Exists(ScreenPath))
                {
                    GetSetClick      getSetClick    = new GetSetClick();
                    ImageRecognition imgRecognition = new ImageRecognition();
                    getSetClick = GetSetClick.Click;
                    bool result = imgRecognition.GetSetClickImage(ScreenPath, getSetClick, "", 10000, accuracy);
                }
            }
            window.Height      = height;
            window.Width       = width;
            window.WindowState = WindowState.Normal;
        }