Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

326
Visualizações
Setting Cursor.Position "half"-works (from one monitor to another)

I have two monitors with the non-primary monitor (number 1) set to the main one's (number 2) top left like this:

enter image description here

I'll repeat: number 2 is the primary monitor.

Here's the code:

Cursor.Position = new Point(-500, -500);

What happens is that when the cursor is initially in the primary monitor (number 2), after the code is executed, the cursor moves to monitor number 1, to a location 500 pixels up from its bottom, but to its far right. Here:

enter image description here

Instead of here:

enter image description here

After running the above code twice, like so:

Cursor.Position = new Point(-500, -500);
Cursor.Position = new Point(-500, -500);

It gets to the correct place.

The problem is that this code seems like a hack and I'd like to avoid it, and get the cursor to the correct place in a "correct" way.

So how do I achieve that?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

When you have more than one screen then you have to be careful about Bounds of each screen C# provide an array of Screens and you can loop through that array to get more information about screen coordinates i.e. Screen.AllScreens

enter image description here

See the image bellow which demonstrate that only primary screen start from X:0 and Y:0 in 2D(X,Y) plane, we can adjust second screen anywhere, in my case it is has position (-1366,305) as shown. and different points ar enter image description here Each Screen has its bound from Left To Right and From Top to Bottom. You can use that bounds to go to exact position like shown in code I can move to any Point of any screen if I add its Bounds'value to Point.

   //To move on First Screen use its Bounds
    Cursor.Position = new Point(300 + Screen.AllScreens[0].Bounds.Left, 300 + Screen.AllScreens[0].Bounds.Top);
    
    //To move on Second Screen use its Bounds
    Cursor.Position = new Point(300 + Screen.AllScreens[1].Bounds.Left, 300 + Screen.AllScreens[1].Bounds.Top);
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda