Community
    • 登入

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

    已排程 已置頂 已鎖定 已移動 General Discussion
    13 貼文 4 Posters 5.3k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • A KA
      A K
      最後由 編輯

      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 條回覆 最後回覆 回覆 引用 2
      • Scott SumnerS
        Scott Sumner @A K
        最後由 編輯

        @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 條回覆 最後回覆 回覆 引用 0
        • AZJIO AZJIOA
          AZJIO AZJIO
          最後由 編輯

          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 條回覆 最後回覆 回覆 引用 1
          • A KA
            A K
            最後由 編輯

            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 條回覆 最後回覆 回覆 引用 1
            • Mikhail VM
              Mikhail V @A K
              最後由 編輯

              @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 條回覆 最後回覆 回覆 引用 0
              • Scott SumnerS
                Scott Sumner
                最後由 編輯

                @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 條回覆 最後回覆 回覆 引用 5
                • AZJIO AZJIOA
                  AZJIO AZJIO
                  最後由 編輯

                  ; 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 條回覆 最後回覆 回覆 引用 1
                  • A KA
                    A K
                    最後由 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 條回覆 最後回覆 回覆 引用 0
                    • Mikhail VM
                      Mikhail V @A K
                      最後由 編輯

                      @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 條回覆 最後回覆 回覆 引用 1
                      • AZJIO AZJIOA
                        AZJIO AZJIO
                        最後由 編輯

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

                        1 條回覆 最後回覆 回覆 引用 0
                        • A KA
                          A K @Mikhail V
                          最後由 編輯

                          @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 條回覆 最後回覆 回覆 引用 0
                          • Mikhail VM
                            Mikhail V @A K
                            最後由 編輯

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

                            1 條回覆 最後回覆 回覆 引用 0
                            • Mikhail VM
                              Mikhail V @Scott Sumner
                              最後由 編輯

                              @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 條回覆 最後回覆 回覆 引用 0
                              • 第一個貼文
                                最後的貼文
                              The Community of users of the Notepad++ text editor.
                              Powered by NodeBB | Contributors