private void propLocation_Click(object sender, EventArgs e)
        {
            WindowDeviceContext hdc = SystemWindow.DesktopWindow.GetDeviceContext(false);
            Graphics            g   = Graphics.FromHdc(hdc.HDC);

            try
            {
                Rectangle r = lastObject.Location;
                g.DrawRectangle(Pens.Blue, r.X, r.Y, r.Width, r.Height);
            }
            catch (COMException) { }
            g.Dispose();
            hdc.Dispose();
        }
Exemple #2
0
        void hk_HotkeyPressed(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            SystemAccessibleObject ctr = null;
            SystemWindow           wp  = null;

            //SystemWindow sw = SystemWindow.FromPoint(Cursor.Position.X, Cursor.Position.Y);
            try
            {
                ctr = SystemAccessibleObject.FromPoint(Cursor.Position.X, Cursor.Position.Y);
            }
            catch { }

            try
            {
                wp = ctr.Window;
                while (wp.Parent != null && wp.Parent.HWnd != IntPtr.Zero)
                {
                    wp = wp.Parent;
                    Application.DoEvents(); Thread.Sleep(100);
                }
                sb.AppendLine("------------------------------------------------------------------");
                sb.AppendLine("WINDOW_TITLE: " + wp.Title);
                sb.AppendLine("------------------------------------------------------------------");
                sb.AppendLine("WINDOW_LOCATION: " + wp.Location.X + " x " + wp.Location.Y);
                sb.AppendLine("------------------------------------------------------------------");
                sb.AppendLine("WINDOW_SIZE: " + wp.Position.Width + " x " + wp.Position.Height);
                sb.AppendLine("------------------------------------------------------------------");
                sb.AppendLine("PROCESS: " + wp.Process.ProcessName + ".exe");
                sb.AppendLine("------------------------------------------------------------------");
                //sb.AppendLine("SCROLLBAR: " + GetScrollPos((IntPtr)0x13004e6, Orientation.Horizontal) + " x " + GetScrollPos((IntPtr)0x13004e6, Orientation.Vertical));
                //sb.AppendLine("SCROLLBAR: " + GetScrollPos(ctr.Window.HWnd, Orientation.Horizontal) + " x " + GetScrollPos(ctr.Window.HWnd, Orientation.Vertical));
                //sb.AppendLine("------------------------------------------------------------------");
            }
            catch { }

            try
            {
                sb.AppendLine("CONTROL_NAME: " + ctr.Name);
                sb.AppendLine("------------------------------------------------------------------");
            }
            catch { }

            try
            {
                sb.AppendLine("CONTROL_TITLE: " + ctr.Window.Title);
                sb.AppendLine("------------------------------------------------------------------");
            }
            catch { }

            try
            {
                sb.AppendLine("CONTROL_VALUE: " + ctr.Value);
                sb.AppendLine("------------------------------------------------------------------");
            }
            catch { }

            try
            {
                sb.AppendLine("CONTROL_CLICK: " + (Cursor.Position.X - wp.Location.X) + " x " + (Cursor.Position.Y - wp.Location.Y));
                sb.AppendLine("------------------------------------------------------------------");
            }
            catch { }

            sb.AppendLine("SCREEN_CLICK: " + Cursor.Position.X + " x " + Cursor.Position.Y);
            sb.AppendLine("------------------------------------------------------------------");

            // Draw target control
            try
            {
                WindowDeviceContext hdc = SystemWindow.DesktopWindow.GetDeviceContext(false);
                Graphics            g   = Graphics.FromHdc(hdc.HDC);
                Rectangle           r   = ctr.Location;
                g.DrawRectangle(Pens.Red, r.X, r.Y, r.Width, r.Height);
                g.Dispose();
                hdc.Dispose();
            }
            catch { }



            tbxEditor.Text = sb.ToString();
        }