Community
    • Login

    Feature Request: Change the color of the carriage depending on the keyboard layout

    Scheduled Pinned Locked Moved General Discussion
    13 Posts 4 Posters 4.9k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A KA
      A K
      last edited by

      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?

      Scott SumnerS Mikhail VM 2 Replies Last reply Reply Quote 2
      • Scott SumnerS
        Scott Sumner @A K
        last edited by

        @A-K

        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.

        1 Reply Last reply Reply Quote 0
        • AZJIO AZJIOA
          AZJIO AZJIO
          last edited by

          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

          1 Reply Last reply Reply Quote 1
          • A KA
            A K
            last edited by

            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.

            1 Reply Last reply Reply Quote 1
            • Mikhail VM
              Mikhail V @A K
              last edited by

              @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.

              1 Reply Last reply Reply Quote 0
              • Scott SumnerS
                Scott Sumner
                last edited by

                @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)
                

                :-)

                Mikhail VM 1 Reply Last reply Reply Quote 5
                • AZJIO AZJIOA
                  AZJIO AZJIO
                  last edited by

                  ; 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

                  1 Reply Last reply Reply Quote 1
                  • A KA
                    A K
                    last edited by A K

                    @Mikhail-V

                    Initially, I was thinking about several solutions:

                    1. carriage color
                    2. characters next to the carriage
                    3. color of the current line highlighting

                    Your decision:
                    4) a color frame around the app’s window

                    At 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.

                    Alt text

                    Mikhail VM 1 Reply Last reply Reply Quote 0
                    • Mikhail VM
                      Mikhail V @A K
                      last edited by

                      @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/456981

                      But 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.

                      A KA 1 Reply Last reply Reply Quote 1
                      • AZJIO AZJIOA
                        AZJIO AZJIO
                        last edited by

                        TextCorrection - Maybe someone will be interested in another way. Just convert words.

                        1 Reply Last reply Reply Quote 0
                        • A KA
                          A K @Mikhail V
                          last edited by

                          @Mikhail-V

                          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!

                          Mikhail VM 1 Reply Last reply Reply Quote 0
                          • Mikhail VM
                            Mikhail V @A K
                            last edited by

                            @A-K
                            beware that currently my AHK script does not work on windows 10, it works only on windows 7.

                            1 Reply Last reply Reply Quote 0
                            • Mikhail VM
                              Mikhail V @Scott Sumner
                              last edited by

                              @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.

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post
                              The Community of users of the Notepad++ text editor.
                              Powered by NodeBB | Contributors