• Login
Community
  • Login

opened file does not get the focus at first launch of npp only

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
9 Posts 3 Posters 897 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
    asphodelus
    last edited by May 14, 2024, 5:50 PM

    Example:

    1. I copy some code from dreamweaver and I want to paste it in a html file saved on desktop. So,
    2. I right-click the file and from the context menu I select Edit with Notepad++
    3. Then I use Ctrl+A to highlight the whole code of the file so I can replace it with the copied one, but nothing happens.
    4. I have to first click somewhere in the npp window and then re-use Ctrl+A to highlight the code.

    That behavior occurs only the first time I open npp. If I close / re-open it the Ctrl+A works as expected.
    Also, Ctrl+A is just a sample action. As the window does not get the focus, I can’t even use the keyboard to type a word.

    notepad++ 8.6.5 (64-bit) on windows 11

    M L 2 Replies Last reply May 14, 2024, 9:22 PM Reply Quote 0
    • M
      mkupper @asphodelus
      last edited by May 14, 2024, 9:22 PM

      @asphodelus I’m unable to reproduce this. From Windows Explorer when I right click on a file Explorer.exe launches a copy of C:\WINDOWS\system32\DllHost.exe that apparently figures out the list of right click options and displays it. When I select Edit with Notepad++ then that instance of DllHost.exe starts "C:\Program Files\Notepad++\notepad++.exe" "...path to the file I had right clicked and chosen to edit" Notepad++ starts up and it and that file has focus. I can start using the keyboard, such as Ctrl+A right away.

      My guess is that you have something, possibly a Notepad++ plugin, that is stealing the focus when you first start notepad++.exe. Rather than guessing at your Windows and Notepad++ configuration and walking through all possible permutations of guesses please post your Debug info per what’s in Please Read This Before Posting.

      A 1 Reply Last reply May 15, 2024, 7:56 AM Reply Quote 2
      • A
        asphodelus @mkupper
        last edited by May 15, 2024, 7:56 AM

        @mkupper
        well, that’s my Debug info:
        Notepad++ v8.6.5 (64-bit)
        Build time : Mar 29 2024 - 17:04:43
        Path : C:\Program Files\Notepad++\notepad++.exe
        Command Line :
        Admin mode : OFF
        Local Conf mode : OFF
        Cloud Config : OFF
        Periodic Backup : OFF
        OS Name : Windows 11 Home (64-bit
        OS Version : 23H2
        OS Build : 22631.3593
        Current ANSI codepage : 1253
        Plugins :
        ComparePlugin (2.0.2)
        mimeTools (3.1)
        NppConverter (4.6)
        NppExport (0.4)

        As I can recall, the only extra (added at a later time) is the ComparePlugin.

        Thanks.

        M 1 Reply Last reply May 15, 2024, 6:40 PM Reply Quote 0
        • M
          mkupper @asphodelus
          last edited by May 15, 2024, 6:40 PM

          @asphodelus, that is a puzzle then. I’m running the exact same version of Windows. I added the Compare Plugin and tested “Edit with Notepad++” with a file. Notepad++ was started, and the file I chose has focus.

          I also tried to set something closer to what you are doing by adding an HTML file to my desktop. Right click and Edit with Noteppad++ works fine. It starts Notepad++ and my test.htm file has focus.

          In re-reading your original post it’s not clear if Notepad++ has focus. Let’s do this.

          • Close the file in Notepad++ and close Notepad++.
          • Right click on your HTML file and select Edit with Notepad++
          • Do Windows+Tab on the keyboard. That is, hold the Windows key down and while doing that press Tab.

          You should see a series of rectangles, one for each open app. The app with the blue border around it is the one that should have focus. Is it Notepad++? If it’s not Notepad++ then I would try closing apps, such as Dreamweaver, to see if they are stealing focus.

          Google finds a Windows focus debugging app, Windows Focus Logger that looks useful. I tried it while it generates a lot of noise it may well give you a clue. I learned that when I right clicked on my test file and moved the mouse up towards Edit with Notepad++ that each of the right click options had focus as it was briefly highlighted as you moved the mouse up.

          To make it easier to find the right place in the log file I enabled the seconds display on my system tray clock (right click on the taskbar, select Taskbar settings, Expand Taskbar behaviors at the bottom, and enable Show seconds in the system tray clock. That way when you do the Edit with Notepad++ you can take note of the exact time you did that and then hunt for that time stamp in WindowFocusLogger’s logfile. Also, make the test HTML file very small. For some reason the WindowFocusLogger app is grabs and logs the entire contents of the HTML file several times when I did the test. I made a test HTML file on the desktop that only has <!-- My HTML file --> with no trailing newline.

          I used WindowFocusLogger.exe 20 from the command prompt which means it will run and log for 20 seconds. After starting WindowFocusLogger I waited bit, right clicked on the test HTML file, and waited a bit with Edit with Notepad++ selected. I then clicked to start Notepad++ and then simply watched the screen without touching anything until the command prompt’s title changed back from WindowFocusLogger back to Command Prompt.

          Here is what was logged for me. You can see me moving the mouse up through the right click options towards Edit with Notepad++. I started Notepad++ at `15/05/2024 11:23:05 and at 11:23:06 the Notepad++ application had focus. It logged the contents of the HTML file six times but as part of that it also showed that Notepad++ never lost focus. Oddly, WindowFocusLogger does not kick out a log line as part of terminating. I started it at 11:22:55 and so it ended 20 seconds later at 11:23:15.

          **********************************************
          Window Focus Logger 1.0
          Start time of registration: 11:22:55 AM
          Copyright(c) www.adminscope.com 2014-2024
          Free for personal and commercial use.
          **********************************************
          Focus changed;15/05/2024 11:22:58;Name:Program Manager;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:58;Name:test;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:58;Name:test;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:58;Name:test;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:58;Name:test;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:59;Name:Properties;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:59;Name:Rename;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:59;Name:Delete;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:59;Name:Create shortcut;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:59;Name:Copy;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:59;Name:Cut;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:59;Name:Send to;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:59;Name:Restore previous versions;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:59;Name:Share;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:59;Name:Copy as path;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:59;Name:Give access to;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:59;Name:Open with;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:22:59;Name:Scan with Microsoft Defender...;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:23:00;Name:Add to Favorites;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:23:00;Name:Edit with Notepad++;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:23:05;Name:test;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:23:06;Name:<!-- My HTML file -->;Processname:Notepad++;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:23:06;Name:<!-- My HTML file -->;Processname:Notepad++;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:23:06;Name:<!-- My HTML file -->;Processname:Notepad++;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:23:06;Name:<!-- My HTML file -->;Processname:Notepad++;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:23:06;Name:<!-- My HTML file -->;Processname:Notepad++;Offscreen:False;KeyboardFocus:True;UIenabled:True
          Focus changed;15/05/2024 11:23:06;Name:<!-- My HTML file -->;Processname:Notepad++;Offscreen:False;KeyboardFocus:True;UIenabled:True
          
          A 1 Reply Last reply May 16, 2024, 4:05 PM Reply Quote 2
          • A
            asphodelus @mkupper
            last edited by asphodelus May 16, 2024, 4:10 PM May 16, 2024, 4:05 PM

            @mkupper
            Thank you very much for your detailed analysis. However…

            As I have said, the problem occurs only the first time I use the Edit With Notepad++ command. (The first time I open my pc, after a restart, etc). So, I tried your suggestion after a restart and I got the following log results:

            **********************************************
            Window Focus Logger 1.0
            Start time of registration: 6:32:01 μμ
            Copyright(c) www.adminscope.com 2014-2024
            Free for personal and commercial use.
            **********************************************
            Focus changed;16/05/2024 18:32:03;Name:test.html;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
            Focus changed;16/05/2024 18:32:04;Name:;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
            Focus changed;16/05/2024 18:32:04;Name:Cut;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
            Focus changed;16/05/2024 18:32:06;Name:;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
            

            Then, a few minutes later I tried again, without restarting, and I got the following log results:

            **********************************************
            Window Focus Logger 1.0
            Start time of registration: 6:36:16 μμ
            Copyright(c) www.adminscope.com 2014-2024
            Free for personal and commercial use.
            **********************************************
            Focus changed;16/05/2024 18:36:18;Name:Popup;Processname:explorer;Offscreen:True;KeyboardFocus:True;UIenabled:True
            Focus changed;16/05/2024 18:36:18;Name:Popup;Processname:explorer;Offscreen:True;KeyboardFocus:True;UIenabled:True
            Focus changed;16/05/2024 18:36:18;Name:Cut;Processname:explorer;Offscreen:False;KeyboardFocus:False;UIenabled:True
            Focus changed;16/05/2024 18:36:18;Name:Popup;Processname:explorer;Offscreen:True;KeyboardFocus:True;UIenabled:True
            Focus changed;16/05/2024 18:36:19;Name:;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
            Focus changed;16/05/2024 18:36:19;Name:;Processname:explorer;Offscreen:False;KeyboardFocus:True;UIenabled:True
            Focus changed;16/05/2024 18:36:23;Name:;Processname:Idle;Offscreen:False;KeyboardFocus:False;UIenabled:False
            Focus changed;16/05/2024 18:36:23;Name:<!-- My HTML file -->;Processname:notepad++;Offscreen:False;KeyboardFocus:True;UIenabled:True
            Focus changed;16/05/2024 18:36:23;Name:<!-- My HTML file -->;Processname:notepad++;Offscreen:False;KeyboardFocus:True;UIenabled:True
            Focus changed;16/05/2024 18:36:23;Name:<!-- My HTML file -->;Processname:notepad++;Offscreen:False;KeyboardFocus:True;UIenabled:True
            Focus changed;16/05/2024 18:36:23;Name:<!-- My HTML file -->;Processname:notepad++;Offscreen:False;KeyboardFocus:True;UIenabled:True
            

            As you can see the second try was successful. So, I don’t have a clue what is going on and the problem is that I have tried the same action with different applications (copy from one / paste to another, using commands of the context menu) such as Notepad, UltraEdit, MS Word and all work as expected.

            Thanks again for your help.

            M 1 Reply Last reply May 17, 2024, 6:19 PM Reply Quote 0
            • M
              mkupper @asphodelus
              last edited by May 17, 2024, 6:19 PM

              @asphodelus said in opened file does not get the focus at first launch of npp only:

              As I have said, the problem occurs only the first time I use the Edit With Notepad++ command.

              I had wondered what you meant by that in the first post. Thank you for clarifying.

              Your first Window Focus Logger log is a puzzle as it shows that Explorer kept the focus and Notepad++ never got it. I’ll need to reconfigure a few things to try to replicate your setup. I power off my machine every night and reboot in the morning. Among other things, my logon script starts Notepad++. Usually I power on my machine, log in, and then do my morning routine such as a cup of coffee. When I come back to my computer it’s booted and sitting at Notepad++, which I’m pretty sure has focus. I said “pretty sure” as the first thing I normally do is Ctrl+Tab to the command prompt window that I use as the main shell.

              I can get closer to your setup by commenting out starting Notepad++ from the logon script and then seeing what happens when I right click on Desktop/Test.htm to see if Notepad++ has focus.

              I started to do that and found a note to myself about why I start Notepad++ as part of my login script.

              Start Notepad++
              
              The intent here is usually the first thing I do is to run zn.bat. At the
              start of a new day zn.bat uses Notepad++ to open several files. If
              Notepad++ has not been loaded since the system booted and is slow to
              load then it gets slightly confused and tends to open the files
              requested by zn.bat in tab positions 1 and 2 rather than at the end of
              the existing tab list. Thus, we start Notepad++ here to get Notepad++'s
              default session fully loaded before we later run zn.bat.
              

              I have replaced that initial startup of Notepad++ with

              start Notepad c:\Users\mkupper\Desktop\npp-focus-issue.txt
              

              which will fire up Microsoft Notepad to show me notes about the lack of focus test I’ll try tomorrow morning.

              My zn.bat is opens a daily working notes file. My thought when I read that note to myself is that this may well be similar to your issue. Notepad++ seems to have a race condition when initializing. It has never bothered me enough to report it as a bug plus the steps to reproduce will be challenging.

              I had worked around the presumed race condition it by pre-launching Notepad++, which should also work for you.

              A 1 Reply Last reply May 18, 2024, 8:31 AM Reply Quote 0
              • L
                Lycan Thrope @asphodelus
                last edited by Lycan Thrope May 17, 2024, 7:18 PM May 17, 2024, 7:16 PM

                @asphodelus ,
                I also can’t reproduce this error, but I’m using Win 10 still, and was using an .asm file for the copy/paste. To be fair, I seldom use keyboard shortcuts other than the standard CNTRL C,V and X for copy,pasting and deleting selected text, so using the CNTRL A was a stretch for me to begin with. :-)

                However, without getting as immersed as @mkupper is, I also can’t reproduce this, and since @mkupper is using Win11, I can’t lazily point out that might be the problem. :-)
                Good luck.

                1 Reply Last reply Reply Quote 1
                • A
                  asphodelus @mkupper
                  last edited by May 18, 2024, 8:31 AM

                  I had worked around the presumed race condition it by pre-launching Notepad++, which should also work for you.

                  I’ve tried pre-launching, it worked, and I’ll stick to this workaround at least for now, as I hope this issue will be resolved the next clean install of windows, which I have planned for after the summer :)

                  Thanks

                  M 1 Reply Last reply May 18, 2024, 4:49 PM Reply Quote 0
                  • M
                    mkupper @asphodelus
                    last edited by May 18, 2024, 4:49 PM

                    @asphodelus said in opened file does not get the focus at first launch of npp only:

                    I’ve tried pre-launching, it worked, and I’ll stick to this workaround at least for now, as I hope this issue will be resolved the next clean install of windows, which I have planned for after the summer :)

                    Good luck with that.

                    This morning I booted and rebooted a few times this morning trying to reproduce the issue but was not successful other than when doing a deliberate effort to start Notepad++ without giving it focus.

                    The first time I tried the machine was so early in the booting process that Window Focus Logger did not start logging until I was done with the test. Window Focus Logger uses Microsoft .NET Framework 4 meaning Window Focus Logger hung until .NET Framework was available and ready. While Window Focus Logger was hung, I found that right click on test.htm and selecting Edit with Notepad++ worked find. Notepad++ started and test.htm had focus in less than a second. It shows how lightweight Notepad++ is in terms of system resources needed.

                    I rebooted a few more times, each time giving the system a little more time so that .NET Framework 4 could be loaded by Window Focus Logger. With logging enabled I could see that Notepad++ was getting focus when I did the right click / edit test on test.htm.

                    The Windows desktop has a feature where if you are holding the shift key down as you start an application then it will launch an instance of that application but does not hand focus to it. This is mainly intended for use on the task bar to start extra instances of something but it also works on the desktop and start menu. So, I right click on the Test icon on the desktop, move the mouse down a little to Edit with Notepad++, hold the shift key down, and then left or normal click the mouse will start Notepad++ which opens displays test.htm while also not getting focus. That replicates what happens to you.

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