在控制台应用程序中捕获鼠标滚轮事件 [英] Capturing mouse wheel events in console application

查看:309
本文介绍了在控制台应用程序中捕获鼠标滚轮事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用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.

推荐答案

您可以使用两个部分:


  1. 在鼠标滚轮事件上创建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屋!

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