Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Notepad++ autosave and launch


  • Please log in to reply
8 replies to this topic
DeWild1
  • Members
  • 369 posts
  • Last active: Feb 28 2014 08:15 PM
  • Joined: 30 Apr 2006
I lost a full days work yesterday! :shock: :twisted: :twisted: :evil: :evil:

So here is my first public script to fix that!
8)
/*
Notepad++ autosave and launch
If notepad++ is active, and you have not touched the keyboard or mouse for 5 sec, it saves all.
Then, it checks to see if there has been no activity for 15 min, if notepad++ is still runing, even if it is not active, it brings it to the front and saves.. (lunch time) :-)
*/
DetectHiddenText, On
SetTitleMatchMode, 2
SetBatchLines -1
#SingleInstance ignore
#WinActivateForce


#notrayicon
;if notepad++ is not running 
	process, exist, notepad++.exe
	If ! errorLevel
		{
		run, %A_ProgramFiles%\Notepad++\Notepad++.exe
		}
sleep, 60000

dome:
loop, 45 ;after 7.5 min, 
{
sleep, 10000
if A_TimeIdlePhysical > 5000 ;after at least 5 sec of not doing anything and if notepad++ is currently active
	{
	If WinActive("ahk_class Notepad++")
		{
		blockinput, On
		send, {Control Down}{Shift Down}s{Control Up}{Shift Up} ;save all 
		Blockinput, off
		}
		
	process, exist, notepad++.exe
	If ! errorLevel
		{ 
		exitapp ;if not running, exit
		}
	}
}
if A_TimeIdlePhysical > 900000 ;if idle time more than 15 min, then force it to activate and then save.
{
winactivate ("ahk_class Notepad++")
sleep, 1000
blockinput, On
send, {Control Down}{Shift Down}s{Control Up}{Shift Up} ;save all 
Blockinput, off
goto, dome
}
goto, dome
---edit added blockinput

Deep
  • Guests
  • Last active:
  • Joined: --
How do we apply your script to notepad++

  • Guests
  • Last active:
  • Joined: --

How do we apply your script to notepad++

Just run the script. After a period of inactivity (keyboard/mouse) it will automatically save your files.

If you start the script and notepad++ is not running, it will start it (provided it is located at %A_ProgramFiles%\Notepad++\Notepad++.exe). If you exit notepad++, the script will also exit.

RoutnAbout
  • Guests
  • Last active:
  • Joined: --
Can this script be used on other software also?
If so what do I need to change?

DeWild1
  • Members
  • 369 posts
  • Last active: Feb 28 2014 08:15 PM
  • Joined: 30 Apr 2006

Can this script be used on other software also?
If so what do I need to change?

Just find out what keys you need it to work with by Doing ALT on your keyboard then just use the keys to find out the sequence and use Windows Spy to find out the title and stuff.

  • Guests
  • Last active:
  • Joined: --

How do we apply your script to notepad++

Just run the script. After a period of inactivity (keyboard/mouse) it will automatically save your files.

If you start the script and notepad++ is not running, it will start it (provided it is located at %A_ProgramFiles%\Notepad++\Notepad++.exe). If you exit notepad++, the script will also exit.



I use notepad++ for a statistical software package and would like to adopt your code. But I know nothing about real programming. Where should I run your script? Could you give me some detailed instructions? I use window XP.

Many thanks :) :) :)

mike2009
  • Guests
  • Last active:
  • Joined: --
nice script but notepad++ also has a plugin for that

check
http://fstellari.goo...com/npp_plugins

chinkaling
  • Members
  • 2 posts
  • Last active: Aug 09 2008 08:47 PM
  • Joined: 20 Jul 2008

nice script but notepad++ also has a plugin for that

check
<!-- m -->http://fstellari.goo...com/npp_plugins<!-- m -->

Nice try, but that plugin's smallest time interval is 1 minute. That's completely useless to me, and many others who are concerned about losing a huge sum of data between 60 seconds... This script [with slight modifications for my purposes at least] is the perfect solution for that.

Great job on your first public script, DeWild1!

Ace1013
  • Guests
  • Last active:
  • Joined: --
Deep and Guest:

I was wondering the same thing you were. I didn't recognize this scripting language, saw no comment on what it was and didn't know Notepad++ could read scripts like these.

Well, the thing is:

AutoHotKey IS a scripting language. This whole website is about writing scripts for a script engine called AutoHotkey, which you can download and install.

It lets you take control of windows and text input, and seems very handy, so I think I'll download it and write something with it myself.

But that solves the mystery for those of us who were searching for an answer about Notepad++ anyway:

This is a script which you can run in AutoHotkey, to automatically enter the "save all" keyboard-shortcut into the Notepad++ window ever so often.