Начальный коммит
This commit is contained in:
@@ -0,0 +1,186 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Ðóññêèé (Ðîññèÿ) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
|
||||
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
|
||||
#pragma code_page(1251)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_ICON1 ICON "icon.ico"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOGEX 0, 0, 201, 223
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Î ïðîãðàììå"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "ÎÊ",IDOK,144,201,50,14
|
||||
CTEXT "IDC_STATIC_BASEDON",IDC_STATIC_BASEDON,7,185,187,10
|
||||
CTEXT "IDC_STATIC_APPINFO",IDC_STATIC_APPINFO,7,7,186,22
|
||||
EDITTEXT IDC_INFO,7,31,187,149,ES_MULTILINE | ES_READONLY | WS_VSCROLL
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_ABOUTBOX, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 194
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 215
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AFX_DIALOG_LAYOUT
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "041904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "serenitatis"
|
||||
VALUE "FileDescription", "SwitchyAlt"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
VALUE "InternalName", "SwitchyAlt.exe"
|
||||
VALUE "LegalCopyright", "2026, serenitatis"
|
||||
VALUE "OriginalFilename", "SwitchyAlt.exe"
|
||||
VALUE "ProductName", "SwitchyAlt"
|
||||
VALUE "ProductVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x419, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_ABOUT_TEXT "Ïåðåêëþ÷àòåëü ðàñêëàäêè êëàâèàòóðû ïðè ïîìîùè ïðàâîé êëàâèøè Alt.\r\nÄëÿ âðåìåííîãî îòêëþ÷åíèÿ èñïîëüçóéòå íàæàòèå ëåâîãî è ïðàâîãî Alt îäíîâðåìåííî èëè ñîîòâåòñòâóþùèé ïóíêò êîíòåêñòíîãî ìåíþ çíà÷êà â òðåå.\r\n\r\n******************************************\r\nÈñòîðèÿ âåðñèé\r\n\r\n1.0\r\n- Íà÷àëüíûé ðåëèç."
|
||||
IDS_APP_MUTEX_ERROR "Óæå çàïóùåí îäèí ýêçåìïëÿð SwitchyAlt"
|
||||
IDS_APP_ALREADY_RUNNING "Óæå çàïóùåí îäèí ýêçåìïëÿð SwitchyAlt"
|
||||
IDS_ERROR_REG_CLASS "Îøèáêà ðåãèñòðàöèè êëàññà îêíà"
|
||||
IDS_ERROR_CREATE_WINDOW "Îøèáêà ñîçäàíèÿ îêíà"
|
||||
IDS_ERROR_TRAY_ICON "Îøèáêà äîáàâëåíèÿ èêîíêè â òðåå"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_ERROR_SETHOOK "Îøèáêà SetWindowsHookEx"
|
||||
IDS_MENU_PAUSE "Ïðèîñòàíîâèòü"
|
||||
IDS_MENU_RESUME "Âîçîáíîâèòü"
|
||||
IDS_MENU_ABOUT "Î ïðîãðàììå"
|
||||
IDS_MENU_EXIT "Âûõîä"
|
||||
IDS_TRAY_TOOLTIP "SwitchyAlt"
|
||||
IDS_ABOUT_TITLE "Î ïðîãðàììå"
|
||||
IDS_BASEDON "Îñíîâàíî íà https://github.com/erryox/Switchy"
|
||||
IDS_APPINFO "SwitchyAlt 1.0\r\n 2026, serenitatis."
|
||||
END
|
||||
|
||||
#endif // Ðóññêèé (Ðîññèÿ) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{16A46215-C3FC-4F84-966D-22B97CADE8C0}</ProjectGuid>
|
||||
<RootNamespace>SwitchyAlt</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>SwitchyAlt</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EntryPointSymbol>
|
||||
</EntryPointSymbol>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Switchy.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="icon.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Switchy.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="icon.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 361 KiB |
+253
@@ -0,0 +1,253 @@
|
||||
#include <windows.h>
|
||||
#include <shellapi.h>
|
||||
#include <commctrl.h>
|
||||
#include "resource.h"
|
||||
|
||||
#pragma comment(lib, "comctl32.lib")
|
||||
#pragma comment(lib, "user32.lib")
|
||||
#pragma comment(lib, "shell32.lib")
|
||||
|
||||
#pragma comment(linker, \
|
||||
"\"/manifestdependency:type='win32' " \
|
||||
"name='Microsoft.Windows.Common-Controls' " \
|
||||
"version='6.0.0.0' " \
|
||||
"processorArchitecture='*' " \
|
||||
"publicKeyToken='6595b64144ccf1df' " \
|
||||
"language='*'\"")
|
||||
|
||||
#define WM_TRAYNOTIFY (WM_USER + 100)
|
||||
#define ID_TRAYICON 1
|
||||
#define IDM_EXIT 1001
|
||||
#define IDM_TOGGLE 1002
|
||||
#define IDM_ABOUT 1003
|
||||
|
||||
HHOOK hHook = NULL;
|
||||
HWND hWndHidden = NULL;
|
||||
NOTIFYICONDATA nid = { 0 };
|
||||
BOOL enabled = TRUE;
|
||||
BOOL keystrokeRightAltProcessed = FALSE;
|
||||
|
||||
HINSTANCE g_hInstance = NULL;
|
||||
|
||||
LPCTSTR LoadStr(UINT id)
|
||||
{
|
||||
static TCHAR buf[1024];
|
||||
buf[0] = TEXT('\0');
|
||||
LoadString(g_hInstance, id, buf, _countof(buf));
|
||||
return buf;
|
||||
}
|
||||
|
||||
void ShowError(UINT id)
|
||||
{
|
||||
MessageBox(NULL, LoadStr(id), TEXT("SwitchyAlt"), MB_OK | MB_ICONERROR);
|
||||
}
|
||||
|
||||
void SwitchLayout()
|
||||
{
|
||||
HWND hwndForeground = GetForegroundWindow();
|
||||
if (!hwndForeground) return;
|
||||
|
||||
char className[256];
|
||||
GetClassNameA(hwndForeground, className, sizeof(className));
|
||||
|
||||
BOOL isRDP = (strstr(className, "TscShellContainerClass") != NULL);
|
||||
BOOL isConsole = (strstr(className, "ConsoleWindowClass") != NULL);
|
||||
|
||||
if (isRDP || isConsole)
|
||||
{
|
||||
INPUT inputs[4] = { 0 };
|
||||
for (int i = 0; i < 4; i++) inputs[i].type = INPUT_KEYBOARD;
|
||||
inputs[0].ki.wVk = VK_MENU; inputs[0].ki.wScan = 0x38;
|
||||
inputs[1].ki.wVk = VK_SHIFT; inputs[1].ki.wScan = 0x2A;
|
||||
inputs[2].ki.wVk = VK_SHIFT; inputs[2].ki.wScan = 0x2A; inputs[2].ki.dwFlags = KEYEVENTF_KEYUP;
|
||||
inputs[3].ki.wVk = VK_MENU; inputs[3].ki.wScan = 0x38; inputs[3].ki.dwFlags = KEYEVENTF_KEYUP;
|
||||
SendInput(4, inputs, sizeof(INPUT));
|
||||
}
|
||||
else
|
||||
{
|
||||
GUITHREADINFO gti = { sizeof(GUITHREADINFO) };
|
||||
HWND targetWnd = hwndForeground;
|
||||
|
||||
if (GetGUIThreadInfo(0, >i) && gti.hwndFocus != NULL)
|
||||
{
|
||||
targetWnd = gti.hwndFocus;
|
||||
}
|
||||
|
||||
PostMessage(targetWnd, WM_INPUTLANGCHANGEREQUEST, 0, (LPARAM)HKL_NEXT);
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (nCode != HC_ACTION)
|
||||
return CallNextHookEx(hHook, nCode, wParam, lParam);
|
||||
|
||||
KBDLLHOOKSTRUCT* p = (KBDLLHOOKSTRUCT*)lParam;
|
||||
|
||||
if (p->flags & LLKHF_INJECTED)
|
||||
return CallNextHookEx(hHook, nCode, wParam, lParam);
|
||||
|
||||
if (p->vkCode == VK_RMENU)
|
||||
{
|
||||
if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN)
|
||||
{
|
||||
if (!keystrokeRightAltProcessed)
|
||||
{
|
||||
keystrokeRightAltProcessed = TRUE;
|
||||
|
||||
if (GetAsyncKeyState(VK_LMENU) & 0x8000)
|
||||
{
|
||||
enabled = !enabled;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
SwitchLayout();
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (wParam == WM_KEYUP || wParam == WM_SYSKEYUP)
|
||||
{
|
||||
keystrokeRightAltProcessed = FALSE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return CallNextHookEx(hHook, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
SetDlgItemText(hDlg, IDC_INFO, LoadStr(IDS_ABOUT_TEXT));
|
||||
SetDlgItemText(hDlg, IDC_STATIC_APPINFO, LoadStr(IDS_APPINFO));
|
||||
SetDlgItemText(hDlg, IDC_STATIC_BASEDON, LoadStr(IDS_BASEDON));
|
||||
return (INT_PTR)TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||
{
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
return (INT_PTR)TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (INT_PTR)FALSE;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case WM_TRAYNOTIFY:
|
||||
if (lParam == WM_RBUTTONUP)
|
||||
{
|
||||
POINT pt;
|
||||
GetCursorPos(&pt);
|
||||
|
||||
HMENU hMenu = CreatePopupMenu();
|
||||
if (hMenu)
|
||||
{
|
||||
AppendMenu(hMenu, MF_STRING, IDM_TOGGLE,
|
||||
enabled ? LoadStr(IDS_MENU_PAUSE) : LoadStr(IDS_MENU_RESUME));
|
||||
|
||||
AppendMenu(hMenu, MF_STRING, IDM_ABOUT, LoadStr(IDS_MENU_ABOUT));
|
||||
AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
|
||||
AppendMenu(hMenu, MF_STRING, IDM_EXIT, LoadStr(IDS_MENU_EXIT));
|
||||
|
||||
SetForegroundWindow(hwnd);
|
||||
UINT cmd = TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_NONOTIFY, pt.x, pt.y, 0, hwnd, NULL);
|
||||
DestroyMenu(hMenu);
|
||||
|
||||
if (cmd == IDM_TOGGLE) enabled = !enabled;
|
||||
if (cmd == IDM_ABOUT)
|
||||
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutDlgProc);
|
||||
if (cmd == IDM_EXIT)
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
|
||||
HANDLE hMutex = CreateMutex(NULL, FALSE, TEXT("SwitchyAltUnique"));
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
ShowError(IDS_APP_MUTEX_ERROR);
|
||||
return 1;
|
||||
}
|
||||
|
||||
WNDCLASSEX wc = { sizeof(WNDCLASSEX) };
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.hInstance = hInstance;
|
||||
wc.lpszClassName = TEXT("SwitchyHiddenClass");
|
||||
|
||||
if (!RegisterClassEx(&wc))
|
||||
{
|
||||
ShowError(IDS_ERROR_REG_CLASS);
|
||||
return 1;
|
||||
}
|
||||
|
||||
hWndHidden = CreateWindowEx(0, wc.lpszClassName, TEXT("SwitchyAlt"),
|
||||
0, 0, 0, 0, 0, HWND_MESSAGE, NULL, hInstance, NULL);
|
||||
|
||||
if (!hWndHidden)
|
||||
{
|
||||
ShowError(IDS_ERROR_CREATE_WINDOW);
|
||||
return 1;
|
||||
}
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
nid.cbSize = sizeof(NOTIFYICONDATA);
|
||||
nid.hWnd = hWndHidden;
|
||||
nid.uID = ID_TRAYICON;
|
||||
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||
nid.uCallbackMessage = WM_TRAYNOTIFY;
|
||||
nid.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
|
||||
lstrcpy(nid.szTip, LoadStr(IDS_TRAY_TOOLTIP));
|
||||
|
||||
if (!Shell_NotifyIcon(NIM_ADD, &nid))
|
||||
{
|
||||
ShowError(IDS_ERROR_TRAY_ICON);
|
||||
}
|
||||
|
||||
hHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, hInstance, 0);
|
||||
if (!hHook)
|
||||
{
|
||||
ShowError(IDS_ERROR_SETHOOK);
|
||||
Shell_NotifyIcon(NIM_DELETE, &nid);
|
||||
DestroyWindow(hWndHidden);
|
||||
return 1;
|
||||
}
|
||||
|
||||
MSG msg;
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
UnhookWindowsHookEx(hHook);
|
||||
Shell_NotifyIcon(NIM_DELETE, &nid);
|
||||
DestroyWindow(hWndHidden);
|
||||
|
||||
return (int)msg.wParam;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Âêëþ÷àåìûé ôàéë, ñîçäàííûé â Microsoft Visual C++.
|
||||
// Èñïîëüçóåòñÿ Switchy.rc
|
||||
//
|
||||
#define IDI_ICON1 102
|
||||
#define IDD_ABOUTBOX 104
|
||||
#define IDS_ABOUT_TEXT 106
|
||||
#define IDS_APP_MUTEX_ERROR 107
|
||||
#define IDS_APP_ALREADY_RUNNING 108
|
||||
#define IDS_ERROR_REG_CLASS 109
|
||||
#define IDS_ERROR_CREATE_WINDOW 110
|
||||
#define IDS_ERROR_TRAY_ICON 111
|
||||
#define IDS_ERROR_SETHOOK 112
|
||||
#define IDS_MENU_PAUSE 113
|
||||
#define IDS_MENU_RESUME 114
|
||||
#define IDS_MENU_ABOUT 115
|
||||
#define IDS_MENU_EXIT 116
|
||||
#define IDS_TRAY_TOOLTIP 117
|
||||
#define IDS_ABOUT_TITLE 118
|
||||
#define IDS_BASEDON 119
|
||||
#define IDS_APPINFO 120
|
||||
#define IDC_CUSTOM1 1002
|
||||
#define IDC_INFO 1004
|
||||
#define IDC_STATIC_BASEDON 1005
|
||||
#define IDC_STATIC_APPINFO 1007
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 121
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1008
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user