We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

macro to insert the path-statement of the active folder into a particular notepad file?

KingL2
KingL2 Posts: 91 Forumite
Fifth Anniversary 10 Posts
Hi
I'd like some kindof of macro in Windows 10 desktop that copies the path statement of the currently active/focussed window and pastes (inserts) it into the sixth line of a particular notepad text file (which is open).

If it is not possible to invoke it from the current window (but, for example, it must be run by clicking on a shortcut file on the desktop); then, obviously, it would be the path statement of the _previously_focussed folder that gets copy-pasted.

If it's not possible to paste-into a particular line of an open notepad file, then pasting into line 1 would be OK, but it must INSERT-paste, not overwrite the existing contents of the file.

If it's not possible to Insert-Paste into an open notepad file, I could live with it opening a new, empty, notepad file and pasting into that; (then I could manually copy-paste that over to where I really want it).

To run from Windows 10 desktop/explorer, not the command-line.

I have no idea if that is possible, or how to do it.  Help, please!  :)

thanks


Comments

  • Neil_Jones
    Neil_Jones Posts: 9,658 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    Something like AutoIT may be able to do this.
  • John_Gray
    John_Gray Posts: 5,845 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Photogenic
    I have difficulty in understanding what you mean by "the path statement of the currently active/focussed window".  I think that whatever that is would have to be extracted by a Windows API, and thus some form of program. 
    With these sort of questions, it can be more productive to indicate what you are trying to do rather than to propose a possible solution!
  • Heedtheadvice
    Heedtheadvice Posts: 2,804 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    Like John writes, to me your question does not make much sense!
    Are you really wanting the window's location, the program using that window, the file shown in the windows contents (such as the file olened as a document in that program) or something else?
  • a
    a Posts: 241 Forumite
    Fifth Anniversary 100 Posts Name Dropper
    I would look at the OPENFILES command, it is not the answer, but could be part of the solution you write
  • KingL2
    KingL2 Posts: 91 Forumite
    Fifth Anniversary 10 Posts
    if I drill down (in windows explorer) to a useful folder:
    d:\data\folder6\tier3folder7\tier4folder8\tier5folder3

    I can copy the path statement of that folder into the clipboard by going :
    • Alt+D  (makes the 'address' field of that window editable)
    • Cntl+C
    • then navigate to my (already open) notepad file
    • and Cntl+V the text "d:\data\folder6\tier3folder7\tier4folder8\tier5folder3" into the notepad file.
    • and save the notepad file

    I just want to be able to do that regularly with a single mouseclick (or two), whenever I am in one of my favourite folders; so adding the path statements of various folders to an ever-growing list in the notepad file.

    - - -

    Over time, I will build (in my notepad file) a list of the locations of all those folders that I have deemed somehow 'special' ; and I can then use that list of path statements to make (probably just in MSWord) some kind of quickreference/homepage of clickable links that I can use to easily reach my favourite folders whenever I want to.

    The requirement is just to 'automate' the addition of a folder to my 'homepage.docx'.

    Just the folders. Not the files, not the apps.

    I'm aware that there are features in Windows that seek to 'bookmark/favourite' folders, but I don't get along with them - I'd rather just make my own list of pathstatements in plaintext. 


  • debitcardmayhem
    debitcardmayhem Posts: 13,133 Forumite
    Part of the Furniture 10,000 Posts Name Dropper Photogenic
    4.8kWp 12x400W Longhi 9.6 kWh battery Giv-hy 5.0 Inverter, WSW facing Essex . Aint no sunshine ☀️ Octopus gas fixed dec 24 @ 5.74 tracker again+ Octopus Intelligent Flux leccy
  • Semple
    Semple Posts: 392 Forumite
    Seventh Anniversary 100 Posts Name Dropper Combo Breaker
    Is it possible for you to view your folder contents via cmd prompt or powershell? That'll make it much easier to pass the absolute path into a text file. 
  • KingL2
    KingL2 Posts: 91 Forumite
    Fifth Anniversary 10 Posts
    edited 26 May 2020 at 4:06AM
    jnhuasd said:

    Autohotkey can do this easily, something like (using the F1 key as the 'hotkey' to activate the script:

    F1::
        Send, !d ; activate the currently active explorer address  bar
        <snip>
        WinActive("Titled - Notepad") ; change to your notepad title
        <snip>
    Return
    



    Awesome. Thanks, that makes light work of it.  I didn't know about Auto Hot Key - it looks pretty handy.

    [
    Warning, not tested. Just off the top of my head, may need some testing.



    yer, is seems that it is     WinActivate, Titled - Notepad
    rather than Winactive ("Titled - Notepad")

    Also, as soon as you make any changes to the notepad file, Windows puts an asterisk on the front of its Windowname, which means that the notepad window isn't recognised/activated when you run it a second time.  Is there a way to get it to ignore the asterisk (so you don't have to save the notepad file every time before you invoke F1)?
  • KingL2
    KingL2 Posts: 91 Forumite
    Fifth Anniversary 10 Posts
    Just a note to add that if you don't want to save the notepad file everytime in order to get rid of the asterisk (I didn't), you can use the Proces i.d. (pid) instead of the Windowname in the WinActivate command, e.g.
        Winactivate, ahk_pid 12345
    (where 12345 is the identifying number of the window that you want to switch to. (You can discover what the particular number is by using the windowspy.exe file that comes in the installation folder for AutoHotKey).
    Using the pid, rather than the name, can also help in other situations where WinActivate fails to locate the window that you are trying to switch to.


Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 352.1K Banking & Borrowing
  • 253.6K Reduce Debt & Boost Income
  • 454.3K Spending & Discounts
  • 245.2K Work, Benefits & Business
  • 600.9K Mortgages, Homes & Bills
  • 177.5K Life & Family
  • 259K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16K Discuss & Feedback
  • 37.7K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.