在 C# 中将鼠标光标移出屏幕

发布于 2024-07-14 20:16:56 字数 174 浏览 8 评论 0原文

我有一个 wpf 窗口,高度为 2000,实际桌面高度约为 1000。显然,窗口的大约一半在屏幕外。 即使窗口延伸到屏幕下方,鼠标也不会向下移动到该区域。 我确实希望此内容位于屏幕外,并且如果鼠标位于该位置的元素上,我希望鼠标能够在其上移动并单击元素。 我不想更改屏幕分辨率,因为某些内容绝对必须在屏幕之外。 不知道该怎么做。

I have a wpf window that has a height of 2000 with an actual desktop height of about 1000. Obviously about half of the window is off screen. Even though the window extends below the screen, the mouse will not move down to that area. I do want this content to be off-screen, and I want the mouse to be able to move over it and click on elements if the mouse is positioned over an element at that position. I don't want to change my screen resolution as some content absolutely has to be off the screen. Not sure how to go about this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

(り薆情海 2024-07-21 20:16:57

Windows 中没有屏幕外光标位置。 我认为鼠标受屏幕分辨率的限制,即使窗口不受限制。

There is not an off the screen cursor position in Windows. I think the mouse is bounded by the screen resolution, even if windows are not.

美人迟暮 2024-07-21 20:16:57

如果您查看 MaxiVista 的屏幕截图,您会发现显示设备管理器的屏幕截图:

设备管理器 http://www.maxivista.com/pics /screenshots/vista_devicemanager_en.gif

如您所见,他们只是编写了一个虚拟显示适配器,它提供了自己的显示尺寸。 因此,窗口将被告知可用大小(例如 2560x1600)是可能的,并允许所有窗口和鼠标使用这些边界。 现在,由显示驱动程序将该虚拟屏幕的右侧部分转发到当前的真实显示适配器,以便在每个物理设备上显示右侧部分。

If you take a look at the screen shots of MaxiVista you'll find a screen shot showing the Device Manager:

Device Manager http://www.maxivista.com/pics/screenshots/vista_devicemanager_en.gif

As you can see they simply wrote a virtual display adapter, which provides its own display size. So windows will be informed about a available size of e.g. 2560x1600 would be possible and allows these bounds for all windows and the mouse. Now it is up to the display driver to forward the right portions of this virtual screen to the current real display adapters so that the right part is shown on each physical device.

薯片软お妹 2024-07-21 20:16:57

我认为这是可能的。 此程序将允许使用辅助计算机作为额外的显示器。 有几个程序可以让您知道鼠标光标所在的坐标。 例如 AutoIt 可以轻松做到这一点。

在此处输入图像描述

当您安装 autoit 时,它会附带此实用程序,让您知道鼠标所在的坐标。 当我截取屏幕截图时,鼠标没有显示,但我在鼠标所在的位置画了一个蓝点。 请注意,坐标为 710、1464。现在我的屏幕分辨率为 1200 * 1920(我的显示器已旋转)。 定位鼠标光标

因此,使用 Autoit,我可以通过执行类似在此处输入图像描述

当我运行该 autoit 程序时来 会将鼠标移动到该位置。 这个问题的答案似乎是正确的,因为我无法将鼠标向右移动超过 1200。 换句话说,执行MouseMove(2500,800)将导致鼠标移动到1200,800。现在有趣部分是我如何能够移动鼠标到(2500,800)! 如果我使用 这个程序 换句话说执行 MouseMove(2500,800)< /code> 现在可以与 Autoit 配合使用,并且鼠标实际上会移动到另一台计算机(maxivista 必须正在运行)。 ma​​xivista 表明可以有一种方法将鼠标移动到屏幕分辨率之外

I think it is possible. This program will enable to use a secondary computer as an extra monitor. There are several programs that can let you know the coordinates where your mouse cursor is positioned. For example AutoIt will do that easily.

enter image description here

When you install autoit it comes with this utility that will let you know the cordinates where you position the mouse. When I took the screen capture the mouse does not show up but I draw a blue dot where the mouse was located. Note that the cordinates where 710, 1464. Right now my screen resolution is 1200 * 1920 (my monitor is rotated). So with Autoit I am able to position my mouse cursor by doing something like

enter image description here

When I run that autoit program it will move the mouse to that location. The answers to this question seem to be right cause I am not able to move the mouse any further than 1200 to the right. In other words executing MouseMove(2500,800) will result in moving the mouse to 1200,800. Now the interesting part is how come I am able to move the mouse to (2500,800)! if I use This program In other words executing MouseMove(2500,800) now works with Autoit and the mouse actually moves to the other computer (maxivista has to be running). maxivista shows that there can be a way of moving the mouse outside the resolution of your screen.

流绪微梦 2024-07-21 20:16:56

光标定界不是由应用程序完成的,而是由 Windows 本身完成的。 据我所知,没有办法让光标指向屏幕之外。

你可以通过做许多游戏所做的事情来模拟你想要的东西。 不要绘制 Windows 光标,而是在应用程序窗口中绘制自定义光标。 强制真实光标(未绘制)停留在监视器的中心。 每次用户移动真实光标时,相应地移动应用程序的光标并将真实光标重新放置到屏幕中央。

这会给你一种你想要的错觉,但我认为 WPF 无法处理这个问题。

Cursor delimiting is not done by the application, but by Windows itself. To my knowledge there is no way to have your cursor pointing off the screen.

You could simulate what you want by doing what many games do. Do not draw the Windows cursor, draw a custom one in your app window. Force the real cursor (not being drawn) to stay in the center of the monitor. Every time the user moves the real cursor, move your application's cursor accordingly and re-place the real cursor to the center of the screen.

This will give the illusion of what you'd like, but I don't think WPF can handle this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文