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

      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