Esempio n. 1
0
        protected override void WndProc(ref Message m)
        {
            if (m.WParam == (IntPtr)234)
            {
                checkBoxFreeMode.Checked = !checkBoxFreeMode.Checked;
            }

            if (m.Msg == 274)
            {
                if (m.WParam == (IntPtr)1998)
                {
                    bool temp = checkBoxFreeMode.Checked;
                    checkBoxFreeMode.Checked = false;
                    var info = new SpyAPI.SHELLEXECUTEINFO();
                    info.cbSize = Marshal.SizeOf(info);
                    info.lpVerb = "runas";
                    info.nShow  = SpyAPI.SW_NORMAL;
                    info.lpFile = Application.ExecutablePath;
                    if (SpyAPI.ShellExecuteEx(ref info))
                    {
                        Environment.Exit(0);
                    }
                    else
                    {
                        checkBoxFreeMode.Checked = temp;
                    }
                }
            }

            base.WndProc(ref m);
        }
Esempio n. 2
0
 private void 松开图片(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         PictureBoxMouseImage.Image = My.Resources.Resources.drag;
         SpyAPI.SystemParametersInfoA(87, 0, 0, 0x2);
         flag = false;
         checkBoxFreeMode.Checked = flag;
         isdraw = false;
         // SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0)
     }
 }
Esempio n. 3
0
        /* TODO ERROR: Skipped EndRegionDirectiveTrivia */

        private void   图片(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                PictureBoxMouseImage.Image = My.Resources.Resources.drag2;
                SpyAPI.SetSystemCursor(Cursors.Cross.CopyHandle(), 32512);
                if (e.Button == MouseButtons.Left)
                {
                    flag = true;
                    checkBoxFreeMode.Checked = flag;
                    isdraw = true;
                }
            }
        }
Esempio n. 4
0
        private void ButtonSend_Click(object sender, EventArgs e)
        {
            try
            {
                labelResult.ResetText();
                var hwnd = 0;
                if (msgMapping.ContainsKey(_TextBoxMsgID.Text))
                {
                    hwnd = msgMapping[_TextBoxMsgID.Text];
                }
                else
                {
                    hwnd = Conversions.ToInteger(TextBoxMsgID.Text);
                }

                long result = SpyAPI.SendMessage(Conversions.ToInteger(TextBoxHwnd.Text), hwnd, Conversions.ToInteger(TextBoxLP.Text), Conversions.ToInteger(TextBoxWP.Text));
                labelResult.Text = "Result:  " + result + "  ( 0x" + Convert.ToString(result, 16) + " )";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
0
 private void SPYFORM_Load(object sender, EventArgs e)
 {
     Intance = this;
     setsysmenu();
     SpyAPI.RegisterHotKey(Handle, 234, default, (int)Keys.F3); // 注册热键
Esempio n. 6
0
        public void check()
        {
            do
            {
                SpyAPI.GetCursorPos(ref point);
                labelMousePos.Text = "当前鼠标位置: (" + point.X.ToString() + "," + point.Y.ToString() + ")";
                if (flag == true)
                {
                    // 窗口句柄
                    int currHwnd = SpyAPI.WindowFromPoint(point);
                    textBoxHwnd.Text = currHwnd.ToString();
                    // 窗口大小

                    SpyAPI.GetWindowRect(currHwnd, ref currPosition);
                    labelWinInfo.Text = "窗体位置大小: " + "(" + currPosition.X.ToString() + ":" + currPosition.Y.ToString() + ")" + " " + "(" + (currPosition.Width - currPosition.X).ToString() + " × " + (currPosition.Height - currPosition.Y).ToString() + ")";
                    // 窗口PID
                    uint arglpdwProcessId = 0;
                    SpyAPI.GetWindowThreadProcessId((uint)currHwnd, ref arglpdwProcessId);
                    textBoxPID.Text = arglpdwProcessId.ToString();
                    // 窗口类名
                    var classname = new System.Text.StringBuilder(255);
                    if (currHwnd > 0)
                    {
                        SpyAPI.GetClassName((IntPtr)currHwnd, classname, 255);
                        textBoxWinClass.Text = classname.ToString();
                    }
                    else
                    {
                        textBoxWinClass.Text = null;
                    }
                    // 窗体文本
                    SpyAPI.GetWindowTextA((IntPtr)int.Parse(textBoxHwnd.Text), classname, 255);
                    textBoxWinText.Text = classname.ToString();
                    // 进程位置
                    try
                    {
                        var p = Process.GetProcessById(Conversions.ToInteger(textBoxPID.Text));
                        textBoxWinTitle.Text = p.MainWindowTitle;   // 窗口标题
                        textBoxEXEPath.Text  = p.MainModule.FileName;
                    }
                    catch (Exception ex)
                    {
                        textBoxEXEPath.Text = "拒绝访问!";
                    }

                    // If isdraw AndAlso currHwnd <> 0 Then

                    // DeskHwnd = GetDesktopWindow()
                    // DeskDC = GetWindowDC(DeskHwnd)
                    // oldRop2 = SetROP2(DeskDC, 10)
                    // newPen = CreatePen(0, 2, 0)

                    // Console.WriteLine(r1.X.ToString() + "  ", r1.Y.ToString() + "  ", r1.Right.ToString() + "  ", r1.Bottom.ToString() + "  ")

                    // Rectangle(DeskDC, r1.X, r1.Y, 100, 100)

                    // DeleteObject(newPen)
                    // ReleaseDC(DeskHwnd, DeskDC)


                    // ControlPaint.DrawReversibleFrame(New Rectangle(r1.X, r1.Y, 100, 100), Color.Transparent, FrameStyle.Thick)
                }

                System.Threading.Thread.Sleep(50);
            }while (true);
        }