在控制台应用程序中捕获鼠标滚轮事件 [英] Capturing mouse wheel events in console application
问题描述
有没有办法使用c#捕获控制台应用程序中的鼠标滚轮事件,就像在GUI / Window应用程序中捕获鼠标滚轮事件一样?
Is there a way to capture mouse wheel events in a console application using c#, like you would capture mouse wheel events in GUI / Window applications?
我想这样做只能在控制台中滚动文本的一部分。
I would like to do this to scroll only a part of the text in the console.
我已经搜索过谷歌,但我可以找到的是Window应用程序中的鼠标滚轮事件
I've searched google for this, but all I can find is mouse wheel events in Window applications.
推荐答案
您可以使用两个部分:
-
在鼠标滚轮事件上创建gloabl系统钩子(好的例子
here )
第二次使用PInvoke检查您的控制台是否处于活动状态(您
可以在这里找到一个例子:
确定当前应用程序是否激活(有焦点))
Second using PInvoke check if your Console is active (you can find a example here: Determine if current application is activated (has focus))
您可以扩展功能n in 2获取窗口RECT 查看这里和
与鼠标位置相交
You can extend function in 2 to get window RECT check here and intersect mouse position with window position
这篇关于在控制台应用程序中捕获鼠标滚轮事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!