扩展显示上的鼠标位置 [英] Mouse position on extended displays

查看:47
本文介绍了扩展显示上的鼠标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个特定问题上我找不到任何东西,所以就去了!

I could not find anything on this particular problem, so here it goes!

我有兴趣通过编程方式更改鼠标光标的位置.

I am interested in changing the position of the mouse cursor programmatically.

Cursor.Position = new Point(x, y);

使用单个监视器按预期工作.但是,当我插入第二个插件并选择扩展桌面时,更改光标的坐标仅相对于主屏幕有效.

works as expected using a single monitor. However, when I plug in a second one and choose to extend the desktop, changing the cursor's coordinates only works relative to the main screen.

那么,有谁知道如何告诉光标我要移至其他屏幕?

So, does anyone know how to tell the cursor that I want to move to a different screen?

推荐答案

获取所需屏幕的宽度和高度,并相对于屏幕移动光标

Get the width and height of your required screen and move the cursor relative to it

int width=Screen.AllScreens[1].Bounds.Width;
int height=Screen.AllScreens[1].Bounds.Height;
Cursor.Position=new Point(width-x,height-y);

这篇关于扩展显示上的鼠标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆