Feature Request: Change the color of the carriage depending on the keyboard layout
-
Hi, all!
I whant to propose an idea about changing color of carriage for different kayboard layouts (second language). This should happen at the time the keyboard layout is switched. The color of the carriage must be associated with the keyboard layout.
Does anyone want to create such a plagin or can it be done in the main program?
-
If you are going to propose an off-the-wall wacky feature (IMO), it might help that you also indicate WHY people other than yourself would find it useful.
-
In many countries English is not native and there are 2 keyboard layouts.
To make it clear in what language the text will be entered, the cursor must be different.
As far as I know, many things change color, for example brackets
I think it’s not difficult to implement, just make a request for the status of the keyboard layout
Show me what the program request for changing the color of the cursor looks like and I’ll make a script using AutoIt -
AZJIO laid out the reason well. Thanks to him.
When the text contains characters in two languages, you often change the keyboard layout.
In this situation it is convenient to have a tool that will remind you in which mode you are.
We discussed this problem with colleagues and decided that this is the easiest way: to change the color of the carriage.
-
@A-K
I see sense in indicating the layout when typing, that is a major problem,
(not only in notepad++, but in general).Though I don’t find the change of the caret color is enough visual feedback for the user.
Also, at a first glance, I don’t think changing the color depending on layout can be done
by means of NPP only. I can change the color of caret with Pythonscript eg., but
I can’t read the current keyboard layout. This will require some WinAPI calls to the system.
Probably it is possible, but I don’t know how to do it from Pythonscript.From UX point of view - I personally think it is better to do an AHK (autohotkey) solution to show
a color frame around the app’s window. For example, if layout is RU, it will draw a green frame
around the window border. This IMO will give better visual feedback, than just changing
the caret color. -
@Mikhail-V said:
…read the current keyboard layout. This will require some WinAPI calls to the system. Probably it is possible, but I don’t know how to do it from Pythonscript.
For purely educational purposes, here’s a way:
import ctypes buff = ctypes.create_unicode_buffer(1024) ctypes.windll.user32.GetKeyboardLayoutNameW(buff) console.write(buff.value)
:-)
-
; The name of the functions will help. This is AutoIt
Func GetActiveKeyboardLayout($hWnd)
Local $aRet = DllCall(‘user32.dll’, ‘long’, ‘GetWindowThreadProcessId’, ‘hwnd’, $hWnd, ‘ptr’, 0)
$aRet = DllCall(‘user32.dll’, ‘long’, ‘GetKeyboardLayout’, ‘long’, $aRet[0])
Return ‘0000’ & Hex($aRet[0], 4)
EndFunc ;==>GetActiveKeyboardLayout -
Initially, I was thinking about several solutions:
- carriage color
- characters next to the carriage
- color of the current line highlighting
Your decision:
4) a color frame around the app’s windowAt first I doubted. But after I saw that the size of the carriage can be configured (see pic) the doubts disappeared. In addition, it seems to me that it is easy to implement.
-
@A-K
OK, a block caret is more visible. Though if I’d need to type a lot with such caret, it looks too annoying to me. I prefer some splash image on a periphery. Anyway, setting caret size or some other GUI element is easy part. Hard part is how to make it work if you switch the layout.I agree that this problem is very annoying, when using 2 layouts, but I prefer to solve this problem system-wide. Obviously if I have a system-wide solution for it, I don’t really need it inside NPP also.
I’ve posted an AHK script in related question here:
https://superuser.com/a/1292388/456981But if you really want it only in NPP and using some of NPP’s GUI highlighting, you could write a Pythonscript which modifies your caret color/size, and bind
it to the some keyboard shortcut.
Then modify that AHK script so as it sends this exact keyboard sequence to NPP instead of showing the red square, and restrict the script to notepad++ only.
So it should work as you initially describe.But I’d really advise you to use a system-wide approach for obvious reasons.
-
TextCorrection - Maybe someone will be interested in another way. Just convert words.
-
To my mind, a text editor needs this function first. For other applications, this is less important. It would be convenient to have such a function without the use of additional tools such as a AutoHotkey.
Although a universal solution can also be useful. I’ll try to understand how to use the AutoHotkey and your script. Thank you very much for the tips!
-
@A-K
beware that currently my AHK script does not work on windows 10, it works only on windows 7. -
@Scott-Sumner said:
@Mikhail-V said:
…read the current keyboard layout. This will require some WinAPI calls to the system. Probably it is possible, but I don’t know how to do it from Pythonscript.
For purely educational purposes, here’s a way:
import ctypes buff = ctypes.create_unicode_buffer(1024) ctypes.windll.user32.GetKeyboardLayoutNameW(buff) console.write(buff.value)
This sort of works, but on windows 10 there is same issue as with AHK - it detects the layout
only once when the application starts, but when I switch the layout and repeat the script -
it returns same code value regardless of current layout.