0

As the title suggests, I want to get a mouse over event at the corners of desktop. I tried to do it by getting the position of the mouse and polling it continuously to check if it is one of the edge coordinated and then trigger the event but I think thats bad way to do it. I tried to use the library MouseKeyHook but it wasn't useful for me to generate the necessary event.

Is there any better way to get mouse over events to the corners of the screen ?

I tried to improve the code by adding the following, but for some reason the mouse over to the corners isn't triggering the action.

  public async void callMainLoop() {
            var slowTask = Task<Boolean>.Factory.StartNew(() => mainMethodLoop(GetMousePosition()));
            await slowTask;
        }


public bool mainMethodLoop(Point point) {
            while (true) {
                double xRes = System.Windows.SystemParameters.PrimaryScreenWidth - 1;
                double yRes = System.Windows.SystemParameters.PrimaryScreenHeight - 1;

                if (point.X == 0 && point.Y == 0) {
                    if (comboBox0.SelectedItem != null) {
                        executeAction(comboBox0.SelectedItem.ToString());
                        return true;
                    }
                }
                return false;
            }
        }

I am not calling this in the constructor, there ins't any freezing now.

bytecar
  • 11
  • 4
  • Wee word of caution: mouse movement into the top and bottom right corners of the screen in Windows 8/8.1, followed by relatively small movements of the mouse up or down, will cause the Charms bar to appear on top of your application. I haven't tested it yet, but Windows 10 will apparently allow dragging windows into corners for docking. Unless your application is full-screen only it may be less of a headache to restrict this behaviour to the corners of the *application* rather than the corners of the *screen*. – goobering Aug 04 '15 at 02:18
  • See: http://stackoverflow.com/questions/2236173/screen-resolution-problem-in-wpf for a plausible explanation as to why your corner detection doesn't work. I'm still looking for a reasonable way to achieve it, but it's starting to look like on of those things that WPF just doesn't make easy. – goobering Aug 04 '15 at 02:33

0 Answers0