实现触摸板

时间:2016-04-21 21:09:42

标签: c#

我正在开发一个应用程序,我将鼠标功能映射到键盘上。例如,如果用户按下“L”,则应用程序将模拟鼠标左键单击。我已经使用以下方式映射了点击和滚动:

[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);

现在我想实现放大和缩小功能。就像在笔记本电脑中,使用触控板上的夹点,我们可以放大和缩小。我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:1)

There is a nice function in Windows 8+ - InjectTouchInput. It allows you to inject touch events or mouse events with any parameters you want. It also is packed into .net wrapper.

This question already contains working C++ sample code for pinch, you can adapt it to your needs. This will simulate zoom by touchscreen.

This is one way. Other way may be by sending WM_MOUSEWHEEL with CTRL key modifier to target HWND, basically simulating mouse wheel zoom.