Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions SlxCom/SlxCom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "SlxComTools.h"
#include <set>
#include "SlxComDisableCtrlCopyInSameDir.h"
#include "SlxComKeyMapper.h"

#ifndef LVS_EX_SNAPTOGRID
#define LVS_EX_SNAPTOGRID 0x00080000 // Icons automatically snap to grid.
Expand Down Expand Up @@ -316,6 +317,8 @@ BOOL APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) {
CloseHandle(hOpenLastPathThread);
}
}

StartKeyMapper();
}

g_hinstDll = hInstance;
Expand Down
8 changes: 8 additions & 0 deletions SlxCom/SlxCom.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@
RelativePath=".\SlxComIconHandler.cpp"
>
</File>
<File
RelativePath=".\SlxComKeyMapper.cpp"
>
</File>
<File
RelativePath=".\SlxComOverlay.cpp"
>
Expand Down Expand Up @@ -516,6 +520,10 @@
RelativePath=".\SlxComIconHandler.h"
>
</File>
<File
RelativePath=".\SlxComKeyMapper.h"
>
</File>
<File
RelativePath=".\SlxComOverlay.h"
>
Expand Down
2 changes: 2 additions & 0 deletions SlxCom/SlxCom.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
<ClCompile Include="SlxComExpandDirFiles.cpp" />
<ClCompile Include="SlxComFactory.cpp" />
<ClCompile Include="SlxComIconHandler.cpp" />
<ClCompile Include="SlxComKeyMapper.cpp" />
<ClCompile Include="SlxComOverlay.cpp" />
<ClCompile Include="SlxComPeTools.cpp" />
<ClCompile Include="SlxComTools.cpp" />
Expand Down Expand Up @@ -270,6 +271,7 @@
<ClInclude Include="SlxComExpandDirFiles.h" />
<ClInclude Include="SlxComFactory.h" />
<ClInclude Include="SlxComIconHandler.h" />
<ClInclude Include="SlxComKeyMapper.h" />
<ClInclude Include="SlxComOverlay.h" />
<ClInclude Include="SlxComPeTools.h" />
<ClInclude Include="SlxComTools.h" />
Expand Down
6 changes: 6 additions & 0 deletions SlxCom/SlxCom.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@
<ClCompile Include="lib\SlxBase64.cpp">
<Filter>lib</Filter>
</ClCompile>
<ClCompile Include="SlxComKeyMapper.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="SlxCom.def">
Expand Down Expand Up @@ -265,6 +268,9 @@
<ClInclude Include="lib\SlxBase64.hxx">
<Filter>lib</Filter>
</ClInclude>
<ClInclude Include="SlxComKeyMapper.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SlxCom.rc">
Expand Down
80 changes: 80 additions & 0 deletions SlxCom/SlxComKeyMapper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#include <Windows.h>
#include <Shlwapi.h>
#include "SlxComKeyMapper.h"

extern HINSTANCE g_hinstDll;
static HHOOK gs_llKeyboardHook = NULL;
static DWORD gs_dwKeyboardTime = 0;

static LRESULT CALLBACK _LLKeyboardHook(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode == HC_ACTION) {
KBDLLHOOKSTRUCT* p = (KBDLLHOOKSTRUCT*)lParam;
WCHAR lpMessage[128] = { 0 };
wnsprintfW(lpMessage, RTL_NUMBER_OF(lpMessage), L"key pressed, virtual code: %d", p->vkCode);
OutputDebugStringW(lpMessage);

WCHAR lpVal[32] = { 0 };
wsprintfW(lpVal, L"%d", p->vkCode);
DWORD dwType;
DWORD dwData;
DWORD dwSize = sizeof(dwData);
if (ERROR_SUCCESS == SHGetValueW(HKEY_CURRENT_USER, L"Software\\Shilyx Studio\\SlxCom\\KeyMapper", lpVal, &dwType, &dwData, &dwSize)) {
if (dwType == REG_DWORD) {
wnsprintfW(lpMessage, RTL_NUMBER_OF(lpMessage), L"map key code %d->%d", p->vkCode, dwData);
OutputDebugStringW(lpMessage);

INPUT input = { 0 };
input.type = INPUT_KEYBOARD;
input.ki.wVk = (WORD)dwData;
input.ki.dwFlags = (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) ? KEYEVENTF_KEYUP : 0;
SendInput(1, &input, sizeof(INPUT));

return 1; // ��ֹ�¼���������
}
}
}

return CallNextHookEx(0, nCode, wParam, lParam);
}

static LRESULT CALLBACK _WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
if (WM_CREATE == uMsg) {
gs_llKeyboardHook = SetWindowsHookExW(WH_KEYBOARD_LL, _LLKeyboardHook, (HINSTANCE)g_hinstDll, 0);
}

return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}

static DWORD WINAPI _LLKeyboardHookThread(void* param) {
#define __CLS_NAME L"{FA9429D4-E65F-4c5a-8B45-88E0387D4A5A}"
WNDCLASSEXW wcex = { sizeof(wcex) };
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)_WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = g_hinstDll;
wcex.hIcon = LoadIcon(NULL, IDI_INFORMATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.lpszClassName = __CLS_NAME;

RegisterClassExW(&wcex);
HWND hWnd = CreateWindowExW(0, __CLS_NAME, NULL, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, g_hinstDll, NULL);
if (!IsWindow(hWnd)) { return 1; }
UpdateWindow(hWnd);

MSG msg;
while (GetMessage(&msg, hWnd, 0, 0)) {
TranslateMessage(&msg);
DispatchMessageA(&msg);
}

return 0;
}

void StartKeyMapper() {
static BOOL s_bFirst = TRUE;
if (s_bFirst) {
s_bFirst = FALSE;
CloseHandle(CreateThread(NULL, 0, _LLKeyboardHookThread, NULL, 0, NULL));
}
}
3 changes: 3 additions & 0 deletions SlxCom/SlxComKeyMapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void StartKeyMapper();
9 changes: 9 additions & 0 deletions SlxCom/SlxComWork_ni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ enum {
SYS_DISABLECTRLCOPYINSAMEDIR,
SYS_DEBUGBREAK,
SYS_WINDOWMANAGER,
SYS_KEYMAPPER, // ����ӳ��(�ļ�)
SYS_SHOWTIMEPALTE_DISABLE,
SYS_SHOWTIMEPALTE_PER60M,
SYS_SHOWTIMEPALTE_PER30M,
Expand Down Expand Up @@ -602,6 +603,13 @@ class MenuMgr {
);
break;

case SYS_KEYMAPPER: {
LPCWSTR lpHint = L"dbgview �в鿴���������룬���� DWORD ֵ�ڴ�ע����£��� 165=93 �ɽ��� ALT ��Ϊ�Ҽ��˵�";
SHSetValueW(HKEY_CURRENT_USER, L"Software\\Shilyx Studio\\SlxCom\\KeyMapper", L"���÷���", REG_SZ, (LPVOID)lpHint, (lstrlenW(lpHint) + 1) * sizeof(WCHAR));
BrowseForRegPath(L"HKEY_CURRENT_USER\\Software\\Shilyx Studio\\SlxCom\\KeyMapper");
}
break;

case SYS_SHOWTIMEPALTE_DISABLE:
m_nTimePlageIntervalMinutes = 0;
CheckMenuRadioItem(m_hMenu, SYS_SHOWTIMEPALTE_DISABLE, SYS_SHOWTIMEPALTE_PER1M, SYS_SHOWTIMEPALTE_DISABLE, MF_BYCOMMAND);
Expand Down Expand Up @@ -693,6 +701,7 @@ class MenuMgr {
AppendMenuW(m_hMenu, MF_STRING, SYS_WINDOWMANAGER, L"���ڹ�����(&W)...");
AppendMenuW(m_hMenu, MF_POPUP, (UINT)(UINT_PTR)hTimePlateMenu, L"���㱨ʱ(&T)");
AppendMenuW(m_hMenu, MF_POPUP, (UINT)(UINT_PTR)InitRegPathSubMenu(&nMenuId), L"ע������ͨ��(&R)");
AppendMenuW(m_hMenu, MF_POPUP, SYS_KEYMAPPER, L"����ӳ��(&M)");
AppendMenuW(m_hMenu, MF_SEPARATOR, 0, NULL);
AppendMenuW(m_hMenu, MF_STRING, SYS_RESETEXPLORER, L"��������Explorer(&E)");
if (g_bVistaLater) {
Expand Down