0

im trying to make a simple clicker in Windows Forms App but the problem is that I can't move cursor outside window from to make click. Here is part of the code im using to move cursor:

this.Cursor = new Cursor(Cursor.Current.Handle);
Cursor.Position = new Point(Cursor.Position.X - 500, Cursor.Position.Y - 500);
Cursor.Clip = new Rectangle(this.Location, this.Size); 
Hubertto
  • 78
  • 8
  • So there is no other way to use Cursor.Clip and move outside Form? – Hubertto Dec 28 '19 at 21:11
  • 1
    Do you want to limit the Cursor's movements? Then define a specific region where the Cursor can move. It doesn't need to be inside the Form's bounds, it can be any area of any screen. What is this region? Do you know how to calculate it? Do you really need it? To what end? Are you trying to trap the Cursor inside the bounds of another, *foreign*, Window? – Jimi Dec 28 '19 at 21:13
  • I just simply want to move cursor and make a click on the scrren. It has to be outside the form or use in a loop and minimalize Windows Form App. I found this fragment of code in Micorsoft Dosc where i can easily set position of it on the screen. I tried to use it but i can not move cursor outside the Form because it simply stops on its border. – Hubertto Dec 28 '19 at 21:18
  • 2
    Then just remove `Cursor.Clip`. You can move the Cursor to any position in the VirtualScreen. – Jimi Dec 28 '19 at 21:19
  • Thanks, moving cursor any position in the VirtualScreen, that's what i wanted! – Hubertto Dec 28 '19 at 21:23
  • 2
    The notes [here](https://stackoverflow.com/a/53026765/7444103) may come in handy. Don't skip the part about the application DpiAwareness. – Jimi Dec 28 '19 at 21:28

0 Answers0