Jump to content

Desktop StickyNotes


Nahuel
 Share

Recommended Posts

This script will allow you to have notes on your screen. Like this:

Screenshot

Posted Image

Features:

  • You can have as many as you wish.
  • You can set the transparency (By right-clicking on them) and close them individually.
  • They are always visible.
  • You can drag them by holding down the left mouse button on them (This feature is awesome. Thanks to Piano Man, tobias7 and gsb who discussed this here.)
  • Create new notes by double-clicking on the tray icon or right-click-->new note.

    UPDATE

  • Now you can restore the sticky notes that haven't been closed! Just click "Save SticyNotes and exit" on the tray Icon. The next time you run it, the notes will be restored.
  • You can set the title (actually, you must, because that makes the restore job easier haha.)
Source:

#include <string.au3>
#include <Guiconstants.au3>
#include <Constants.au3>
#include <Misc.au3>
#include <File.au3>

_Singleton("DesktopStickyNotes")

Opt("TrayMenuMode", 1)
Opt("TrayAutoPause", 0)
Opt("WinTitleMatchMode", 2)
Opt("GUICloseOnESC", 0)
TraySetClick(8)

Global $n = 0
Global $a = 0
Global $moving
Global $notaEnGui
Global $comp=1
Global $Restore=0

If FileExists("*.restore") then
RestaurarNotas()
$Restore=1
EndIf

$Main=GUICreate("",200,200,-1,-1,-1,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
GUICtrlCreateLabel("Type the StickyNote title:",5,5)
$InputTitulo=GUICtrlCreateEdit("",5,22,190,25, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_MULTILINE + $ES_WANTRETURN)
GUICtrlCreateLabel("Type the StickyNote body:",5,52)
$Input=GUICtrlCreateEdit("",5,70,190,80, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_MULTILINE + $ES_WANTRETURN)
$OkBut=GUICtrlCreateButton("&OK",5,160,190,-1,$BS_DEFPUSHBUTTON )

$Mensaje=GUICtrlRead($Input)
$NotaTitulo=GUICtrlRead($InputTitulo)

If not $restore Then
    GUISetState(@SW_SHOW,$Main)
Else
    GUISetState(@SW_HIDE,$Main)
EndIf

AnimateTitle($Main, "Desktop StickyNotes! - Nahuel", 100)

$NuevaNota = TrayCreateItem("New StickyNote")
TrayCreateItem("")
$Exit = TrayCreateItem("Save StickyNotes and Exit")

While 1
    Sleep(10)
    $msgT = TrayGetMsg()
    $msg = GUIGetMsg(1)
    Select
        Case $msgT = $Exit
            If WinExists("- StickyNote") Then
                $WinList=WinList("- StickyNote")
                For $b=1 to $WinList[0][0]
                    GUIDelete($WinList[$b][1])
                Next
                GUIDelete($Main)
                TrayTip("StickyNotes saved","StickyNotes that haven't been closed were saved to restore"&@CRLF&"when Desktop StickyNotes is opened again",2000)
                Sleep(3500)
            EndIf
                Exit
        Case $msgT = $NuevaNota Or $msgT = $TRAY_EVENT_PRIMARYDOUBLE
            GUISetState(@SW_SHOW,$Main)
        Case $msg[0] = $GUI_EVENT_CLOSE
            If $msg[1]=$Main Then
               GUISetState(@SW_HIDE,$Main)
            Else
                $NotaH=WinGetTitle($msg[1])
                $NotaNa=StringTrimRight($NotaH,13)
                FileDelete(@ScriptDir&"\"&$NotaNa&".restore")
                GUIDelete($msg[1])
            EndIf
        Case $msg[0] = $GUI_EVENT_SECONDARYDOWN
            $Title=WinGetTitle($msg[1])
            $TWinPos=WinGetPos($msg[1])
            $X=$TWinPos[0]+207
            $Y=$TWinPos[1]
            $Title=WinGetTitle($msg[1])
            $NotaNombre=StringTrimRight($Title,13)
            $hGUI=GUICreate("Sttings for "&$NotaNombre,220,90,$X,$Y,-1,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW),$msg[1])
            GUICtrlCreateGroup(" Transparency ",5,10,210,65)
            $slider = GUICtrlCreateSlider (10,25,200,20)
            GUICtrlSetData(-1,170)
            GUICtrlSetLimit(-1,255,0)
            GUICtrlCreateLabel("Transparent",10,50)
            GUICtrlCreateLabel("Solid",180,50)
            GUISetState(@SW_SHOW, $Title)
            while 1
                $msg1=GUIGetMsg(1)
                if $msg1[0]=$slider Then
                    WinSetTrans($msg[1],"",GUictrlread($slider))
                EndIf
                if $msg1[0]=$GUI_EVENT_CLOSE Then
                    $NotaH=WinGetTitle($msg1[1])
                    $NotaNombre=StringTrimRight($NotaH,13)
                    FileDelete(@ScriptDir&"\"&$NotaNombre&".restore")
                    GUIDelete($msg1[1])     
                    ExitLoop
                EndIf
            WEnd
        Case $msg[0] = $GUI_EVENT_PRIMARYDOWN
            If $msg[1]=$Main Then
               
            Else   
            If $moving <> $GUI_EVENT_MOUSEMOVE Then
                $moving = $GUI_EVENT_MOUSEMOVE
                Opt("MouseCoordMode", 0)
                $mousePos = MouseGetPos()
                Opt("MouseCoordMode", 1)
            _WinDrag()
            EndIf
            EndIf
        Case $msg[0] = $OkBut
            GUISetState(@SW_HIDE,$Main)
            $Mensaje=GUICtrlRead($Input)
            $NotaTitulo=GUICtrlRead($InputTitulo)
            crearnota($NotaTitulo,$Mensaje)
    EndSelect
WEnd

Func crearnota($oTitulo,$oCuerpo)
    If $oTitulo="" Then
        MsgBox(64,"Oops!","You must enter a title!")
        GUISetState(@SW_SHOW,$Main)
        Return
    EndIf
    If $oCuerpo="" Then
        MsgBox(64,"Oops!","You must enter a StickyNote!")
        GUISetState(@SW_SHOW,$Main)
        Return
    EndIf
   
    $WinList=WinList("- StickyNote")
    For $b=1 to $WinList[0][0]
        $comp=StringCompare($oTitulo&" - StickyNote",$WinList[$b][0])
        If $comp=0 Then
            MsgBox(64,"Oops!","There's already a StickyNote with that title!")
            GUISetState(@SW_SHOW,$Main)
            Return
        EndIf
    Next       
    $n+=1
    $hGUI = GUICreate($oTitulo&" - StickyNote", 200, 200, $n*10, $n*10,$WS_OVERLAPPEDWINDOW,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
    GUISetBkColor(0xFFFFAD)
    $NotaEnGui=GUICtrlCreateLabel($oCuerpo,0,0,200,200,$SS_CENTER)
    GUICtrlSetFont($NotaEnGui, 25, 700, "", "Script")
    $moving = $NotaEnGui
    WinSetTrans($hGUI, "", 170)
    GUISetState(@SW_SHOW, $hGUI)
    FileWrite($oTitulo&".restore",$oCuerpo)
    FileSetAttrib($oTitulo&".restore","H")
EndFunc

;~ #cs
Func _WinDrag()
    Do
        $pos = MouseGetPos()
        $winPos = WinGetPos($msg[1])

        If $pos[0] - $mousePos[0] < 0 Then
            $x = 0
        ElseIf $winPos[2] - $mousePos[0] + $pos[0] > @DesktopWidth Then
            $x = @DesktopWidth - $winPos[2]
        Else
            $x = $pos[0] - $mousepos[0]
        EndIf

        If $pos[1] - $mousePos[1] < 0 Then
            $y = 0
        ElseIf $winPos[3] - $mousePos[1] + $pos[1] > @DesktopHeight Then
            $y = @DesktopHeight - $winPos[3]
        Else
            $y = $pos[1] - $mousepos[1]
        EndIf

        WinMove($msg[1], '', $x, $y)
    Until not _IsPressed(01)
$moving = $NotaEnGui
EndFunc;===>WinDrag()

Func AnimateTitle($GuiHand, $sTitle, $iBuf)
    $sTitle = StringSplit($sTitle, "")
    For $i = $iBuf To 0 Step - 1
        Sleep(5)
        WinSetTitle($GuiHand, "", _StringRepeat(" ", $i) & $sTitle[1])
    Next
    Local $s
    For $i = 1 To $sTitle[0]
        Sleep(10)
        $s &= $sTitle[$i]
        WinSetTitle($GuiHand, "", $s)

    Next
EndFunc

Func restaurarNotas()
    $FileList=_FileListToArray(@scriptdir,"*.restore")
    For $i=1 to $FileList[0]
    $n+=1
    $MensajeF=FileRead($FileList[$I])
    $NombreTitulo=StringSplit($FileList[$I],".")
    $hGUI = GUICreate($NombreTitulo[1]&" - StickyNote", 200, 200, $n*10, $n*10,$WS_OVERLAPPEDWINDOW,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
    GUISetBkColor(0xFFFFAD)
    $NotaEnGui=GUICtrlCreateLabel($MensajeF,0,0,200,200,$SS_CENTER)
    GUICtrlSetFont($NotaEnGui, 25, 700, "", "Script")
    $moving = $NotaEnGui
    WinSetTrans($hGUI, "", 170)
    GUISetState(@SW_SHOW, $hGUI)
    Next
EndFunc
Edited by Nahuel
Link to comment
Share on other sites

If you were to use:

Dim $fullDesktopDimensions=WinGetPos("Program Manager")

.. instead of @DesktopWidth and @DesktopHeight you'd have dual-monitor support.

Of course, that means editing your _WinDrag() function somewhere along the lines of:

Func _WinDrag()
    Do
        $pos = MouseGetPos()
        $winPos = WinGetPos($msg[1])

        If $pos[0] - $mousePos[0] < 0 Then
            $x = 0
        ElseIf $winPos[2] - $mousePos[0] + $pos[0] > $fullDesktopDimensions[2] Then
            $x = $fullDesktopDimensions[2] - $winPos[2]
        Else
            $x = $pos[0] - $mousepos[0]
        EndIf

        If $pos[1] - $mousePos[1] < 0 Then
            $y = 0
        ElseIf $winPos[3] - $mousePos[1] + $pos[1] > $fullDesktopDimensions[3] Then
            $y = $fullDesktopDimensions[3] - $winPos[3]
        Else
            $y = $pos[1] - $mousepos[1]
        EndIf

        WinMove($msg[1], '', $x, $y)
    Until not _IsPressed(01)
$moving = $NotaEnGui
EndFunc;===>WinDrag()

Edit: Department of Redundancy Department

Edited by Monamo

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

I think it'd be cool to us $WS_POPUP and add a close button that matches better. It'd look a bit more sticky note-ish. A color pick might be really neat too.

And a font chooser. God, I hate Comic Sans MS

Edited by idusy
Link to comment
Share on other sites

haha yeah, I agree. I hate Comic Sans as well, but I was looking for something that could look like handwriting and that'd be available on most windows versions, but then I saw that WinSetTrans is only for Win2000/XP so I changed it to Script and updated main post.

I don't really know how to do the font selection thingy.

Link to comment
Share on other sites

kool! one suggestion, if your code doesnt completely depend on making its own windows, make the notes a splash with the opt set to 1 and then you wont see the title bar. that would however prevent you from closing them. hotkey for each maybe?

Link to comment
Share on other sites

Thanks for the suggestion, I really like the idea.. but that wouldn't let me control their transparency right? and it'd complicate things a bit... I thought about using XSkin too, to make it look like an actual stickynote.

I updated the script to a newer version.

Xp users: Would someone mind telling me if it closes when you click "Save stickynotes and exit" on the tray icon? I gave the script to someone and she says it won't exit :)

Link to comment
Share on other sites

It does close on XP...

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Png files are pretty easy using the au3lib include A3LGDIPlus.

I have created a Desktop Notes also that uses png files for the notes.

I would like to upload it here, but I can't add a zip file. which is needed to include the png files.

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...