Exemplo n.º 1
0
 public override void Execute(Arguments arguments)
 {
     try
     {
         arguments.AssertMinimumCount(1);
         if (arguments.Exists(1) && arguments[1].Text == "/out")
         {
             FileName outfile = arguments[2].Text;
             if (outfile.Exists())
             {
                 outfile.Delete();
             }
             fileStream = outfile.WritingStream();
             writer     = new StreamWriter(fileStream)
             {
                 AutoFlush = true
             };
             SetOut(writer);
             SetError(writer);
         }
         var file    = arguments[0].FileName.Required($"File {arguments[0].Text} not found");
         var chooser = new Chooser(file);
         chooser.Choose();
         WriteLine("Done");
     }
     finally
     {
         writer?.Close();
         fileStream?.Close();
     }
 }
Exemplo n.º 2
0
        void menuConsoleSaveToFile_Click(object sender, EventArgs e)
        {
            if (dialogSaveToFile.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            FileName file = dialogSaveToFile.FileName;

            if (file.Exists())
            {
                file.Delete();
            }
            file.Text = richConsole.Lines.Listify("\r\n");
        }
Exemplo n.º 3
0
        void ICapture()
        {
            ushort step = 0, max = ushort.MaxValue, widht = 0, height = 0;
            uint   length = 0;

            using (MemoryStream stream = new MemoryStream())
            {
                WriteInfo("Waiting frame " + step);

                string extra = "";
                while (step < max)
                {
                    Bitmap capture = GetBitmap();
                    if (capture == null)
                    {
                        Thread.Sleep(50);
                        continue;
                    }

                    byte[] search = SearchFor(capture, step, ref extra, ref max, ref length, ref widht, ref height);
                    capture.Dispose();

                    if (search == null || search.Length == 0)
                    {
                        continue;
                    }

                    // Write
                    stream.Write(search, 0, search.Length);

                    WriteInfo("Get Frame " + step, StringHelper.Convert2KbWithBytes(search.Length), ConsoleColor.Cyan);
                    step++;
                    if (step != max)
                    {
                        WriteInfo("Waiting frame " + step);
                    }

                    // Play beep
                    if (PlayBeep)
                    {
                        Beep();
                    }

                    // Sendkey
                    switch (PressKey)
                    {
                    case EKey.None: break;

                    default:
                    {
                        InputSimulator input = new InputSimulator();

                        VirtualKeyCode key = (VirtualKeyCode)(int)PressKey;
                        input.Keyboard.KeyDown(key);
                        input.Keyboard.KeyUp(key);
                        break;
                    }
                    }
                }

                // Dump
                if (stream.Length > 0)
                {
                    byte[] data = stream.ToArray();

                    if (CompressHelper.IsGzipped(data, 0))
                    {
                        data = CompressHelper.Compress(data, 0, data.Length, false);

                        WriteInfo("Dump file [GZIP]", StringHelper.Convert2KbWithBytes(data.Length), ConsoleColor.Cyan);
                    }
                    else
                    {
                        WriteInfo("Dump file", StringHelper.Convert2KbWithBytes(data.Length), ConsoleColor.Cyan);
                    }

                    if (FileName.Exists)
                    {
                        FileName.Delete();
                    }

                    using (FileStream fw = FileName.Create())
                        fw.Write(data, 0, data.Length);
                }
            }
        }