This very small HTA can be used as a template for post-it note emulation in Windows XP. It simply contains a textarea and self-modifying code that saves itself on exit, it also saves the size and position of the window as well.
The point of these notes is rapid "write & exit", so all you have do is move the mouse out the window and click to blur the note, which then automatically saves and exits. This also gets around the problem of not being able to set a HTA window to "on top" and lets me skip having a taskbar icon (I really wanted to make it look nothing like a window)
Also has off-screen checking,silent read-only errors and last date\save count in the tooltip.
Anyway, I've added instructions (XP only sorry) on how to create a new file type (PSI) and add this to the windows right-click new menu, which lets you create them anywhere! (you need TweakUI though)
<HTML ID="HTMLSaveAll"><HEAD><TITLE>.</TITLE>
<HTA:APPLICATION SHOWINTASKBAR="No" SYSMENU="No" SCROLL="No" MAXIMIZEBUTTON="NO"/></HEAD>
<BODY ID="objBody" STYLE="Margin:0;Border:0" SaveX=100 SaveY=100 SaveW=220 SaveH=220 Viewed="Never" Count=0>
<TEXTAREA ID="txaPad" STYLE="Width:100%;Height:100%;Font-Family:Arial;Font-Size:12;Overflow-Y:Auto;
BackGround-Color:#FFFFA0; Scrollbar-Base-Color:#C0C050;"></TEXTAREA><SCRIPT LANGUAGE="VBScript">
'*****************
'-- HTA Post-It --
'By Alan Bond 2011
'*****************
'To take full advantage of this HTA so you can right click and "New post-it" anywhere in windows XP:-
'(Requires TweakUI)
'1. In Explorer goto Tools\Folder-Options\File Types and add a new one called PSI (or whatever you like)
'2. Goto Advanced and add a new action "Open" with application:- C:\WINDOWS\System32\mshta.exe "%1"
'3. Give it a description (used in New menu) and a nice icon (something yellow)
'4. Rename this HTA to "whatever.PSI" (remove any post-it text, and these comments)
'5. In TweakUI goto Templates and add the above PSI file (You can now delete whatever.PSI)
Option Explicit
Dim strPath 'Filename of this HTA
Dim intOffX,intOffY 'Size of window border and title
'---- Restore last size\position
With objBody
'---- If last session was out of screen then re-position
If Int(.SaveX)<0 Then .SaveX=0
If Int(.SaveY)<0 Then .SaveY=0
If Int(.SaveX)+Int(.SaveW)>Screen.Width Then .SaveX=Screen.Width-.SaveW
If Int(.SaveY)+Int(.SaveH)>Screen.Height Then .SaveY=Screen.Height-.SaveW
Self.MoveTo 9999,0 : Self.ResizeTo .SaveW,.SaveH 'Limits flicker a bit
Self.ResizeTo .SaveW+(.SaveW-.OffsetWidth),.SaveH+(.SaveH-.OffsetHeight) 'True innersize
Self.MoveTo 0,0 : intOffX=Window.ScreenLeft : intOffY=Window.ScreenTop 'Get title\border size
Self.MoveTo .SaveX,.SaveY : txaPad.Title="Last viewed: " & .Viewed & VBCRLF & "View count: " & .Count
End With
'---- The title is the single filename with no extension
strPath = Replace(Document.Location.Pathname,"/","\") : strPath = Replace(strPath,"%20"," ")
Document.Title=Right(strPath,Len(strPath)-InstrRev(strPath,"\")) 'Filename
Document.Title=Left(Document.Title,Len(Document.Title)-4) 'Extension
txaPad.Focus
'---- Exit on blur
Sub txaPad_OnBlur()
'---- Store position,size and info in body
With objBody
.SaveX=Window.ScreenLeft-intOffX : .SaveY=Window.ScreenTop-intOffY : .Count=.Count+1
.SaveW=Document.Body.offsetwidth : .SaveH=Document.Body.OffsetHeight : .Viewed=Now
End With
'---- Save & exit
Dim objFile : On Error Resume Next 'For Read-only files etc.
Set objFile = CreateObject("Scripting.FileSystemObject").CreateTextFile(strPath, True)
objFile.Write HTMLSaveAll.OuterHTML : objFile.Close :
Window.Close
End Sub
</SCRIPT></BODY></HTML> I've tried like crazy to limit the start-up flicker, but failed....Anybody know how to do this? Starting off minimised locks the window until you self.focus :-\
Also found out that Document.URLUnencoded doesn't work in SP3? (which means CubeWorld is broken) :-( In SP1 it's fine "\Hello there" but "/hello%20there" in SP3. So I used Document.Location and replaced a few important chars.
Have fun!