Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed switching layouts in other programs #1

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
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
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@

This small windowless program allow you swich keyboard layout with CapsLock key. While non-standard keyboard layout will bright Scroll Lock indicator. Usual Caps Lock function available via Shift + CapsLock key combination. I recommend set "To turn off Caps Lock -- SHIFT key" in Windows Advanced Key Settings.

Forked from [here](http://flydom.ru/capslang)
Fixed switching layouts in programs running on behalf of the administrator,
**to do this, run the program as an administrator.**

Исправлено переключение раскладок в программах, запущенных от имени администратора,
**для этого запустите программу от имени администратора.**

_Binaries compiled using mingw g++compiler_


## Download
#### Toggles the standard layout ALT+SHIFT
#### Переключает стандартную раскладку ALT+SHIFT

Download [mingw-caps-min.exe](https://github.com/steelswing/capslang/releases/download/2.0/mingw-caps-min.exe)\
Download [mingw-capslang.exe](https://github.com/steelswing/capslang/releases/download/2.0/mingw-capslang.exe)

Forked from [here](https://github.com/edanko/capslang)

## Complation
You can compile it using Visual Studio or [lccwin32](https://lcc-win32.services.net/)
Expand All @@ -13,7 +29,7 @@ Project file for lccwin32 included
Copy caps-min.exe to your Startup (%AppData%\Microsoft\Windows\Start Menu\Programs\Startup) folder.

## Run
Just run caps-min.exe and enjoy
Just run mingw-caps-min.exe and enjoy

## Exit
To close programm press Ctrl + Alt + L
15 changes: 11 additions & 4 deletions caps-min.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/*
CapsLang by Ryurik 2003-11-12, updated 2006-10-24


11-04-2023
Updated by LWJGL2 for correct work at startup from the administrator.
Updated by LWJGL2 для корректной работы при запуске от администратора.

This small windowless program allow you swich keyboard layout with CapsLock key.
While non-standard keyboard layout will bright Scroll Lock indicator

Expand All @@ -21,6 +25,7 @@

#include <windows.h>
#include <tchar.h>
#include <winuser.h>

#define WH_KEYBOARD_LL 13
typedef struct tagKBDLLHOOKSTRUCT {
Expand Down Expand Up @@ -63,9 +68,11 @@ LRESULT CALLBACK KbdHook(int nCode,WPARAM wParam,LPARAM lParam) {
if (wParam==WM_KEYDOWN) {
HWND hWnd=GetCaretWindow();
if (hWnd) {
PostMessage(hWnd,WM_INPUTLANGCHANGEREQUEST,0,(LPARAM)HKL_NEXT);
// PostMessage(hWnd,WM_INPUTLANGCHANGEREQUEST,(WPARAM)INPUTLANGCHANGE_FORWARD,0);
// PostMessage(hWnd,WM_INPUTLANGCHANGEREQUEST,(WPARAM)INPUTLANGCHANGE_FORWARD,(LPARAM)HKL_NEXT);
// ALT + SHIFT для переключения
keybd_event(VK_MENU, 0, 0, 0);
keybd_event(VK_SHIFT, 0, 0, 0);
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
return TRUE;
}
}
Expand Down
11 changes: 10 additions & 1 deletion capslang.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/*
CapsLang by Ryurik 2003-11-12, updated 2006-10-24

11-04-2023
Updated by LWJGL2 for correct work at startup from the administrator.
Updated by LWJGL2 для корректной работы при запуске от администратора.

This small windowless program allow you swich keyboard layout with CapsLock key.
While non-standard keyboard layout will bright Scroll Lock indicator
Expand All @@ -21,6 +25,7 @@

#include <windows.h>
#include <tchar.h>
#include <winuser.h>

#define WH_KEYBOARD_LL 13
typedef struct tagKBDLLHOOKSTRUCT {
Expand Down Expand Up @@ -56,7 +61,11 @@ LRESULT CALLBACK KbdHook(int nCode,WPARAM wParam,LPARAM lParam) {
if (wParam==WM_KEYDOWN) {
HWND hWnd=GetFocusWindow();
if (hWnd) {
PostMessage(hWnd,WM_INPUTLANGCHANGEREQUEST,0,(LPARAM)HKL_NEXT);
// ALT + SHIFT для переключения
keybd_event(VK_MENU, 0, 0, 0);
keybd_event(VK_SHIFT, 0, 0, 0);
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
ToggleLight();
return TRUE;
}
Expand Down