c#程序怎么设置老板键和自动停靠?

2025-06-21 09:00:49
推荐回答(1个)
回答1:

热键:
方式1--[DllImport("user32.dll")]private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, Keys vk); [DllImport("user32.dll")]private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
方式2--
Application.AddMessageFilter(this);//比较麻烦 需要MFC的消息宏 WM_ALTKEYDOWN之类的

自动停靠:
我的思路是在OnMove事件里判断当前窗体右上角坐标的x,小于某个值或=0则认为自动停靠,
循环移动窗体到屏幕外,留下几个像素。当鼠标进入窗体且当前是停靠状态则循环移进桌面。