예제 #1
0
        private bool MouseHook_MouseAction(MouseHook.MouseActionArgs args)
        {
            if (args.MouseButton == Settings.StrokeButton)
            {
                if (args.MouseButtonState == MouseHook.MouseButtonStates.Down)
                {
                    stroking = true;
                    Cursor.Hide();
                    lastPoint = args.Location;
                    drwaingPoints.Add(args.Location);
                    return(true);
                }
                else if (args.MouseButtonState == MouseHook.MouseButtonStates.Up)
                {
                    stroking = false;
                    Cursor.Show();

                    if (stroked)
                    {
                        if (Gesture.Vectors == null)
                        {
                            Gesture.GenerateVectors(drwaingPoints);
                        }
                        else
                        {
                            Gesture gesture = new Gesture("", drwaingPoints);
                            if (gesture.Vectors != null)
                            {
                                for (int i = 0; i < 128; i++)
                                {
                                    double x        = (Gesture.Vectors[i].X * 0.9 + gesture.Vectors[i].X * 0.1);
                                    double y        = (Gesture.Vectors[i].Y * 0.9 + gesture.Vectors[i].Y * 0.1);
                                    double distance = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
                                    Gesture.Vectors[i].X = (sbyte)(x * 127 / distance);
                                    Gesture.Vectors[i].Y = (sbyte)(y * 127 / distance);
                                }
                            }
                        }
                        stroked = false;
                    }

                    drwaingPoints.Clear();
                    this.Close();
                    return(true);
                }
            }

            if (args.MouseButtonState == MouseHook.MouseButtonStates.Move && stroking)
            {
                stroked = true;
                if (Settings.Pen.Opacity != 0 && Settings.Pen.Thickness != 0)
                {
                    draw.DrawPath(lastPoint, args.Location);
                }
                lastPoint = args.Location;
                drwaingPoints.Add(args.Location);
            }

            return(false);
        }
예제 #2
0
        private bool MouseHook_MouseAction(MouseHook.MouseActionArgs args)
        {
            if (spy)
            {
                try
                {
                    if (args.MouseButtonState == MouseHook.MouseButtonStates.Up)
                    {
                        IntPtr hwnd = API.WindowFromPoint(new API.POINT(args.Location.X, args.Location.Y));
                        API.GetWindowThreadProcessId(hwnd, out uint pid);
                        IntPtr        hProcess = API.OpenProcess(API.AccessRights.PROCESS_QUERY_INFORMATION, false, (int)pid);
                        StringBuilder path     = new StringBuilder(1024);
                        uint          size     = (uint)path.Capacity;
                        API.QueryFullProcessImageName(hProcess, 0, path, ref size);
                        textBoxCode.Text = textBoxCode.Text.TrimEnd('\n').TrimEnd('\r') + "\r\n" + Regex.Replace(path.ToString(), @"([\\\.\{\}\[\]\(\)\^\$\|\*\+\?])", @"\$1");
                        spy            = false;
                        Cursor.Current = Cursors.Default;
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }

            return(false);
        }