Jump to content

Notepad autosave


SybrenNooij
 Share

Recommended Posts

Hello,

 

I work alot with notepad. Sometimes it happens that my computer falls asleep, or something else. When this happens, my notes in my notepad are lost, obviously.

Is there a way to make a script to save notepad as a .txt file with the date as name, something like %timedate%(I know %username% is the general one for the username). 

My next step is to repeat this batch file very 15 minutes by windows scheduled tasks.

Any ideas are welcome!

 

Link to comment
Share on other sites

I would just use the exe and have it run every 15 mins.  When you use the sleep command, the only resource the exe would be consuming would be alittle bit of ram (about 50k).  I guess if you wanted to not consume the 50k then the scheduled task would be the way to go.  For laziness of not wanting to create the scheduled task I would just do the exe.  I would write the exe this way:  Make a main loop that loops indefinitely for 15 mins, on each pass your going to:  WinList("notepad") to get a list of all the notepad windows, then loop through those windows and:  Controlgethandle of the notepad edit control so you can copy all the text, when the text is copied, save the file with @username and probably _NowDate and _Nowtime.  After you save, delete all the text of the still open notepad document and close the open notepad and re-open it (all of this to avoid gui prompts).  When looping through notepad window is finished and files are saved, you are finished with your loop and add a sleep(900000) (15 mins).

Edited by TouchOdeath
Link to comment
Share on other sites

  • Moderators

Hi, @SybrenNooij, welcome to the forum. Can you explain what you're writing to notepad, or show us the code you're using? As it sounds like you're writing a large amount of data, perhaps you should look at a better method of retaining your data such as SQLite. Beyond that, if your computer going to sleep is causing your script to fail, why not just set it to lock after a certain amount of time, but not go into hibernation?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hi @JLogan3o13, I use it for notes while I work. It's actually pretty rare, that my computer crashes. But when it happens, I lose all my notes. And because I am pretty busy at work, and make alot of notes, they are important to me. I guess there are usually about 300-600 words per day. My thoughts were as following: Making a script that checks if the process notepad.exe is active, if yes, then save as file.txt to a specific location. Then I make a scheduled task, that runs this script every 15 minutes or something like that. 

Edited by SybrenNooij
Link to comment
Share on other sites

Not to knock AutoIt (I use it everyday), but it sounds to me you need a little better solution than notepad. Google offers many tools, one including (https://www.google.com/keep) which you can make all kinds of notes, check things off your note list, set alarmas, share the notes with other people, etc... many features. On top of that, you should also take a look at the Google Drive (https://drive.google.com) which allows you store whatever you want (15 gigs free), plus make documents, spreadsheets, presataitons, etc... (none of the documents, spreadsheets, etc.. count against your 15 gigs of storage space). Everything I talked about and so much more is available free with a Google Account (https://accounts.google.com).

I know this is not a answer to the question asked but I really do think it can benefit you. Let me know if you have any questions.

Link to comment
Share on other sites

Yeah well, I could also just use Word, and apply autosave, but the issue is that I like the small format of notepad and the plaint text. I know this is also possible in Word, and there are indeed other solutions for my question. My question is, if it is possible to make such a script or something like that, that could help me and/or make it easier.

Link to comment
Share on other sites

Yeah well, I could also just use Word, and apply autosave, but the issue is that I like the small format of notepad and the plaint text. I know this is also possible in Word, and there are indeed other solutions for my question. My question is, if it is possible to make such a script or something like that, that could help me and/or make it easier.

For sure, was not trying to kill your thread or anything like that. Just seem to me you really cared about your notes, and I know for me I have had way to many Hard Drives die on me. So that is way I choose something like Google Drive, to store everything I need so I do not have to worry about that. Now of course I take monthly updates of my Google Drive as well, just incase Google goes down or something, but other than that, everything I need is available to me anytime, anywhere.

Hello,

 

I work alot with notepad. Sometimes it happens that my computer falls asleep, or something else. When this happens, my notes in my notepad are lost, obviously.

Is there a way to make a script to save notepad as a .txt file with the date as name, something like %timedate%(I know %username% is the general one for the username). 

My next step is to repeat this batch file very 15 minutes by windows scheduled tasks.

Any ideas are welcome!

 

As for your question, have you ever used Sublime Text 3 (http://www.sublimetext.com/3). Awesome, light weight, very simple like notepad and has many addon's (you choose what you want installed) which is created by the community. I did a quick Google serach and found https://packagecontrol.io/packages/auto-save but I know there are plenty other Auto-Save addon's, as well. That would probably be a much better solution, especially if you're looking for something light weight.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...