示例#1
0
        private void TakeScreenShoot_Load(object sender, EventArgs e)
        {
            toolStripProgressBar1.Value = 0;

            int iHandle = NativeWin32.FindWindow(null, _nameProcess);

            pictureBox1.Image = PrintWindowWin32.PrintWindow(iHandle);

            Bitmap b = new Bitmap(pictureBox1.ClientSize.Width, pictureBox1.Height);

            pictureBox1.DrawToBitmap(b, pictureBox1.ClientRectangle);

            string ok     = "Color [A=255, R=0, G=255, B=0]";
            string fail   = "Color [A=255, R=255, G=0, B=0";
            int    width  = 354;
            int    height = 78;

            Color  colour = b.GetPixel(width, height);
            string name   = colour.ToString();

            if (name == ok)
            {
                Status = "P";
            }
            if (name == fail)
            {
                Status = "F";
            }
            b.Dispose();
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        private void GetTaskWindows()
        {
            // Get the desktopwindow handle
            int nDeshWndHandle = NativeWin32.GetDesktopWindow();
            // Get the first child window
            int           nChildHandle = NativeWin32.GetWindow(nDeshWndHandle, NativeWin32.GW_CHILD);
            List <string> list         = new List <string>();

            while (nChildHandle != 0)
            {
                //If the child window is this (SendKeys) application then ignore it.
                if (nChildHandle == this.Handle.ToInt32())
                {
                    nChildHandle = NativeWin32.GetWindow(nChildHandle, NativeWin32.GW_HWNDNEXT);
                }

                // Get only visible windows
                if (NativeWin32.IsWindowVisible(nChildHandle) != 0)
                {
                    StringBuilder sbTitle = new StringBuilder(1024);
                    // Read the Title bar text on the windows to put in combobox
                    NativeWin32.GetWindowText(nChildHandle, sbTitle, sbTitle.Capacity);
                    string sWinTitle = sbTitle.ToString();
                    {
                        if (sWinTitle.Length > 0)
                        {
                            list.Add(sWinTitle);
                        }
                    }
                }
                // Look for the next child.
                nChildHandle = NativeWin32.GetWindow(nChildHandle, NativeWin32.GW_HWNDNEXT);
            }
            cboWindows.Properties.DataSource = list;
        }
示例#3
0
 private void SeekFSStream(long offset)
 {
     if (NANDMMCStyle)
     {
         if (_fileStream.Position == offset)
         {
             return; // No need to seek, we're already where we want to be...
         }
         if (_fileStream.CanSeek)
         {
             _fileStream.Seek(offset, SeekOrigin.Begin);
         }
         else
         {
             throw new Exception("Unable to seek!");
         }
     }
     else
     {
         var lo = (int)(offset & 0xffffffff);
         var hi = (int)(offset << 32);
         lo = (int)NativeWin32.SetFilePointer(_deviceHandle, lo, ref hi, NativeWin32.SeekOriginToMoveMethod(SeekOrigin.Begin));
         if (lo == -1)
         {
             throw new X360NANDManagerException(X360NANDManagerException.ErrorLevels.Win32Error);
         }
     }
 }
示例#4
0
文件: KeyCode.cs 项目: Nucs/nlib
        /// <summary>
        /// Calls the Win32 SendInput method with a KeyDown and KeyUp message in the same input sequence in order to simulate a Key PRESS.
        ///
        /// </summary>
        /// <param name="keyCode">The KeyCode to press</param>
        public static void SimulateKeyPress(this KeyCode keyCode)
        {
            var input1 = new INPUT();

            input1.Type                    = 1U;
            input1.Data.Keyboard           = new KEYBDINPUT();
            input1.Data.Keyboard.Vk        = (ushort)keyCode;
            input1.Data.Keyboard.Scan      = 0;
            input1.Data.Keyboard.Flags     = 0U;
            input1.Data.Keyboard.Time      = 0U;
            input1.Data.Keyboard.ExtraInfo = IntPtr.Zero;
            var input2 = new INPUT();

            input2.Type                    = 1U;
            input2.Data.Keyboard           = new KEYBDINPUT();
            input2.Data.Keyboard.Vk        = (ushort)keyCode;
            input2.Data.Keyboard.Scan      = 0;
            input2.Data.Keyboard.Flags     = 2U;
            input2.Data.Keyboard.Time      = 0U;
            input2.Data.Keyboard.ExtraInfo = IntPtr.Zero;
            if ((int)NativeWin32.SendInput(2U, new INPUT[2] {
                input1,
                input2
            }, Marshal.SizeOf(typeof(INPUT))) == 0)
            {
                throw new Exception(string.Format("The key press simulation for {0} was not successful.", keyCode));
            }
        }
示例#5
0
        /// <summary> Enumerates the files in this collection. </summary>
        /// <param name="target">        The target to act on. </param>
        /// <param name="searchPattern"> A pattern specifying the search. </param>
        /// <returns>
        ///     An enumerator that allows foreach to be used to process the files in this collection.
        /// </returns>
        public static IEnumerable <FileInfo> EnumerateFiles(this DirectoryInfo target, string searchPattern)
        {
            const int MAX_PATH     = 248;
            const int MAX_FILENAME = 260;

            string searchPath = Path.Combine(target.FullName, searchPattern);

            if (searchPath.Length >= MAX_PATH)
            {
                yield break;
            }

            NativeWin32.WIN32_FIND_DATA findData;
            using (NativeWin32.SafeSearchHandle hFindFile = NativeWin32.FindFirstFile(searchPath, out findData))
            {
                if (!hFindFile.IsInvalid)
                {
                    do
                    {
                        if ((findData.dwFileAttributes & FileAttributes.Directory) == 0 && findData.cFileName != "." && findData.cFileName != "..")
                        {
                            string fileName = Path.Combine(target.FullName, findData.cFileName);
                            if (fileName.Length >= MAX_FILENAME)
                            {
                                yield break;
                            }
                            else
                            {
                                yield return(new FileInfo(Path.Combine(target.FullName, findData.cFileName)));
                            }
                        }
                    } while (NativeWin32.FindNextFile(hFindFile, out findData));
                }
            }
        }
示例#6
0
文件: SnippingTool.cs 项目: Nucs/nlib
        /// <summary>
        /// Takes screenshot of the window (supports multiple monitors) and then lets user to select the wanted area and returns that area.
        /// Also returns the rectangle of the selected part inside of the window.
        /// </summary>
        public static Image Snip(IntPtr hWnd, out Rectangle rect, PixelFormat format = PixelFormat.Format24bppRgb)
        {
            NativeWin32.SetForegroundWindow(hWnd);

            Rect r;

            if (!NativeWin32.GetWindowRect(hWnd, out r))
            {
                rect = Rectangle.Empty;
                return(null);
            }
            rect = new Rectangle(Convert.ToInt32(r.X), Convert.ToInt32(r.Y), Convert.ToInt32(r.Width), Convert.ToInt32(r.Height));

            var bmp = ScreenShot.Create(hWnd);

            Graph = Graphics.FromImage(bmp);
            Graph.SmoothingMode = SmoothingMode.None;

            using (var snipper = new SnippingTool(bmp)
            {
                SpecificWindowMode = true
            }) {
                snipper.Location = new Point(rect.Left, rect.Top);
                NativeWin32.SetForegroundWindow(snipper.Handle);

                if (snipper.ShowDialog() == DialogResult.OK)
                {
                    rect = snipper.rcSelect;
                    return(snipper.Image);
                }
            }
            rect = Rectangle.Empty;
            return(null);
        }
示例#7
0
        private void Excute(string boardNo, string product_id)
        {
            this.TopMost = false;

            StopTimerReadBarcode();

            txtBarcode.ResetText();
            txtBarcode.Focus();
            productionId = boardNo;
            modelId      = product_id;
            MessageHelpers.SetSuccessStatus(true, "OK", $"Board '{boardNo}' OK!", lblStatus, lblMessage);
            // Thực hiện gửi dữ liệu đi
            int iHandle = NativeWin32.FindWindow(null, cboWindows.Text);

            NativeWin32.SetForegroundWindow(iHandle);

            serial = boardNo.Split(separator: new[] { "_" }, count: 4, options: StringSplitOptions.None);
            //maxaddress = boardNo.Split(separator: new[] { "." }, count: 4, options: StringSplitOptions.None);

            //SendKeys.Send("{TAB}");
            //SendKeys.Send("{ENTER}");
            SendKeys.Send(serial[0]);
            SendKeys.Send("{ENTER}");

            //SendKeys.Send(maxaddress[1]);
            //SendKeys.Send("{ENTER}");

            if (checkComWrite.Checked == true)
            {
                // Start machine FCT Check
                Thread.Sleep(200);
                comWrite.WriteData("S");
            }
        }
示例#8
0
 /// <summary>
 /// Запускает инициализацию бота
 /// </summary>
 /// <param name="winName">Паттер поиска процесса</param>
 public void initBotAsync(string winName)
 {
     if (status > State.NotInitialized)
     {
         return;
     }
     Task.Run(() =>
     {
         Status    = State.Initialization;
         Regex rgx = new Regex(winName, RegexOptions.IgnoreCase);
         while (true)
         {
             Thread.Sleep(5000);
             var runningProc = getRunProcesses();
             foreach (var item in runningProc)
             {
                 if (rgx.IsMatch(item.MainWindowTitle))
                 {
                     gameProc = item;
                     gameProc.EnableRaisingEvents = true;
                     gameProc.Exited += GameProc_Exited;
                     NativeWin32.SetForegroundWindow(gameProc.MainWindowHandle.ToInt32());
                     Status = State.Ready;
                     return;
                 }
             }
         }
     });
 }
示例#9
0
        private static void OnAddWordSystemHotkeyPressed(object sender, EventArgs e)
        {
            var appExePath = NativeWin32.GetFocusesApp();
            var appExeName = System.IO.Path.GetFileNameWithoutExtension(appExePath);

            Context.AddActiveApplicationHandyman(appExeName, appExePath);
        }
示例#10
0
        internal int ReadFromDevice(ref byte[] buffer, long offset, int index = 0, int count = -1)
        {
            SeekFSStream(offset);
            if (count <= 0)
            {
                count = buffer.Length;
            }
#if DEBUG
            Main.SendDebug("Reading 0x{0:X} bytes from the device @ offset 0x{1:X} index in the buf: 0x{2:X}", count, offset, index);
#endif
            if (NANDMMCStyle)
            {
                return(_fileStream.Read(buffer, index, count));
            }
            uint readcount;
            bool res;
            if (index != 0)
            {
                res = NativeWin32.ReadFile(_deviceHandle, buffer, (uint)count, out readcount, IntPtr.Zero);
            }
            else
            {
                var tmp = new byte[count];
                res = NativeWin32.ReadFile(_deviceHandle, tmp, (uint)count, out readcount, IntPtr.Zero);
                if (res)
                {
                    Buffer.BlockCopy(tmp, 0, buffer, index, count);
                }
            }
            if (!res)
            {
                throw new X360NANDManagerException(X360NANDManagerException.ErrorLevels.Win32Error);
            }
            return((int)readcount);
        }
示例#11
0
 private void btnSelectWindow_Click(object sender, EventArgs e)
 {
     if (DialogResult.OK ==
         MessageBox.Show(
             "After you click \"OK\" this dialog you'll have 3 seconds to select the window the keys will be send to",
             "Select your desired window", MessageBoxButtons.OKCancel, MessageBoxIcon.Information))
     {
         Thread.Sleep(3000);
         this._hiveServerSystem.Window = NativeWin32.GetActiveProcessWindow();
         this.lblCurrentWindow.Text    = this._hiveServerSystem.Window.Title;
         if (DialogResult.Yes !=
             MessageBox.Show("Is " + this._hiveServerSystem.Window.Title + " the window you want?",
                             "Are you sure?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
         {
             this._hiveServerSystem.Window   = new NativeWin32.ProcessWindow(new IntPtr(), "nowindowselectedinputhive");
             this.lblCurrentWindow.ForeColor = Color.DarkRed;
             this.lblCurrentWindow.Text      = "None";
         }
         else
         {
             this.lblCurrentWindow.ForeColor = Color.Green;
             this.lblCurrentWindow.Text      = this._hiveServerSystem.Window.Title;
         }
     }
 }
示例#12
0
        private static void Main()
        {
            try {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Diagnostical.HasConsoleBeenAllocated = NativeWin32.AllocConsole();
                if (Diagnostical.HasConsoleBeenAllocated)
                {
                    Console.WriteLine("Logging console activated.");
                    Console.WriteLine("Assembly version {0}", Assembly.GetEntryAssembly().GetName().Version);
                    Console.WriteLine("Loading MainForm.");
                }

                using (var mainForm = new MainForm()) {
                    Application.Run(mainForm);
                }
            }
            catch (Exception exception) {
                exception.Error();
            }
            finally {
                if (Diagnostical.HasConsoleBeenAllocated)
                {
                    Diagnostical.HasConsoleBeenAllocated = !NativeWin32.FreeConsole();
                }
            }
        }
示例#13
0
 /// <summary>
 ///     Uninstalls the global hook
 /// </summary>
 private void unhook()
 {
     if (NativeWin32.UnhookWindowsHookEx(HHook) == false)
     {
         throw new Win32Exception(Marshal.GetLastWin32Error());
     }
 }
示例#14
0
文件: WindowFinder.cs 项目: Nucs/nlib
        /// <summary>
        /// Handles the MouseUp event of the picTarget control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        private void picTarget_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            IntPtr hWnd;
            IntPtr hTemp;

            // End targeting
            isTargeting = false;

            // Unhighlight window
            if (targetWindow != IntPtr.Zero)
            {
                NativeWin32.HighlightWindow(targetWindow);
            }
            targetWindow = IntPtr.Zero;

            // Reset capture image and cursor
            picTarget.Cursor = Cursors.Default;
            picTarget.Image  = bitmapFind;

            // Get screen coords from client coords and window handle
            hWnd = NativeWin32.WindowFromPoint(picTarget.Handle, e.X, e.Y);

            // Get owner
            while ((hTemp = NativeWin32.GetParent(hWnd)) != IntPtr.Zero)
            {
                hWnd = hTemp;
            }

            SetWindowHandle(hWnd);

            // Release capture
            NativeWin32.SetCapture(IntPtr.Zero);
        }
示例#15
0
文件: WindowFinder.cs 项目: Nucs/nlib
 /// <summary>
 /// Sets the window handle if handle is a valid window.
 /// </summary>
 /// <param name="handle">The handle to set to.</param>
 public void SetWindowHandle(IntPtr handle)
 {
     if ((NativeWin32.IsWindow(handle) == false) || (NativeWin32.IsRelativeWindow(handle, this.Handle, true)))
     {
         // Clear window information
         windowHandle     = IntPtr.Zero;
         windowHandleText = string.Empty;
         windowClass      = string.Empty;
         windowText       = string.Empty;
         isWindowUnicode  = false;
         windowCharset    = string.Empty;
     }
     else
     {
         // Set window information
         windowHandle     = handle;
         windowHandleText = Convert.ToString(handle.ToInt32(), 16).ToUpper().PadLeft(8, '0');
         windowClass      = NativeWin32.GetClassName(handle);
         windowText       = NativeWin32.GetWindowText(handle);
         isWindowUnicode  = NativeWin32.IsWindowUnicode(handle) != 0;
         windowCharset    = ((isWindowUnicode) ? ("Unicode") : ("Ansi"));
     }
     if (WindowHandleChanged != null)
     {
         WindowHandleChanged(this, EventArgs.Empty);
     }
 }
示例#16
0
文件: WindowFinder.cs 项目: Nucs/nlib
        /// <summary>
        /// Highlights the specified window, but only if it is a valid window in relation to the specified owner window.
        /// </summary>
        private void HighlightValidWindow(IntPtr hWnd, IntPtr hOwner)
        {
            // Check for valid highlight
            if (targetWindow == hWnd)
            {
                return;
            }

            // Check for relative
            if (NativeWin32.IsRelativeWindow(hWnd, hOwner, true))
            {
                // Unhighlight last window
                if (targetWindow != IntPtr.Zero)
                {
                    NativeWin32.HighlightWindow(targetWindow);
                    targetWindow = IntPtr.Zero;
                }

                return;
            }

            // Unhighlight last window
            NativeWin32.HighlightWindow(targetWindow);

            // Set as current target
            targetWindow = hWnd;

            // Highlight window
            NativeWin32.HighlightWindow(hWnd);
        }
示例#17
0
 private void tmrEditNotify_Tick(object sender, EventArgs e)
 {
     if (m_bDirtys)
     {
         // Kiểm tra lại bản mạch đã OK trên WIP chưa?
         // Nếu OK => Đóng dấu
         // Nếu FAIL => Bỏ qua không đóng dấu, thông báo lỗi
         //trạng thái bản mạch hiện tại
         if (checkEditSerialPort.Checked == true)
         {
             var checkAgain = _workOrderItemService.Get_WORK_ORDER_ITEMS_By_BoardNo(productionId);
             if (checkAgain.BOARD_STATE == 1)
             {
                 //com.WriteData("O");
                 lblMarking.Visible = true;
             }
             else if (checkAgain.BOARD_STATE == 2)
             {
                 messageError = $"Board '{productionId}' NG Wip. Vui lòng kiểm tra lại!";
                 MessageHelpers.SetErrorStatus(true, "NG", messageError, lblStatus, lblMessage);
                 CheckTextBoxNullValue.SetColorErrorTextControl(txtBarcode);
                 var errorForm = new FormError(messageError);
                 errorForm.ShowDialog();
                 txtBarcode.Focus();
             }
         }
         int iHandle2 = NativeWin32.FindWindow(null, this.Text);
         NativeWin32.SetForegroundWindow(iHandle2);
         lblPass.Text  = pass.ToString();
         lblNG.Text    = ng.ToString();
         lblTotal.Text = total.ToString();
         LoadData(productionId, modelId, gridLookUpEditProcessID.EditValue.ToString(), boardState);
         m_bDirtys = false;
     }
 }
示例#18
0
文件: ScreenShot.cs 项目: Nucs/nlib
        /// <summary>
        ///     Creates a screenshot from a hidden window.
        /// </summary>
        /// <param name="windowHandle">
        ///     The handle of the window.
        /// </param>
        /// <returns>
        ///     A <see cref="Bitmap"/> of the window.
        /// </returns>
        public static Bitmap CreateFromHidden(IntPtr windowHandle)
        {
            Bitmap bmpScreen = null;

            try {
                Rectangle r;
                using (Graphics windowGraphic = Graphics.FromHdc(new IntPtr(NativeWin32.GetWindowDC(windowHandle)))) {
                    r = Rectangle.Round(windowGraphic.VisibleClipBounds);
                }

                bmpScreen = new Bitmap(r.Width, r.Height);
                using (Graphics g = Graphics.FromImage(bmpScreen)) {
                    IntPtr hdc = g.GetHdc();
                    try {
                        NativeWin32.PrintWindow(windowHandle, hdc, 0);
                    } finally {
                        g.ReleaseHdc(hdc);
                    }
                }
            } catch {
                if (bmpScreen != null)
                {
                    bmpScreen.Dispose();
                }
            }

            return(bmpScreen);
        }
示例#19
0
        private void TextBox_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key != System.Windows.Input.Key.Enter)
            {
                return;
            }

            //var allProcesses = Process.GetProcesses();

            //foreach (Process theprocess in allProcesses)
            //{
            //    Console.WriteLine("Process: {0} ID: {1}", theprocess.ProcessName, theprocess.Id);
            //}

            //Process[] process1 = Process.GetProcessesByName("chrome");
            //process1[0].WaitForInputIdle();
            //var handler = NativeWin32.FindWindow("chrome", null);
            var iHandle = NativeWin32.FindWindow("Notepad++", null);

            //var iHandle = FindWindow("Notepad++", null);
            //var iHandle = NativeWin32.FindWindow(null,"");

            NativeWin32.SetForegroundWindow(iHandle);
            System.Windows.Forms.SendKeys.SendWait("{F11}");

            //SendMessage(iHandle, NativeWin32.WM_KEYDOWN, NativeWin32.VK_A, NativeWin32.VK_SHIFT);
            //var mes = SendMessage(iHandle, NativeWin32.WM_KEYDOWN, new IntPtr(NativeWin32.VK_F11), IntPtr.Zero);
            //var mes2 = NativeWin32.SendMessage(iHandle, NativeWin32.SC_CLOSE, 0, 0);


            e.Handled = true;
            //MessageBox.Show(((TextBox)sender).Text);
        }
示例#20
0
 public void RemountDevice()
 {
     foreach (var mp in _mountPoints)
     {
         Main.SendDebug("Mounting {0} to {1}", mp.VolumePath, mp.MountPath);
         NativeWin32.SetVolumeMountPoint(mp.MountPath, mp.VolumePath);
     }
 }
示例#21
0
        private void SetWindowStyle()
        {
            var       helper         = new WindowInteropHelper(this);
            const int gwlExstyle     = -20;
            const int wsExNoactivate = 0x08000000;

            NativeWin32.SetWindowLong(helper.Handle, gwlExstyle, (IntPtr)(wsExNoactivate | wsExNoactivate));
        }
        private void SetWindowStyle()
        {
            var       hwnd           = new WindowInteropHelper(this).Handle;
            const int gwlExstyle     = (-20);
            const int wsExNoactivate = 0x08000000;
            const int wsExToolWindow = 0x00000080;

            NativeWin32.SetWindowLong(hwnd, gwlExstyle, (IntPtr)(wsExNoactivate | wsExToolWindow));
        }
示例#23
0
 /// <summary>
 /// Release the device
 /// </summary>
 internal void Release()
 {
     if (DeviceHandle != null && !DeviceHandle.IsInvalid)
     {
         DeviceHandle.Close();
     }
     NativeWin32.UnLockDevice(Path);
     IsLocked = false;
 }
示例#24
0
 private static IntPtr SetHook(NativeWin32.LowLevelKeyboardProc proc)
 {
     using (Process curProcess = Process.GetCurrentProcess())
         using (ProcessModule curModule = curProcess.MainModule)
         {
             return(NativeWin32.SetWindowsHookEx(WH_KEYBOARD_LL, proc,
                                                 NativeWin32.GetModuleHandle(curModule.ModuleName), 0));
         }
 }
示例#25
0
 private void hook(IntPtr hInstance)
 {
     callbackDelegate = new keyboardHookProc(hookProc);
     GC.KeepAlive(callbackDelegate);
     HHook = NativeWin32.SetWindowsHookEx(WH_KEYBOARD_LL, callbackDelegate, hInstance, 0);
     if (HHook == IntPtr.Zero)
     {
         throw new Win32Exception(Marshal.GetLastWin32Error());
     }
 }
示例#26
0
 internal int hookProc(int code, int wParam, ref keyboardHookStruct lParam)
 {
     if (code >= 0)
     {
         add_keyevent(new KeyEventProcessArgs()
         {
             wParam = wParam, lParam = lParam.DeepClone()
         });
     }
     return(NativeWin32.CallNextHookEx(HHook, code, wParam, ref lParam));
 }
示例#27
0
 public void UnmountDevice()
 {
     foreach (var volume in _volumes)
     {
         SafeFileHandle vHandle;
         NativeWin32.UnmountVolume(volume, out vHandle);
         vHandle.Close();
         _mountPoints.Add(new MountPoint(volume));
         Main.SendDebug("Removing mount point: {0}", volume);
         NativeWin32.DeleteVolumeMountPoint(volume);
     }
 }
 public ScreenManager()
 {
     NativeWin32.DEVMODE devMode = new NativeWin32.DEVMODE();
     if (!NativeWin32.EnumDisplaySettings(Screen.PrimaryScreen.DeviceName, NativeWin32.ENUM_CURRENT_SETTINGS, ref devMode))
     {
         WallpaperRefreshRate = 250;
     }
     else
     {
         WallpaperRefreshRate = devMode.dmDisplayFrequency;
     }
 }
示例#29
0
        public bool Draw(WallpaperRenderer renderer, IntPtr hdc, IntPtr memDc)
        {
            if (!BrowserManager.Browser.ShouldDraw)
            {
                return(false);
            }

            BrowserManager.Browser.ShouldDraw = false;

            Size wallpaperSize = renderer.ScreenManager.WallpaperSize;

            if (!BrowserManager.Browser.Size.Equals(wallpaperSize))
            {
                BrowserManager.Browser.Size = wallpaperSize;
            }

            Bitmap bitmap = BrowserManager.Browser.GetRenderData();

            if (bitmap == null)
            {
                if (lastRenderData != null)
                {
                    bitmap = lastRenderData;
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                lastRenderData?.Dispose();
            }

            IntPtr hBitmap = bitmap.GetHbitmap();

            NativeWin32.SelectObject(memDc, hBitmap);

            Point offset = renderer.ScreenManager.WallpaperOffset;

            bool flag = NativeWin32.BitBlt(hdc,
                                           offset.X, offset.Y,
                                           wallpaperSize.Width, wallpaperSize.Height,
                                           memDc,
                                           0, 0,
                                           NativeWin32.TernaryRasterOperations.SRCCOPY);

            NativeWin32.DeleteObject(hBitmap);

            lastRenderData = bitmap;

            return(flag);
        }
示例#30
0
文件: ScreenShot.cs 项目: Nucs/nlib
        /// <summary>
        ///     Create a complete screenshot of a window by using a handle.
        /// </summary>
        /// <param name="windowHandle">
        ///     Handle of the window.
        /// </param>
        /// <returns>
        ///     A <see cref="Bitmap"/> of the window.
        /// </returns>
        public static Bitmap Create(IntPtr windowHandle)
        {
            Rect window;

            NativeWin32.GetWindowRect(windowHandle, out window);
            int       winWidth   = Convert.ToInt32(window.Right - window.Left);
            int       winHeight  = Convert.ToInt32(window.Bottom - window.Top);
            Rectangle windowRect = new Rectangle((int)window.Left, (int)window.Top, winWidth, winHeight);
            Bitmap    bmpScreen  = ScreenShot.Create(windowRect);

            return(bmpScreen);
        }
示例#31
0
 internal MMCDevice(string displayName, string path, NativeWin32.DiskGeometry geometry)
 {
     DisplayName = displayName;
     Path = path;
     DiskGeometry = geometry;
 }