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

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

问题描述

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

推荐答案

您可以用二部分做到这一点:

You can do this with "two" parts:


  1. 在创建鼠标滚轮事件gloabl系统钩子(很好的例子
    这里

二用PInvoke的检查,如果你的控制台是活动的(你
可以在这里找到一个例子:
确定是否当前的应用程序被激活(有焦点)

Second using PInvoke check if your Console is active (you can find a example here: Determine if current application is activated (has focus))

您可以在2个扩展函数来获取窗口RECT的 检查在这里和
相交鼠标位置的窗口位置

You can extend function in 2 to get window RECT check here and intersect mouse position with window position

这篇关于在控制台应用程序捕获鼠标滚轮事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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