コード例 #1
0
        public void MouseMove(int x, int y, int sx, int sy)
        {
            Win32Types.Rect rect;
            Win32Funcs.GetWindowRectWrapper(hptr, out rect);
            int tx = x + rect.Left;

            int ty = y + rect.Top;

            mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, tx * 65535 / sx, ty * 65535 / sy, 0, 0);
        }
コード例 #2
0
        protected override IntPtr DoCapture()
        {
            var ret = Win32Funcs.BitBltWrapper(
                HMemDc, 0, 0, WinClientRect.Width, WinClientRect.Height,
                HScrDc, 0, 0,
                (uint)Win32Consts.RasterOperationMode.SRCCOPY);

            SaveFile();

            return(ret ? _bitsPtr : IntPtr.Zero);
        }
コード例 #3
0
        public bool Init(string windowName)
        {
            var handle = Win32Funcs.FindWindowWrapper(null, windowName);

            if (handle.Equals(IntPtr.Zero))
            {
                return(false);
            }

            return(Init(handle));
        }
コード例 #4
0
        public const int MOUSEEVENTF_ABSOLUTE   = 0x8000; // 绝对坐标

        private void button1_Click(object sender, EventArgs e)
        {
            var hWnd = Win32Funcs.FindWindowWrapper(null, "逍遥模拟器".Trim());

            if (string.IsNullOrEmpty("逍遥模拟器") || hWnd.Equals(IntPtr.Zero))
            {
                MessageBox.Show("无效的窗口标题");
                return;
            }
            AddCapture(hWnd);
        }
コード例 #5
0
        protected override bool DoCapture(out IntPtr bitsPtr)
        {
            bitsPtr = _bitsPtr;
            var ret = Win32Funcs.BitBltWrapper(
                HMemDc, 0, 0, WinClientRect.Width, WinClientRect.Height,
                HScrDc, 0, 0,
                (uint)Win32Consts.RasterOperationMode.SRCCOPY);

            SaveFile();

            return(ret);
        }
コード例 #6
0
        private void buttonTitle_Click(object sender, EventArgs e)
        {
            var hWnd = Win32Funcs.FindWindowWrapper(null, textBox_Title.Text.Trim());

            if (string.IsNullOrEmpty(textBox_Title.Text) || hWnd.Equals(IntPtr.Zero))
            {
                MessageBox.Show("无效的窗口标题");
                return;
            }

            AddCapture(hWnd);
            EnableStart(false);
        }
コード例 #7
0
        private void EnterGame()
        {
            mytext += "尝试进入游戏……\r\n";
            var hWnd = Win32Funcs.FindWindowWrapper(null, "逍遥模拟器".Trim());

            if (string.IsNullOrEmpty("逍遥模拟器") || hWnd.Equals(IntPtr.Zero))
            {
                mytext += "进入游戏失败\r\n未打开逍遥模拟器\r\n";
                return;
            }
            AddCapture(hWnd);
            mytext  += "已进入游戏\r\n";
            gamemode = true;
            return;
        }
コード例 #8
0
        public bool Init(IntPtr handle)
        {
            HWnd = handle;

            //获取窗口大小
            if (!Win32Funcs.GetWindowRectWrapper(HWnd, out _windowRect) ||
                !Win32Funcs.GetClientRectWrapper(HWnd, out WinClientRect))
            {
                return(false);
            }

            _bmpDataSize = WinClientRect.Width * WinClientRect.Height * 3;

            return(CommonInit());
        }
コード例 #9
0
        private void buttonTitle_Click(object sender, EventArgs e)
        {
            var hWnd = Win32Funcs.FindWindowWrapper(null, "逍遥模拟器".Trim());

            if (string.IsNullOrEmpty("逍遥模拟器") || hWnd.Equals(IntPtr.Zero))
            {
                MessageBox.Show("无效的窗口标题");
                return;
            }
            for (int i = 0; i < 57; i++)
            {
                string path = "C:\\Users\\10947\\Desktop\\新建文件夹 (2)\\" + string.Format("_{0:D4}_图层 ", i) + (57 - i).ToString() + ".bmp";
                ig[i] = (Bitmap)Image.FromFile(path);
            }
            timer1.Start();
            AddCapture(hWnd);
        }
コード例 #10
0
        public void Cleanup()
        {
            if (HBitmap.Equals(IntPtr.Zero))
            {
                return;
            }

            //删除用过的对象
            Win32Funcs.SelectObjectWrapper(HMemDc, HOldBitmap);
            Win32Funcs.DeleteObjectWrapper(HBitmap);
            Win32Funcs.DeleteDcWrapper(HMemDc);
            Win32Funcs.ReleaseDcWrapper(HWnd, HScrDc);

            HWnd       = IntPtr.Zero;
            HScrDc     = IntPtr.Zero;
            HMemDc     = IntPtr.Zero;
            HBitmap    = IntPtr.Zero;
            HOldBitmap = IntPtr.Zero;
            //_bitsPtr = IntPtr.Zero;
        }
コード例 #11
0
        protected override bool CommonInit()
        {
            //位图信息
            _bitmapInfo = new Win32Types.BitmapInfo {
                bmiHeader = new Win32Types.BitmapInfoHeader()
            };
            _bitmapInfo.bmiHeader.Init();
            _bitmapInfo.bmiHeader.biWidth       = WinClientRect.Width;
            _bitmapInfo.bmiHeader.biHeight      = WinClientRect.Height;
            _bitmapInfo.bmiHeader.biPlanes      = 1;
            _bitmapInfo.bmiHeader.biBitCount    = 24;
            _bitmapInfo.bmiHeader.biSizeImage   = (uint)(WinClientRect.Width * WinClientRect.Height);
            _bitmapInfo.bmiHeader.biCompression = (uint)Win32Consts.BitmapCompressionMode.BI_RGB;

            HScrDc  = Win32Funcs.GetWindowDcWrapper(HWnd);
            HMemDc  = Win32Funcs.CreateCompatibleDcWrapper(HScrDc);
            HBitmap = Win32Funcs.CreateDibSectionWrapper(HMemDc, ref _bitmapInfo,
                                                         (uint)Win32Consts.DibColorMode.DIB_RGB_COLORS,
                                                         out _bitsPtr, IntPtr.Zero, 0);
            HOldBitmap = Win32Funcs.SelectObjectWrapper(HMemDc, HBitmap);

            return(true);
        }
コード例 #12
0
ファイル: YT_SizeBorder.cs プロジェクト: 20154530/IpgwCore
 protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
 {
     base.OnMouseLeftButtonDown(e);
     Win32Funcs.SendMessage(new WindowInteropHelper(AttachedWindow as Window).Handle, 0x112, (IntPtr)(61440 + resDirection), IntPtr.Zero);
 }