;Ala-Vista Note App ; ;No alarm yet! ;Double click to save last position. AppVersion=1.2 IfNotExist, Notepad FileCreateDir, Notepad IfNotExist, Notepad\Number.txt FileAppend, 1, Notepad\Number.txt IfNotExist, Notepad\Note1.txt FileAppend, , Notepad\Note1.txt IfNotExist, Notepad\*.bmp { UrlDownloadToFile, http://www.autohotkey.net/~jk7800/Note/Cancel.bmp, Notepad\Cancel.bmp UrlDownloadToFile, http://www.autohotkey.net/~jk7800/Note/new.bmp, Notepad\new.bmp UrlDownloadToFile, http://www.autohotkey.net/~jk7800/Note/Note.bmp, Notepad\Note.bmp UrlDownloadToFile, http://www.autohotkey.net/~jk7800/Note/Save.bmp, Notepad\Save.bmp UrlDownloadToFile, http://www.autohotkey.net/~jk7800/Note/Alarm.bmp, Notepad\Alarm.bmp } Menu, tray, add, Enable/Disable window, EnableDisable Menu, Tray, Default, Enable/Disable window Enabled=1 Number=1 MaxNum=1 Note1=Click here to create new note. notwriting=1 FileRead, Gui, Notepad\LastPos.txt StringSplit, Gui, Gui, * Gui +LastFound +Owner +AlwaysOnTop -Caption +OwnDialogs GUI_ID:=WinExist() Gui, Margin, 0, 0 Gui, Color, FAF99F Gui, Add, Picture, gDelete x4 y4, Notepad\Cancel.bmp Gui, Add, Edit, vAlarmSetH Limit2 x17 y4 W18 H17, 00 Gui, Add, Edit, vAlarmSetM Limit2 x35 y4 W18 H17, 00 Gui, Add, Edit, vAlarmSetS Limit2 x53 y4 W18 H17, 00 Gui, Add, Picture, vAlarmButton gSetTimer x54 y4, Notepad\Alarm.bmp GuiControl, Hide, AlarmSetH GuiControl, Hide, AlarmSetM GuiControl, Hide, AlarmSetS Gui, Add, Picture, gSave x73 y4, Notepad\Save.bmp Gui, Add, Picture, gNew x92 y4, Notepad\New.bmp Gui, Add, Text, BackgroundTrans gEdit vNoteRead x4 y26 W99 H78, Gui, Add, Edit, vNoteWrite R5 x4 y26 W99 H76, GuiControl, Hide, NoteWrite Gui, Add, Text, BackgroundTrans gPrev x4 y104, %A_Space%<%A_Space% Gui, Add, Text, BackgroundTrans gNext x14 y104, %A_Space%>%A_Space% Gui, Add, Text, vAlarmRem x30 y104, 00:00:00 GuiControl, Hide, AlarmRem Gui, Add, Picture, vBackground 0x4000000 gStopWriting x0 y0, Notepad\Note.bmp GuiControl, Show, NoteRead GuiControl, , NoteRead, Click here to create new note. SysGet, VirtualScreenWidth, 78 SysGet, VirtualScreenHeight, 79 VirtualScreenWidth-=113 VirtualScreenHeight-=121 if(Gui1<0 or Gui2<0 or Gui1>VirtualScreenWidth or Gui2>VirtualScreenHeight) { Gui, Show, , Notepad WinGetPos, Gui_X, Gui_Y, , , ahk_id %GUI_ID% FileDelete, Notepad\LastPos.txt FileAppend, %Gui_X%*%Gui_Y%, Notepad\LastPos.txt } Else Gui, Show, x%Gui1% y%Gui2%, Notepad WinSet, TransColor, FF00FF 255, ahk_id %GUI_ID% Loop, Notepad\Note*.txt FileRead, Note%A_Index%, %A_LoopFileLongPath% GuiControl, , NoteRead, %Note1% FileRead, MaxNum, Notepad\Number.txt if(Note1="") GuiControl, , NoteRead, Click here to create new note. gosub EnableDisable SetTimer, Update, 60000 gosub Update Return SetTimer: if(AlarmCounting=1) { if(A_GuiEvent="DoubleClick") { Sleep, 500 GuiControl, Hide, AlarmRem AlarmCounting=0 SetTimer, AlarmCountdown, OFF Return } Return } GuiControl, Show, AlarmSetH GuiControl, Show, AlarmSetM GuiControl, Show, AlarmSetS GuiControl, , AlarmSetH, 00 GuiControl, , AlarmSetM, 00 GuiControl, , AlarmSetS, 00 GuiControl, Hide, AlarmButton SettingAlarm=1 Return AlarmCountdown: Alarm3-=1 if(Alarm3<0) { Alarm3:=59 Alarm2-=1 } if(Alarm2<0) { Alarm2:=59 Alarm1-=1 } if(Alarm1<0) { Sleep, 500 GuiControl, Hide, AlarmRem Gui, Color, FF8080 SoundBeep Sleep, 500 Gui, Color, FFFFFF Sleep, 500 Gui, Color, FAF99F Sleep, 500 SoundBeep Gui, Color, FF8080 Sleep, 500 Gui, Color, FFFFFF Sleep, 500 Gui, Color, FAF99F Sleep, 500 AlarmCounting=0 if(RunAppWhenExpired=1) Run, %FileToRun%, %Parameter% SetTimer, AlarmCountdown, OFF Return } AlarmT:=StrLen(Alarm1) if(AlarmT=1) Alarm1=0%Alarm1% AlarmT:=StrLen(Alarm2) if(AlarmT=1) Alarm2=0%Alarm2% AlarmT:=StrLen(Alarm3) if(AlarmT=1) Alarm3=0%Alarm3% AlarmA=%Alarm1%:%Alarm2%:%Alarm3% GuiControl, , AlarmRem, %AlarmA% Return StopWriting: if(SettingAlarm=1) { GuiControl, Hide, AlarmSetH GuiControl, Hide, AlarmSetM GuiControl, Hide, AlarmSetS GuiControl, Show, AlarmButton SettingAlarm=0 } if (notwriting=1) { if(A_GuiEvent="DoubleClick") { WinGetPos, Gui_X, Gui_Y, , , ahk_id %GUI_ID% FileDelete, Notepad\LastPos.txt FileAppend, %Gui_X%*%Gui_Y%, Notepad\LastPos.txt Return } PostMessage, 0xA1, 2,,, A Return } GuiControlGet, Note,, NoteWrite GuiControl, Show, NoteRead GuiControl, Hide, NoteWrite gosub Save notwriting=1 if(Note="") if(MaxNum>1) gosub Delete Else GuiControl, , NoteRead, Click here to create new note. Else GuiControl, , NoteRead, %Note% Return Save: if(SettingAlarm=1) { Parameter:="" MsgBox, 262180, Note v1.16, Do you want to launch any program when the timer expires? IfMsgBox Yes { FileSelectFile, FileToRun if(FileToRun<>"") { MsgBox, 262180, Note v1.16, Do you want any parameteres to be sent? IfMsgBox Yes InputBox, Parameter, Note v1.16, Parameters:, , 200, 125 RunAppWhenExpired=1 } } GuiControl, Hide, AlarmSetH GuiControl, Hide, AlarmSetM GuiControl, Hide, AlarmSetS GuiControl, Show, AlarmButton GuiControl, Show, AlarmRem GuiControlGet, Alarm1,, AlarmSetH GuiControlGet, Alarm2,, AlarmSetM GuiControlGet, Alarm3,, AlarmSetS Alarm=%Alarm1%:%Alarm2%:%Alarm3% GuiControl, , AlarmRem, %Alarm% SetTimer, AlarmCountdown, 1000 SettingAlarm=0 AlarmCounting=1 Return } if (notwriting=1) GuiControlGet, Note,, NoteRead Else GuiControlGet, Note,, NoteWrite GuiControl, , NoteRead, %Note% GuiControl, Show, NoteRead GuiControl, Hide, NoteWrite Note%Number%:=Note FileDelete, Notepad\Note%Number%.txt FileAppend, %Note%, Notepad\Note%Number%.txt Return New: if(SettingAlarm=1) { GuiControl, Hide, AlarmSetH GuiControl, Hide, AlarmSetM GuiControl, Hide, AlarmSetS GuiControl, Show, AlarmButton SettingAlarm=0 } if (notwriting=0) gosub Save Else notwriting=0 MaxNum+=1 FileDelete, Notepad\Number.txt FileAppend, %MaxNum%, Notepad\Number.txt Number:=MaxNum GuiControl, , NoteRead, Click here to create new note. GuiControl, , NoteWrite, GuiControl, Hide, NoteRead GuiControl, Show, NoteWrite GuiControl, Focus, NoteWrite Return Edit: if(SettingAlarm=1) { GuiControl, Hide, AlarmSetH GuiControl, Hide, AlarmSetM GuiControl, Hide, AlarmSetS GuiControl, Show, AlarmButton SettingAlarm=0 } GuiControlGet, Note,, NoteRead if(Note=="Click here to create new note.") GuiControl, , NoteWrite, Else GuiControl, , NoteWrite, %Note% GuiControl, Hide, NoteRead GuiControl, Show, NoteWrite GuiControl, Focus, NoteWrite notwriting=0 Return Prev: if(SettingAlarm=1) { GuiControl, Hide, AlarmSetH GuiControl, Hide, AlarmSetM GuiControl, Hide, AlarmSetS GuiControl, Show, AlarmButton SettingAlarm=0 } if(Number=1) Return Number-=1 if(Number<1) Number=1 Note:=Note%Number% if (notwriting=1) GuiControl, , NoteRead, %Note% Else GuiControl, , NoteWrite, %Note% Return Next: if(SettingAlarm=1) { GuiControl, Hide, AlarmSetH GuiControl, Hide, AlarmSetM GuiControl, Hide, AlarmSetS GuiControl, Show, AlarmButton SettingAlarm=0 } if(Number=MaxNum) Return Number+=1 Note:=Note%Number% if (notwriting=1) GuiControl, , NoteRead, %Note% Else GuiControl, , NoteWrite, %Note% Return Delete: if(SettingAlarm=1) { GuiControl, Hide, AlarmSetH GuiControl, Hide, AlarmSetM GuiControl, Hide, AlarmSetS GuiControl, Show, AlarmButton SettingAlarm=0 Return } if (notwriting=1) { if(MaxNum=1) { FileDelete, Notepad\Note1.txt FileAppend, , Notepad\Note1.txt GuiControl, , NoteWrite, GuiControl, , NoteRead, Click here to create new note. Return } Loop %MaxNum% { NumberCopyTo:=A_Index+Number-1 NumberCopyFrom:=A_Index+Number Note%NumberCopyTo%:=Note%NumberCopyFrom% Note:=Note%A_Index% FileDelete, Notepad\Note%A_Index%.txt FileAppend, %Note%, Notepad\Note%A_Index%.txt } FileDelete, Notepad\Note%MaxNum%.txt MaxNum-=1 FileDelete, Notepad\Number.txt FileAppend, %MaxNum%, Notepad\Number.txt if (Number>1) Number:=MaxNum Note:=Note%Number% GuiControl, , NoteRead, %Note% } Else { Note:=Note%Number% GuiControl, , NoteRead, %Note% notwriting=1 GuiControl, Show, NoteRead GuiControl, Hide, NoteWrite } Return EnableDisable: if(SettingAlarm=1) { GuiControl, Hide, AlarmSetH GuiControl, Hide, AlarmSetM GuiControl, Hide, AlarmSetS GuiControl, Show, AlarmButton SettingAlarm=0 } if(Enabled=1) { WinSet, ExStyle, +0x20, ahk_id %GUI_ID% Loop 11 { Sleep, 25 TMPTrans:=255-A_Index*8 WinSet, TransColor, FF00FF %TMPTrans%, ahk_id %GUI_ID% } WinSet, TransColor, FF00FF 159, ahk_id %GUI_ID% Enabled=0 if(notwriting=0) goto StopWriting }Else{ WinSet, ExStyle, -0x20, ahk_id %GUI_ID% Loop 11 { Sleep, 25 TMPTrans:=159+A_Index*8 WinSet, TransColor, FF00FF %TMPTrans%, ahk_id %GUI_ID% } WinSet, TransColor, FF00FF 255, ahk_id %GUI_ID% Enabled=1 } Return Update: connected:=DllCall("Wininet.dll\InternetGetConnectedState", "Str", 0x40,"Int",0) if connected { UrlDownloadToFile, http://www.autohotkey.net/~jk7800/Note/CurrentVer.txt, %A_Temp%\NotepadCurrentVersion.txt FileRead, CurVer, %A_Temp%\NotepadCurrentVersion.txt if(CurVer=AppVersion) { SetTimer, Update, OFF Return }else{ MsgBox, 262208, Updating..., Note v%AppVersion% has to update to version %CurVer%.`nPlease wait..., 2 UrlDownloadToFile, http://www.autohotkey.net/~jk7800/Note/UpdateList.txt, %A_Temp%\NotepadUpdateList.txt FileRead, UpdateList, %A_Temp%\NotepadUpdateList.txt UrlDownloadToFile, http://www.autohotkey.net/~jk7800/Note/ChangesList.txt, %A_Temp%\NotepadChangesList.txt FileRead, UpdateChanges, %A_Temp%\NotepadUpdateList.txt Loop, Parse, UpdateList,  { StringSplit, UpdateFile, A_LoopField, ? UrlDownloadToFile, %UpdateFile1%, %UpdateFile2% } MsgBox, 262148, Updated!, Note has just been updated! Current version is: %CurVer%.`nShow log of changes? IfMsgBox Yes msgbox, %UpdateChanges% Reload } } Return Help() { msgbox, To be continued }