Reputation: 1886
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.
I've searched google for this, but all I can find is mouse wheel events in Window applications.
Upvotes: 3
Views: 3424
Reputation: 19820
You can do this with "two" parts:
Create global system hook on mouse wheel event (good example here)
Second using PInvoke check if your Console is active (you can find a example here: Determine if current application is activated (has focus))
You can extend function in 2 to get window RECT check here and intersect mouse position with window position
Upvotes: 3
Reputation: 45173
Call the ReadConsoleInput
function. You will receive a MOUSE_WHEELED
event when the wheel is rotated on your console.
Upvotes: 7