using system.runtime.interopservices;
//註冊熱鍵的api
[dllimport("user32")]
public static extern bool registerhotkey(intptr hwnd,int id,uint control,keys vk );
//解除註冊熱鍵的api
[dllimport("user32")]
public static extern bool unregisterhotkey(intptr hwnd, int id);
private void form2_load1(object sender, system.eventargs e)
private void form2_load1(object sender, system.eventargs e)
protected override void wndproc(ref message m)
base.wndproc (ref m);
}none = 0,alt = 1,crtl= 2, shift = 4,windows = 8
這是熱鍵的定義 alt+crtl是3 直接相加就可以了
如果用sendmessagea這個api 就是
sendmessage(this.handle,wm_sethotkey,0x45a, 0)
//wm_sethotkey 是 0x32
//0x45a 高位元組是contrl鍵 低位元組是a b c d 所以5a是z的ascii 4是alt 也就是alt+z
C 註冊系統熱鍵
簡單點說就是為程式制定快捷鍵勒。很多軟體都帶熱鍵功能的,通過以下方式可以實現2個鍵或3個鍵的快捷鍵,相當之實用,具體實現方法看後文吧。先引用using system.runtime.interopservices 的命名空間,然後在合適的位置加上如下 就ok。注意 form1 load和form1 ...
C 註冊系統熱鍵
引用using system.runtime.interopservices 命名空間 dllimport user32 public static extern bool registerhotkey intptr hwnd,int id,uint control,keys vk 註冊熱鍵的api...
C 註冊熱鍵 RegisterHotKey
vc 註冊熱鍵 registerhotkey 需要同時按住 ctrl 方向鍵,則使用 註冊熱鍵 的方法。1 定義熱鍵,不要重複,防止熱鍵衝突 define myhotkey1 1018 define myhotkey2 1019 2 註冊熱鍵 registerhotkey m hwnd,myhotk...