閺€鎯版 (0) +1 鐠э拷 (0) +1 闊拷 (0) +1
閺€鎯版閹存劕濮�閺屻儳婀呴弨鎯版>>

正在阅读:弹出窗口杀手(下)弹出窗口杀手(下)

2004-02-14 09:34 出处:PConline 作者:TheAres/ASPCool 责任编辑:huangpeidan
  注册系统热键   系统热键用在像弹出窗口杀手这种应用程序非常有用,Ctrl+Shift+J是缺省热键。   说道实现,我们继续用RegisterHotkey(HWND hWnd, int id, UINT fsModifiers, UINT vkey)完成,代码如下:      一般的,注册热键要以下几步: /* ------- using HOTKEYs in a C# application ------- -- code snippet by James J Thompson -- 在Form的load 中 : Ctrl+Shift+J bool success = RegisterHotKey(Handle, 100, KeyModifiers.Control | KeyModifiers.Shift, Keys.J);   在form的closing中:   UnregisterHotKey(Handle, 100);   如何处理热键:      当我们按下热键以后,流程是这样:首先用HWND GetForegroundWindow()来得到窗体,然后要抓出窗体的标题,GetWindowText(HWND hwnd, /*out*/LPTSTR lpString, int nMaxCount)。   具体如下: protected void ProcessHotkey() { IntPtr hwnd = NativeWIN32.GetForegroundWindow(); if (!hwnd.Equals(IntPtr.Zero)) { NativeWIN32.STRINGBUFFER sWindowTitle; NativeWIN32.GetWindowText(hwnd, out sWindowTitle, 256); if (sWindowTitle.szText.Length>0) AddWindowTitle( sWindowTitle.szText ); // add to the ListView (Form) } }

关注我们

最新资讯离线随时看 聊天吐槽赢奖品
閹靛婧€鐠佸潡妫�閸ョ偛鍩屾い鍫曞劥