Community
    • 登入

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

    已排程 已置頂 已鎖定 已移動 General Discussion
    13 貼文 4 Posters 5.4k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • 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