Post-It notes using HTAs

Author Message
AMBience

  • Total Posts : 31
  • Scores: 0
  • Reward points : 0
  • Joined: 7/24/2008
  • Status: offline
Post-It notes using HTAs Friday, November 04, 2011 12:18 PM (permalink)
0
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!
 
#1
    ZooBeast

    • Total Posts : 8
    • Scores: 0
    • Reward points : 0
    • Joined: 9/17/2009
    • Status: offline
    Re:Post-It notes using HTAs Tuesday, December 13, 2011 1:58 PM (permalink)
    0
    this is a great idea...
    i like how it writes to itself to store parameters on position and size.

    I've tried like crazy to limit the start-up flicker, but failed....Anybody know how to do this?

    you will have to set the size and position before activation of the window
     
     <SCRIPT Language="VBScript"> 
     Self.MoveTo 0,0           '[ Left   : Bottom ] 
     Self.ResizeTo 400,100     '[ Width  : Height ] 
     </SCRIPT> 
     <HTML ID="HTMLSaveAll"><HEAD><TITLE>.</TITLE> 
     the rest of the code...

    looking through your code
    it will take quite an overhaul to use this method
    but it will remove the flicker

    Also found out that Document.URLUnencoded doesn't work in SP3?

    yeah Ive noticed this to
    i had been using it in SP3 and it worked as it should
    but about half way through this year it stopped working
    i think it was a Windoze update that broke it.
     
    #2
      AMBience

      • Total Posts : 31
      • Scores: 0
      • Reward points : 0
      • Joined: 7/24/2008
      • Status: offline
      Re:Post-It notes using HTAs Friday, December 16, 2011 1:16 PM (permalink)
      0
      Thanks!

      The main problem with the flicker is I have to MoveTo 0,0 to get your titlebar height, otherwise you get "window creep"
       
      #3
        ZooBeast

        • Total Posts : 8
        • Scores: 0
        • Reward points : 0
        • Joined: 9/17/2009
        • Status: offline
        Re:Post-It notes using HTAs Sunday, December 18, 2011 2:33 PM (permalink)
        0
        I never knew it was so complicated to get the true size and position of the hta.
        and its not that much of an overhaul as i first thought...

        I assume this was to move it off screen so you could get the true size and position
        Self.MoveTo 9999,0

        i removed it from where it was and used this method below
        and it seems to have removed all the flicker
        i have a bit of error handling because sometimes you get an access denied error

        <HTML id=HTMLSaveAll XMLNS:HTA><HEAD><TITLE>postit</TITLE>
        <SCRIPT language=VBScript>
        On Error Resume Next                 'continue on if error
        Self.MoveTo -1000,-1000              'move off screen
        If Err.Number <>0 Then Window.Close  'if access denied error close window
        On Error Goto 0                      'reset to normal error handling
        </SCRIPT>
        <HTA:APPLICATION SHOWINTASKBAR="No"...
        the rest of the code
        

         
        #4

          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2012 ASPPlayground.NET Forum Version 3.9