//private IEnumerable<IntPtr> GetWindowHandles(IntPtr handle, int indent) //{ // yield return handle; // var childHandles = new ChildWindowHandles(handle); // if(!childHandles.Any()) // { // yield break; // } // foreach (var childHandle in childHandles) // { // yield return childHandle; // } //} /// <summary> /// 指定した対象を指定した種類でキャプチャする /// </summary> /// <param name="target">キャプチャ対象</param> /// <param name="type">キャプチャ種類</param> private void CaptureImage(CaptureTarget target, CaptureType type) { //List<WindowInfo> windowInfos = new List<WindowInfo>(); //foreach (var handle in new TopLevelWindowHandles()) //{ // windowInfos.Add(new WindowInfo(handle)); //} //foreach(var windowInfo in windowInfos) //{ // Console.WriteLine($"{windowInfo.WindowText} : {windowInfo.ClassName}"); //} try { // キーボードフック中断 KeyboardHook.Pause(); // 矩形領域 if (target == CaptureTarget.RectArea) { using (Bitmap screenBitmap = this.CaptureScreen()) using (CaptureForm captureForm = new CaptureForm(screenBitmap)) { captureForm.ShowDialog(); using (Bitmap captureBitmap = captureForm.CaptureBitmap) { this.SaveImage(captureBitmap, type); } } } // デスクトップ else if (target == CaptureTarget.Desktop) { using (Bitmap captureBitmap = this.CaptureScreen()) { this.SaveImage(captureBitmap, type); } } // アクティブウィンドウ else if (target == CaptureTarget.ActiveWindow) { using (Bitmap captureBitmap = this.CaptureActiveWindow()) { this.SaveImage(captureBitmap, type); } } } finally { // キーボードフック再開 KeyboardHook.Start(); } }
private void RegisterWatchEvent() { if (CaptureTarget.HasFlag(ApiSandbox.WatchPacketType.RawPacket)) { GatePacketManager.RawPacketEntried += OnPacketEntried; } if (CaptureTarget.HasFlag(ApiSandbox.WatchPacketType.ViewPacket)) { FormTaskManager.DrawPacketEntried += OnPacketEntried; } }
public override int Read(byte[] buffer, int offset, int count) { // Read into the given buffer: var bytesRead = StreamToCapture.Read(buffer, offset, count); Debug.Assert(bytesRead <= count); // Copy that data to the capture buffer: if (CaptureTarget != null) { CaptureTarget.Write(buffer, offset, bytesRead); } return(bytesRead); }