Community
    • Login

    Image Drag > Image Name or Image Code Switch

    Scheduled Pinned Locked Moved General Discussion
    7 Posts 5 Posters 5.5k 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.
    • Dennis StruckD
      Dennis Struck
      last edited by

      FOR NOTEPAD DESIGNERS: I do a lot of web page creation and insert a plethora of image names into the [html/css/script] code. To get the image name into the code I perform a lot of cut and paste. I could save at least an hour a day if I could drag the image icon into my NotePad session and have the image [file] name automatically fill the text space where I drop the image. As it is now, the image file code fills the text space. It would be fantastic to have a switch setting [under settings] that allows a user to select Code or File Name as the content of a drag and drop insert.

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Dennis Struck
        last edited by

        @Dennis-Struck

        Your description (after “as it is now…”) makes it sound like the image binary data is being copied into the middle of the current file you are editing with Notepad++. I believe what is really happening when you drag and drop into Notepad++ is that a new editor tab is being created, representing the file dropped. Your description versus what is happening is TWO DIFFERENT THINGS.

        That being said, I understand what you want. If you are using standard Windows Explorer, then copying a filename (so that you can put it into a text buffer you are editing with Notepad++) is a really labor-intensive process (as you have said).

        So…there are better ways. For example, it is super-quick and easy when you use XYPlorer as your file-manager: Click your desired file with the left mouse button and hold it; tap the right mouse button and a menu pops up with various choices for copying the current file/path to the clipboard. I use XYPlorer (obviously), but I presume other Explorer.exe replacements also provide the same simplicity for this type of action. I think one of these is truly hat you need.

        I guess my key point is that copying filenames from the file system is really a job for an Explorer-like program, not (really) Notepad++. It could be a Notepad++ feature, though; point taken. You can certainly make a feature suggestion (well within your right to do so), however, features are slow to get adopted when they are even accepted, and as you say, your need to save “an hour a day” is immediate. So…that’s about all I’ve got to say. :-)

        1 Reply Last reply Reply Quote 1
        • PeterJonesP
          PeterJones
          last edited by

          So, I have added a right-click action to Windows Explorer which copies the full path of the selected file.

          WARNING: This involves editing the registry. Use at your own risk.

          • regedit
          • HKEY_CLASSES_ROOT\
          •    AllFilesystemObjects\
            • if the shell\ subkey doesn’t exist, add New > Key = shell to the AllFilesystemObjects key
          •       shell\:
            • Right Click on shell\, add New > Key = CopyFullPath
          •          CopyFullPath\
            • Right Panel: (Default) : REG_SZ : Copy Full Path to Clipboard
            • Right Panel: Right Click in blank, New > String Value = Icon
            • Right Panel: Icon : REG_SZ : shell32.dll,-16763
            • Right Panel: Right click in blank, New > Key = command
          •             command\
            • Right Panel: (Default) : REG_SZ : cmd.exe /c (echo.|set /p=""%1"") | clip.exe

          Explanation of the command shown: cmd.exe /c runs everything that follows in a new command processor. The (echo.|set /p=""%1"") is some command-trickery to echo the filename, keeping the quotes around it; the | clip.exe pipes the output from the trickery to clip.exe, which is a Windows executable to add stuff to the Windows clipboard.

          At this point, if you open a new Explorer window, you should be able to right click on a file and choose “Copy Full Path to Clipboard”

          Sometimes, registry changes don’t propagate immediately. If it didn’t for you, you can log out and back in to force the refresh. (Or, if you have NirSoft’s nircmd.exe, you can run

          nircmd.exe sysrefresh
          nircmd.exe shellrefresh
          

          … which will ensure Windows Explorer will be refreshed.)

          But at this point, you should be able to copy the full path to a file to the clipboard, and then paste it into your document in Notepad++.

          Alan KilbornA 1 Reply Last reply Reply Quote 6
          • Alan KilbornA
            Alan Kilborn @PeterJones
            last edited by

            @PeterJones

            I think there are 2 camps on this one: The DOS/CMD.exe veterans that appreciate the elegance and utility of this…and those that can’t quit complaining that N++ can’t do this natively (and needs a new user interface to be a useful program). Upvoters are definitely in the first group! :-)

            1 Reply Last reply Reply Quote 1
            • MAPJe71M
              MAPJe71
              last edited by

              Why the additional set command instead of just echoing the argument value i.e. (echo.""%1"")?

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

                @MAPJe71

                If I try what you suggest, which I believe is: cmd.exe /c (echo.""%1"") | clip.exe , then running it yields a double set of surrounding "

                The obvious solution to that problem is to change it to: cmd.exe /c (echo."%1") | clip.exe , which seems to work equivalently to @PeterJones 's original suggestion.

                1 Reply Last reply Reply Quote 1
                • PeterJonesP
                  PeterJones
                  last edited by

                  @Alan-Kilborn: To the point of the second camp: I’m not sure whether dragging-and-dropping a file from a Windows Explorer into NPP is a Windows Explorer operation, or a NPP operation, or a strange mix, so I have my doubts whether there is anything you could do in the NPP code to optionally “intercept” that operation – but I’ve never coded a drag-and-drop interface, so I could be wrong.

                  @MAPJe71 & @Scott-Sumner: Yeah, there was a reason I didn’t explain that “command-trickery”: I had grabbed that command from some website a few years back, and had since forgotten exactly why they did the set trickery.

                  It seems to work even with the simplified cmd.exe /c (echo "%1" | clip.exe).

                  Ah, I did some searching, and found the page I think I originally found it from: http://www.askvg.com/registry-tweak-to-add-copy-as-path-option-in-files-and-folders-context-menu-in-windows/ : It turns out that the simplified cmd.exe /c (echo "%1" | clip.exe) will include the newline in the clipboard, whereas the set/p trickery will prevent the newline from being in the clipboard.

                  And I was also reminded in the article: with a default Vista/Win7/Win8 installation, there is already a “Copy as Path” in the extended SHIFT+RightClick menu – and without the newline – so you don’t even need my registry hack, it should just “be there”. (If you don’t notice it, it’s probably down near “Pin to Start Menu” and above the “Send To…”)

                  Ah, there we go: http://superuser.com/questions/295484/unhide-windows-7-context-menu-extras-permanently reminded me why I made my own version of the Copy As Path: some of the SHIFT+RightClick menu items can be “unhidden” so it goes into the normal RightClick menu (the extra “shift” annoyed me), but the “Copy as Path” stays hidden.

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