private void MouseHook_MouseLeftUpAction(object sender, EventArgs e)
 {
     ENDPOINT.X = (int)(GetCursorPosition().X / dx);
     ENDPOINT.Y = (int)(GetCursorPosition().Y / dy);
     capturing  = false;
     MouseHook.stop();
     this.Hide();
     cap.CaptureArea(STARTPOINT.X * dx, STARTPOINT.Y * dy, ENDPOINT.X * dx, ENDPOINT.Y * dy);
     this.Close();
 }
        public SelectMouseCursor()
        {
            InitializeComponent();
            m  = PresentationSource.FromVisual(Application.Current.MainWindow).CompositionTarget.TransformToDevice;
            dx = m.M11;
            dy = m.M22;
            MouseHook.MouseMoveAction     += MouseHook_MouseAction;
            MouseHook.MouseLeftDownAction += MouseHook_MouseLeftDownAction;
            MouseHook.MouseLeftUpAction   += MouseHook_MouseLeftUpAction;
            MouseHook.Start();

            CursorTranslate.X = GetCursorPosition().X / dx - 13;
            CursorTranslate.Y = GetCursorPosition().Y / dy - 13;

            Cursor.RenderTransform = CursorTranslate;

            XTextblock.Text = (GetCursorPosition().X / dx).ToString();
            YTextblock.Text = (GetCursorPosition().Y / dy).ToString();
        }
Exemple #3
0
        void Hook_KeyboardDown(object sender, GlobalKeyHookEventArgs e)
        {
            //System.Windows.MessageBox.Show(e.VKeyCode.ToString());

            if (e.VKeyCode == VKeyCode.Three)
            {
                if (GlobalKeyHook.IsKeyDown(VKeyCode.LeftAlt) && GlobalKeyHook.IsKeyDown(VKeyCode.LeftShift) && GlobalKeyHook.Hook.Pressing == false)
                {
                    cap.CaptureMyScreen();
                    GlobalKeyHook.Hook.Pressing = true;
                }
            }

            if (e.VKeyCode == VKeyCode.Four)
            {
                if (GlobalKeyHook.IsKeyDown(VKeyCode.LeftAlt) && GlobalKeyHook.IsKeyDown(VKeyCode.LeftShift) && GlobalKeyHook.Hook.Pressing == false)
                {
                    if (SelectMouseCursor == null)
                    {
                        SelectMouseCursor         = new SelectMouseCursor();
                        SelectMouseCursor.Owner   = App.Current.MainWindow;
                        SelectMouseCursor.Closed += delegate
                        {
                            SelectMouseCursor = null;
                        };
                        SelectMouseCursor.Show();
                    }
                    else
                    {
                        SelectMouseCursor.Activate();
                    }
                    GlobalKeyHook.Hook.Pressing = true;
                }
            }

            if (e.VKeyCode == VKeyCode.Six)
            {
                if (GlobalKeyHook.IsKeyDown(VKeyCode.LeftAlt) && GlobalKeyHook.IsKeyDown(VKeyCode.LeftShift) && GlobalKeyHook.Hook.Pressing == false)
                {
                    if (Setting == null)
                    {
                        Setting         = new ScreenshotLikeAMac.UI.Setting();
                        Setting.Owner   = App.Current.MainWindow;
                        Setting.Closed += delegate
                        {
                            Setting = null;
                        };
                        Setting.Show();
                    }
                    else
                    {
                        Setting.Activate();
                    }
                    GlobalKeyHook.Hook.Pressing = true;
                }
            }

            if (e.VKeyCode == VKeyCode.ESC)
            {
                if (SelectMouseCursor != null)
                {
                    MouseHook.stop();
                    SelectMouseCursor.Close();
                    SelectMouseCursor = null;
                }
            }
        }