如何在Windows中挂接全局快捷方式?
我记得几年前使用过一个程序,该程序使我能够通过自定义的伽玛斜率和其他调整来微调显示器的设置.它能够为不同用途创建不同的屏幕设置配置文件,并设置全局热键快捷方式来激活它们,而无需退出正在使用的程序.
I remember using a program, some years back, that allowed me to fine-tune my monitor's settings with custom gamma ramps and other adjustments. It had the ability to create different screen-settings profiles for different uses, and setup global hotkey shortcuts to activate them without switching out of the program you're in.
我的问题是,您如何为此设置钩子?当我只想在一个屏幕上访问桌面,而又想在另一个屏幕上继续工作时,我讨厌WINDOWS-D将所有内容最小化.(我有2个显示器,这是有原因的!)因此,我认为入侵一个最小化一个显示器上的所有Delphi应用程序并不难.唯一的问题是将其挂接到热键上.有谁知道API的用途吗?
My question is, how do you set up the hook for that? I'm sick of WINDOWS-D minimizing everything when I only want access to the desktop in one screen and I want to keep working in the other one. (I have 2 monitors for a reason!) So I figure it shouldn't be that difficult to hack up a little Delphi app that will minimize everything on one monitor. The only problem is hooking it to a hotkey. Does anyone know what the API is for this?
http://www.swissdelphicenter.ch/torry/showcode.php?id=147
基本上有三个步骤:
注册
// Register Hotkey Win + A
id1 := GlobalAddAtom('Hotkey1');
RegisterHotKey(Handle, id1, MOD_WIN, VK_A);
句柄
procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
{ .... }
// Trap Hotkey Messages
procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
if Msg.HotKey = id1 then
ShowMessage('Win + A pressed !');
取消注册
UnRegisterHotKey(Handle, id1);
GlobalDeleteAtom(id1);