如何在C#中的控制台应用程序中设置鼠标光标的位置? [英] How do I set the position of the mouse cursor from a Console app in C#?

查看:829
本文介绍了如何在C#中的控制台应用程序中设置鼠标光标的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了许多有关如何在C#Windows forms 项目中设置鼠标位置的文章-我想在控制台应用程序中进行此操作.如何在C#Windows 控制台应用程序中设置鼠标的绝对位置?

I've found many articles on how to set the mouse position in a C# windows forms project - I want to do this in a console application. How can I set the absolute mouse position from a C# windows console application?

谢谢!

提示:不是Console.setCursorPosition,它仅设置文本光标在控制台中的位置.

Hint: it's not Console.setCursorPosition, that only sets the position of the text cursor in the console.

推荐答案

在控制台应用程序中,添加对System.Windows.Forms.dll的引用,并使用您已了解的其他技术.控制台与Windows exe的选择只会影响PE标头(甚至可能是默认代码模板,但您可以轻而易举地破解它);您仍然可以在控制台exe中使用完整的框架.

Inside your console application, add a reference to System.Windows.Forms.dll and use the other techniques you've read about. The choice of console vs windows exe only impacts the PE header (and maybe the default code template, but you can hack that trivially); you can still use the full framework in a console exe.

您要控制的鼠标位于Windows中,而不是控制台中.

The mouse you want to control is in windows, not the console.

这篇关于如何在C#中的控制台应用程序中设置鼠标光标的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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