1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
/* ============================================================================
Hardware HotKeys plugin for Miranda NG.
Copyright © Eugene f2065, http://f2065.narod.ru, f2065 mail.ru, ICQ 35078112
This program is free software; you can redistribute it and / or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 - 1307, USA.
============================================================================ */
#include "stdafx.h"
HINSTANCE hInstance;
int hLangpack;
HWND hDialogWnd = nullptr; // õýíäë îêíà íàñòðîåê, îí ãëîáàëüíî èñïîëüçóåòñÿ äëÿ âûâîäà òóäà â ðåàëòàéìå ñêàíêîäîâ êëàâû èç õóêà
HHOOK hHook;
CLIST_INTERFACE *pcli;
// òàì õðàíÿòñÿ íàñòðîéêè - ñêàíêîäû êíîïîê äëÿ çàêðûòèÿ/ïîêàçà/÷òåíèÿ, íà êîòîðûå äîëæíû ðåàãèðîâàòü ñîîòâåòñòâóþùèå äåéñòâèÿ
DWORD code_Close = 0;
DWORD code_HideShow = 0;
DWORD code_ReadMsg = 0;
// â _tmp êîïèðóþòñÿ íàñòðîéêè íà âðåìÿ äèàëîãà íàñòðîåê
DWORD code_Close_tmp = 0;
DWORD code_HideShow_tmp = 0;
DWORD code_ReadMsg_tmp = 0;
// ôîðìàò ñêàíêîäîâ òóò òàêîé:
// ìëàäøèå 0...7 áèòû - ýòî àïïàðàòíûé ñêàíêîä (êàê îí ïðèõîäèò â KbdLLHookStruct.scanCode&0xFF)
// 8 áèò - ýòî êàê áû ÷àñòü ñêàíêîäà, ôëàã LLKHF_EXTENDED ((LOBYTE(KbdLLHookStruct.flags)&1) - ÷àñòü êíîïîê ñ ýòèì ôëàãîì
// (àâòîðàì 101-êíîïî÷íîé êëàâû íå õâàòèëî 255 ñêàíêîäîâ, ò.ê. òàì ìíîãî ñòàðûõ êíîïîê êîòîðûå óæå äàâíî âûìåðëè òèïà F13-F20).
// èòàê, ïëàãèí îïåðèðóåò 9-áèòíûìè ñêàíêîäàìè (èìåíà êíîïîê âñåõ ýòèõ ñêàíêîäîâ ïðîïèñàíû â òàáëèöå *key_tab[0x200]).
// áèòû 9-19 - íå èñïîëüçóþòñÿ.
// áèòû 20-31 - ýòî ôëàãè ðåãèñòðîâ, Shift/Ctrl/Alt/Win. Íà 4 êíîïêè - 12 áèòîâ. Ïîòîìó ÷òî êàæäàÿ êíîïêà 3 èìååò áèòà - ëåâàÿ, ïðàâàÿ, èëè ëþáàÿ.
// áèòîâûå ìàñêè ðåãèñòðîâ îïåðåäåëåíû â key_flag_sr è ñîñåäíèõ èìåíàõ
// ïëàãèí îïåðèðóåò 10 - áèòíûìè "ñêàíêîäàìè" ñîáñòâåííîãî ôîðìàòà.
// ìëàäøèå 0...7 áèòû - ýòî îáû÷íî àïïàðàòíûé ñêàíêîä (êàê îí ïðèõîäèò â KbdLLHookStruct.scanCode&0xFF)
// 8 áèò - ýòî êàê áû ÷àñòü ñêàíêîäà, ôëàã LLKHF_EXTENDED ((LOBYTE(KbdLLHookStruct.flags)&1) - ÷àñòü êíîïîê ñ ýòèì ôëàãîì
// (àâòîðàì 101-êíîïî÷íîé êëàâû íå õâàòèëî 255 ñêàíêîäîâ, ò.ê. òàì ìíîãî ñòàðûõ êíîïîê êîòîðûå óæå äàâíî âûìåðëè òèïà F13-F20).
// 9 áèò - ýòî çíà÷èò ÷òî â áèòàõ 0...7 íå àïïàðàòíûé ñêàíêîä, à VK-êîä (KbdLLHookStruct.vkCode), è 8 áèò ïðè ýòîì âñåãäà 0.
// ñäåëàíî ýòî ïîòîìó ÷òî íåêîòîðûå USB-êëàâèàòóðû íå âûäàþò â õóê àïïàðàòíûå ñêàíäîäû, è åñëè òàì 0 - òî áóäåò èñïîëüçîâàí VK-êîä.
// (èìåíà êíîïîê âñåõ ýòèõ ñêàíêîäîâ ïðîïèñàíû â òàáëèöå *key_tab[0x300]).
// áèòû 10-19 - íå èñïîëüçóþòñÿ.
// áèòû 20-31 - ýòî ôëàãè ðåãèñòðîâ, Shift/Ctrl/Alt/Win. Íà 4 êíîïêè - 12 áèòîâ. Ïîòîìó ÷òî êàæäàÿ êíîïêà 3 èìååò áèòà - ëåâàÿ, ïðàâàÿ, èëè ëþáàÿ.
// áèòîâûå ìàñêè ðåãèñòðîâ îïåðåäåëåíû â key_flag_sr è ñîñåäíèõ èìåíàõ
DWORD key_code = 0; // òàì ïîñòîÿííî îáíîâëÿåòñÿ ñêàíêîä òåêóùåé íàæàòîé êîìáèíàöèè
DWORD key_code_raw = 0;
DWORD key_code_assign = 0; // âî âðåìÿ íàñòðîåê òàì õðàíèòñÿ ñêàíêîä ïîñëåäíåé íàæàòîé êîìáèíàöèè, êîòîðûé ìîæíî íàçíà÷èòü äëÿ äåéñòâèÿ.
CHAR key_name_buffer[150]; // áóôåð êóäà ïå÷àòàåòñÿ èìÿ êíîïêè â íàñòðîéêàõ. ANSI.
// Ñàìàÿ äëèííàÿ â òåîðèè ñòðîêà - «L_Shift + L_Ctrl + L_Alt + L_Win + R_Shift + R_Ctrl + R_Alt + R_Win + MSO_Print, HP_TouchPadOff» - ìåíåå 100 áóêâ.
// ============================================================================
BOOL APIENTRY DllMain( HMODULE hModule, DWORD, LPVOID)
{
hInstance = hModule;
return TRUE;
}
// ============================================================================
PLUGININFOEX PluginInfoEx = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
__DESCRIPTION_MIR,
__AUTHOR,
__AUTHOREMAIL,
__COPYRIGHT,
__AUTHORWEB,
UNICODE_AWARE,
// {315B3800-8258-44C4-B60E-58C50B9303B6} - GUID äëÿ ïëàãèíà HwHotKeys
{ 0x315b3800, 0x8258, 0x44c4, { 0xb6, 0xe, 0x58, 0xc5, 0xb, 0x93, 0x3, 0xb6 } }
};
extern "C" __declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD)
{
return &PluginInfoEx;
}
// ============================================================================
extern "C" __declspec(dllexport) int Load(void)
{
// çàãðóæàåì (èç ÁÄ) íàñòðîéêè ïëàãèíà
code_Close = db_get_dw(0, __DbModName, "Close", 0);
code_HideShow = db_get_dw(0, __DbModName, "HideShow", 0);
code_ReadMsg = db_get_dw(0, __DbModName, "ReadMsg", 0);
// óñòàíîâêà êîäà ëîêàëèçàöèè - ìàêðîñ mir_getLP(PlgInfoEx)
mir_getLP(&PluginInfoEx);
// Èíòåðôåéñ êîíòàêòëèñòà - ìàêðîñ çàïîëíÿåò CLIST_INTERFACE *pcli;
pcli = Clist_GetInterface();
// ðåãèñòðàöèÿ äèàëîãà îïöèé
HookEvent(ME_OPT_INITIALISE, initializeOptions);
// óñòàíîâêà õóêà äëÿ íèçêîóðîâíåâîé îáðàáîòêè õîòêååâ
hHook = SetWindowsHookExA(WH_KEYBOARD_LL, key_hook, hInstance, 0);
// StringCbPrintfA(key_name_buffer, 100, "hHook = 0x%x, Err = %u", hHook, GetLastError);
// MessageBoxA(0, key_name_buffer, 0, 0);
return 0;
}
// ====================================
int initializeOptions(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE OptDlgPg = { sizeof(OptDlgPg) };
OptDlgPg.position = 100000000;
OptDlgPg.hInstance = hInstance;
OptDlgPg.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
OptDlgPg.pszTemplate = MAKEINTRESOURCEA(dlg_options);
OptDlgPg.szGroup.w = LPGENW("Customize");
OptDlgPg.szTitle.w = LPGENW("Hardware HotKeys");
OptDlgPg.pfnDlgProc = OptDlgProc;
OptDlgPg.hLangpack = hLangpack;
Options_AddPage(wParam, &OptDlgPg);
return 0;
}
// ============================================================================
extern "C" __declspec(dllexport) int Unload(void)
{
UnhookWindowsHookEx(hHook);
return 0;
}
// ============================================================================
|