#Persistent #SingleInstance, Force DetectHiddenWindows, On SetTitleMatchMode, 2 SetTitleMatchMode, Slow SetWinDelay, 0 Process, Priority,, High SetBatchLines, 0 CoordMode, Mouse, Screen SetWorkingDir %A_ScriptDir% MCode(Hex2Bin, "568b74240c8a164684d2743b578b7c240c538ac2c0e806b109f6e98ac802cac0e104880f8a164684d2741a8ac2c0e806b309f6eb80e20f02c20ac188078a16474684d275cd5b5f5ec3") ;#Include tic-MakeICOBars-1.11.ahk AppName := "Work Break" VersionNumber := "2.81 Alpha" GoSub, TrayMenu Gui, 2: -Caption +E0x80000 +LastFound +LastFound +ToolWindow +AlwaysOnTop ; WS_EX_LAYERED Gui, 2: Show, w1 h1 Hide hwnd := WinExist() pToken := Gdip_Startup() Images := "Background.png|WorkEnd.png|OK.png|BreakEnd.png|SessionEnd.png|Exit.png|Repeat.png" Loop, Parse, Images, | { pBitmap := Gdip_CreateBitmapFromFile("Images\" . A_LoopField) hbm%A_Index% := Gdip_CreateHBITMAPFromBitmap(pBitmap) Gdip_DisposeImage(pBitmap) hdc%A_Index% := DllCall("CreateCompatibleDC", "Uint", 0) hbm%A_Index%old := GDI_SelectObject(hdc%A_Index%, hbm%A_Index%) If !(hbm%A_Index% && hdc%A_Index%) { MsgBox, Load error: %A_LoopField% ExitApp } GetBitmapSize(hbm%A_Index%, Width%A_Index%, Height%A_Index%) } Gdip_Shutdown(pToken) DllCall("LoadLibrary", "Str", "msimg32.dll") hbm := Gdi_CreateDIBSection(hdcDest, Width1, Height1, 32) hdc := DllCall("CreateCompatibleDC", "Uint", 0) GDI_SelectObject(hdc, hbm) VarSetCapacity(rc, 16, 0), NumPut(Height1, NumPut(Width1, rc, 8)) DllCall("FillRect", "Uint", hdc, "Uint", &rc, "Uint", DllCall("GetStockObject", "Int", 4)) ; BLACK_BRUSH=4 AlphaBlend(hdc, 0, 0, Width1, Height1, hdc1, 0, 0, Width1, Height1, 255) AlphaBlend(hdc, 50, 25, Width2, Height2, hdc2, 0, 0, Width2, Height2, 255) AlphaBlend(hdc, 120, 140, Width3, Height3, hdc3, 0, 0, Width3, Height3, 150) ;######################################################################################### IfExist, %AppName%.ini { IniRead, WorkTime, %AppName%.ini, Timer Settings, WorkTime IniRead, BreakTime, %AppName%.ini, Timer Settings, BreakTime IniRead, RepeatTimes, %AppName%.ini, Timer Settings, RepeatTimes IniRead, ScreenCap, %AppName%.ini, Capture Settings, ScreenCap IniRead, ScreenCapTime, %AppName%.ini, Capture Settings, ScreenCapTime IniRead, ScreenSelect, %AppName%.ini, Capture Settings, ScreenSelect IniRead, Destination, %AppName%.ini, Capture Settings, Destination IniRead, Sound, %AppName%.ini, Sound, Sound IniRead, AutoStart, %AppName%.ini, AutoStart, AutoStart IniRead, IrfanView, %AppName%.ini, Helper Apps Settings, IrfanView IniRead, IrfanviewExe, %AppName%.ini, Helper Apps Settings, IrfanviewExe IniRead, ToDoList, %AppName%.ini, Helper Apps Settings, ToDoList IniRead, ToDoListExe, %AppName%.ini, Helper Apps Settings, ToDoListExe IniRead, TDLTaskFile, %AppName%.ini, Helper Apps Settings, TDLTaskFile IniRead, ChosenHotkey, %AppName%.ini, Helper Apps Settings, ChosenHotkey If (ChosenHotkey <> "") Hotkey, %ChosenHotkey%, TrayNewTask IniRead, ChosenTaskIdeaHotkey, %AppName%.ini, Helper Apps Settings, ChosenTaskIdeaHotkey If (ChosenTaskIdeaHotkey <> "") Hotkey, %ChosenTaskIdeaHotkey%, CaptureTaskIdea IniRead, MasterFile, %AppName%.ini, Other Features, MasterFile ; IniRead, MasterListFile, %AppName%.ini, Other Features, MasterListFile } Else WorkTime := 48, BreakTime := 12, RepeatTimes := 3, ScreenCapTime := 20, ScreenCap := "0", ScreenSelect := 1, Sound := 1, AutoStart := "0", IrfanView := "0", ToDoList := "0", ChosenTaskIdeaHotKey := "^!T", ChosenHotkey := "^!L", MasterFile := "0" Gui, 1: Add, GroupBox, x10 y10 w330 h140, Timer Settings Gui, 1: Add, Text, x20 yp+30 w200 r1 -Multi -Wrap, Time to work for (minutes): Gui, 1: Add, Edit, x+10 yp+0 w100 r1 -Multi -Wrap vWorkTime, %WorkTime% Gui, 1: Add, Text, x20 y+20 w200 r1 -Multi -Wrap, Time to break for (minutes): Gui, 1: Add, Edit, x+10 yp+0 w100 r1 -Multi -Wrap vBreakTime, %BreakTime% Gui, 1: Add, Text, x20 y+20 w200 r1 -Multi -Wrap, Number of Work/Break Cycles: Gui, 1: Add, Edit, x+10 yp+0 w100 r1 -Multi -Wrap vRepeatTimes, %RepeatTimes% Gui, 1: Add, GroupBox, x10 y+20 w330 h180, Screen Capture/Sound Gui, 1: Add, CheckBox, x20 yp+30 r1 -Multi -Wrap vScreenCap gScreenCap Checked%ScreenCap% Gui, 1: Add, Text, x+0 yp+0 w110 r1 -Multi -Wrap, Screen Capture every Gui, 1: Add, Edit, x+10 yp+0 w50 r1 -Multi -Wrap vScreenCapTime, %ScreenCapTime% Gui, 1: Add, Text, x+10 yp+0 w70 r1 -Multi -Wrap, seconds Gui, 1: Add, CheckBox, x168 yp+34 r1 -Multi -Wrap vSound Checked%Sound% Gui, 1: Add, Text, xp+30 yp+0 w110 r1 -Multi -Wrap, Sound Enabled? Gui, 1: Add, CheckBox, x20 yp+0 r1 -Multi -Wrap vScreenSelect0 gScreenSelect Checked%ScreenSelect% Gui, 1: Add, Text, x+0 yp+0 w110 r1 -Multi -Wrap, Entire Screen ScreenSelect := !ScreenSelect Gui, 1: Add, CheckBox, x20 y+20 r1 -Multi -Wrap vScreenSelect1 gScreenSelect Checked%ScreenSelect% Gui, 1: Add, Text, x+0 yp+0 w110 r1 -Multi -Wrap, Active Window Gui, 1: Add, Text, x20 y+10 w110 r1 -Multi -Wrap, Save to: Gui, 1: Add, Edit, x20 y+10 w225 r1 -Multi -Wrap vDestination, %Destination% Gui, 1: Add, Button, x+10 yp+0 w75 r1 -Multi -Wrap vSelectDest gSelectDest, Browse Gui, 1: Add, GroupBox,x+20 y10 w330 h334, Helper Applications Gui, 1: Font, Bold Gui, 1: Add, text, xp10 yp+30 r1 -Multi -Wrap, IrfanView Gui, 1: Font, Normal Gui, 1: Add, CheckBox, x+6 r1 -Multi -Wrap vIrfanView gIrfanView Checked%IrfanView%, Enabled? Gui, 1: Add, text, x360 yp+20 r1 -Multi -Wrap, Program Location: Gui, 1: Add, Edit, x360 yp+20 w225 r1 -Multi -Wrap vIrfanviewExe, %IrfanViewExe% Gui, 1: Add, Button, x+10 yp+0 w75 r1 -Multi -Wrap vSelectIrfanViewExe gSelectIrfanViewExe, Browse Gui, 1: Font, Bold Gui, 1: Add, text, x360 yp+30 r1 -Multi -Wrap, ToDoList Gui, 1: Font, Normal Gui, 1: Add, CheckBox, x+6 r1 -Multi -Wrap vToDoList gToDoList Checked%ToDoList%, Enabled? Gui, 1: Add, text, x360 yp+20 r1 -Multi -Wrap, Program Location: Gui, 1: Add, Edit, x360 y+10 w225 r1 -Multi -Wrap vToDoListExe, %ToDoListExe% Gui, 1: Add, Button, x+10 yp+0 w75 r1 -Multi -Wrap vSelectToDoListExe gSelectToDoListExe, Browse Gui, 1: Add, Text, x360 y+5 w110 r1 -Multi -Wrap, TDL File Selection: Gui, 1: Add, Edit, x360 y+10 w225 r1 -Multi -Wrap vTDLTaskFile, %TDLTaskFile% Gui, 1: Add, Button, x+10 yp+0 w75 r1 -Multi -Wrap vSelectTDLFile gSelectTDLFile, Browse Gui, 1: Font, Bold Gui, 1: Add, Text, x360 y+5 w200 r1 -Multi -Wrap, Capture New Task/Idea Hotkey(s): Gui, 1: Font, Normal Gui, 1: Add, Hotkey, x360 y+10 w225 r1 -Multi -Wrap vChosenTaskIdeaHotkey, %ChosenTaskIdeaHotkey% Gui, 1: Font, Bold Gui, 1: Add, Text, x360 y+5 w160 r1 -Multi -Wrap, Start New Task Hotkey(s): Gui, 1: Font, Normal Gui, 1: Add, Hotkey, x360 y+10 w225 r1 -Multi -Wrap vChosenHotkey, %ChosenHotkey% Gui, 1: Add, GroupBox, x10 y+20 w670 h40, Other Features: Gui, 1: Add, CheckBox, x20 yp+20 r1 -Multi -Wrap vMasterFile gMasterFile Checked%MasterFile% Gui, 1: Add, Text, x+0 yp+0 w200 r1 -Multi -Wrap, Master Task Journal? Gui, 1: Add, CheckBox, x168 yp+0 r1 -Multi -Wrap vAutoStart Checked%AutoStart% Gui, 1: Add, Text, xp+30 yp+0 w110 r1 -Multi -Wrap, AutoStart Enabled? Gui, 1: Add, Button, x255 y+25 w75 r1 -Multi -Wrap vOK gOKCancel, &OK Gui, 1: Add, Button, x+30 yp+0 w75 r1 -Multi -Wrap vCancel gOKCancel, &Cancel GoSub, ScreenCap OnMessage(0x200, "WM_MOUSEMOVE") OnMessage(0x201, "WM_LBUTTONDOWN") OnMessage(0x203, "WM_LBUTTONDOWN") If AutoStart = 1 GoSub, TrayStart Return SelectDest: FileSelectFolder, Destination,,, Select the folder to which screenshots will be saved to If !ErrorLevel GuiControl,, Destination, %Destination% Return ; Helper apps sections (IrfanView & ToDoList) SelectToDoListExe: FileSelectFile, ToDoListExe,,, Select ToDoList executable (todolist.exe) location If !ErrorLevel GuiControl,, ToDoListExe, %ToDoListExe% Return SelectTDLFile: FileSelectFile, TDLTaskFile,,, Select ToDoList file (*.tdl) new tasks will be saved to If !ErrorLevel GuiControl,, TDLTaskFile, %TDLTaskFile% Return SelectIrfanViewExe: FileSelectFile, IrfanViewExe,,, Select IrfanView executable (i_view32.exe) location If !ErrorLevel GuiControl,, IrfanViewExe, %IrfanViewExe% Return /* SelectMasterListFile: FileSelectFile, MasterListFile,,, Select Master Task List for all tasks: If !ErrorLevel GuiControl,, MasterListFile, %MasterListFile% Return */ ;End of Helper apps section ; Code for Preference selection dependancies ScreenSelect: StringRight, Control, A_GuiControl, 1 Control := !Control GuiControl,, ScreenSelect%Control%, 0 Return ScreenCap: Gui, 1: Submit, NoHide GuiControl, Enable%ScreenCap%, ScreenCapTime GuiControl, Enable%ScreenCap%, ScreenSelect0 GuiControl, Enable%ScreenCap%, ScreenSelect1 GuiControl, Enable%ScreenCap%, Destination GuiControl, Enable%ScreenCap%, SelectDest IrfanView: Gui, 1: Submit, NoHide GuiControl, Enable%IrfanView%, IrfanViewExe GuiControl, Enable%IrfanView%, SelectIrfanViewExe ToDoList: Gui, 1: Submit, NoHide GuiControl, Enable%ToDoList%, ToDoListExe GuiControl, Enable%ToDoList%, SelectToDoListExe GuiControl, Enable%ToDoList%, TDLTaskFile GuiControl, Enable%ToDoList%, SelectTDLFile MasterFile: Gui, 1: Submit, NoHide Return ;######################################################################################### OKCancel: Gui, 1: Submit, NoHide Gui, 1: +OwnDialogs If (WorkTime&1 = "") || (BreakTime&1 = "") { MsgBox, Both work and break time must be entered and only contain numbers Return } If A_GuiControl = OK { IniWrite, %WorkTime%, %AppName%.ini, Timer Settings, WorkTime IniWrite, %BreakTime%, %AppName%.ini, Timer Settings, BreakTime IniWrite, %RepeatTimes%, %AppName%.ini, Timer Settings, RepeatTimes IniWrite, %ScreenCap%, %AppName%.ini, Capture Settings, ScreenCap IniWrite, %ScreenCapTime%, %AppName%.ini, Capture Settings, ScreenCapTime IniWrite, %ScreenSelect0%, %AppName%.ini, Capture Settings, ScreenSelect IniWrite, %Destination%, %AppName%.ini, Capture Settings, Destination IniWrite, %Sound%, %AppName%.ini, Sound, Sound IniWrite, %AutoStart%, %AppName%.ini, AutoStart, AutoStart IniWrite, %IrfanView%, %AppName%.ini, Helper Apps Settings, IrfanView IniWrite, %IrfanviewExe%, %AppName%.ini, Helper Apps Settings, IrfanviewExe IniWrite, %ToDoList%, %AppName%.ini, Helper Apps Settings, ToDoList IniWrite, %ToDoListExe%, %AppName%.ini, Helper Apps Settings, ToDoListExe IniWrite, %TDLTaskFile%, %AppName%.ini, Helper Apps Settings, TDLTaskFile IniWrite, %ChosenHotkey%, %AppName%.ini, Helper Apps Settings, ChosenHotkey If (ChosenHotkey <> "") Hotkey, %ChosenHotkey%, TrayNewTask IniWrite, %ChosenTaskIdeaHotkey%, %AppName%.ini, Helper Apps Settings, ChosenTaskIdeaHotkey If (ChosenTaskIdeaHotkey <> "") Hotkey, %ChosenTaskIdeaHotkey%, CaptureTaskIdea IniWrite, %MasterFile%, %AppName%.ini, Other Features, MasterFile ; IniWrite, %MasterListFile%, %AppName%.ini, Other Features, MasterListFile } Gui, 1: Hide Return ;######################################################################################### UpdateTray: If !LoopTimes LoopTimes = 0 If Working { TimePassed := Round(100*((A_TickCount-Time1)/(WorkTime*60*1000))) Menu, Tray, Tip, % "Elapsed Time: " . (A_TickCount-Time1)//(1000*60) . " / " . WorkTime . " Minutes`nWork Period: " . (LoopTimes//2)+1 . " / " . RepeatTimes } Else { TimePassed := Round(100*((A_TickCount-Time1)/(BreakTime*60*1000))) Menu, Tray, Tip, % "Elapsed Time: " . (A_TickCount-Time1)//(1000*60) . " / " . BreakTime . " Minutes`nBreak Period: " . (LoopTimes//2)+1 . " / " . RepeatTimes } If TimePassed >= 100 SetTimer, UpdateTray, Off If Working E := MakeICOBars(TimePassed, "339900", "Elapsed.ico") Else E := MakeICOBars(TimePassed, "CC0000", "Elapsed.ico") If E { MsgBox, %E% Return } Menu, Tray, Icon, Elapsed.ico FileDelete, Elapsed.ico Return ;######################################################################################### EndWorkBreak: LoopTimes++ If (LoopTimes >= RepeatTimes*2) { End := 1 LoopTimes = } SetTimer, EndWorkBreak, Off VarSetCapacity(rc, 16, 0), NumPut(Height1, NumPut(Width1, rc, 8)) DllCall("FillRect", "Uint", hdc, "Uint", &rc, "Uint", DllCall("GetStockObject", "Int", 4)) ; BLACK_BRUSH=4 AlphaBlend(hdc, 0, 0, Width1, Height1, hdc1, 0, 0, Width1, Height1, 255) If End { AlphaBlend(hdc, 75, 25, Width5, Height5, hdc5, 0, 0, Width5, Height5, 255) AlphaBlend(hdc, 60, 140, Width6, Height6, hdc6, 0, 0, Width6, Height6, 150) AlphaBlend(hdc, 160, 140, Width7, Height7, hdc7, 0, 0, Width7, Height7, 150) } Else { If Working AlphaBlend(hdc, 50, 25, Width2, Height2, hdc2, 0, 0, Width2, Height2, 255) Else AlphaBlend(hdc, 50, 25, Width4, Height4, hdc4, 0, 0, Width4, Height4, 255) AlphaBlend(hdc, 120, 140, Width3, Height3, hdc3, 0, 0, Width3, Height3, 150) } DllCall("UpdateLayeredWindow", "Uint", hwnd, "Uint", 0, "Uint", 0, "Int64*", Width1|Height1<<32, "Uint", hdc, "Int64*", 0, "Uint", 0, "Uint*", 255<<16|1<<24, "Uint", 2) XCentre := (A_ScreenWidth-Width1)//2, YCentre := (A_ScreenHeight-Height1)//2 Gui, 2: Show, x%XCentre% y%YCentre% NA If Sound = 1 { SoundPlay, %SystemRoot%\Media\notify.wav } Return ;############################################################################################# WM_MOUSEMOVE() { Global Sleep, 1 MouseGetPos, HX, HY, HWin If (A_Gui) && (HWin = hwnd) { WinGetPos, WinX, WinY,,, ahk_id %hwnd% HX -= WinX, HY -= WinY If !End { If (HX > 120) && (HX < 120+Width3) && (HY > 140) && (HY < 140+Height3) HButton := 1, Alpha := 255 Else HButton := "", Alpha := 150 If HButton = %OldHButton% Return } Else { If (HY > 140) && (HY < 140+Height6) { If (HX > 60) && (HX < 60+Width6) HButton := 2, 2Alpha := 255, 3Alpha := 150 If (HX > 160) && (HX < 160+Width7) HButton := 3, 3Alpha := 255, 2Alpha := 150 } Else HButton := "", 2Alpha := 150, 3Alpha := 150 } VarSetCapacity(rc, 16, 0), NumPut(Height1, NumPut(Width1, rc, 8)) DllCall("FillRect", "Uint", hdc, "Uint", &rc, "Uint", DllCall("GetStockObject", "Int", 4)) ; BLACK_BRUSH=4 AlphaBlend(hdc, 0, 0, Width1, Height1, hdc1, 0, 0, Width1, Height1, 255) If !End { If Working AlphaBlend(hdc, 50, 25, Width2, Height2, hdc2, 0, 0, Width2, Height2, 255) Else AlphaBlend(hdc, 50, 25, Width4, Height4, hdc4, 0, 0, Width4, Height4, 255) AlphaBlend(hdc, 120, 140, Width3, Height3, hdc3, 0, 0, Width3, Height3, Alpha) } Else { AlphaBlend(hdc, 75, 25, Width5, Height5, hdc5, 0, 0, Width5, Height5, 255) AlphaBlend(hdc, 60, 140, Width6, Height6, hdc6, 0, 0, Width6, Height6, 2Alpha) AlphaBlend(hdc, 160, 140, Width7, Height7, hdc7, 0, 0, Width7, Height7, 3Alpha) } DllCall("UpdateLayeredWindow", "Uint", hwnd, "Uint", 0, "Uint", 0, "Int64*", Width1|Height1<<32, "Uint", hdc, "Int64*", 0, "Uint", 0, "Uint*", 255<<16|1<<24, "Uint", 2) OldHButton := HButton } Return } ;############################################################################################# WM_LBUTTONDOWN() { Global MouseGetPos, HX, HY, HWin If (A_Gui) && (HWin = hwnd) { WinGetPos, WinX, WinY,,, ahk_id %hwnd% HX -= WinX, HY -= WinY If !End { If (HX > 120) && (HX < 120+Width3) && (HY > 140) && (HY < 140+Height3) { Gui, 2: Hide Working := !Working SetTimer, UpdateTray, 250 Time1 := A_TickCount If !Working SetTimer, EndWorkBreak, % BreakTime*60*1000 ;% Else SetTimer, EndWorkBreak, % WorkTime*60*1000 ;% } } Else { If (HY > 140) && (HY < 140+Height6) { If (HX > 60) && (HX < 60+Width6) /* If ToDoList =1 { Gui, 2:Hide Run %TDLTask% WinWaitActive, %TDLTaskFile%,,3 SetTitleMatchMode, 2 PostMessage, 0x111, 32967,,,ToDoList © AbstractSpoon } */ ExitApp If (HX > 160) && (HX < 160+Width7) { End = Gui, 2: Hide GoSub, TrayStart } } } } Return } ;############################################################################################# TrayMenu: Menu, Tray, Icon , %A_ScriptDir%\images\clock_edit.ico, IconNumber, 1 Menu, Tray, NoStandard Menu, Tray, DeleteAll Menu, Tray, Add, Start, TrayStart Menu, Tray, Add, Settings, TraySettings Menu, Tray, Add Menu, Tray, Add, New Task, TrayNewTask Menu, Tray, Add, Capture Task/Idea, CaptureTaskIdea Menu, Tray, Add Menu, TaskLogs, Add, Work Log, Work_Log Menu, TaskLogs, Add, Master Log, Master_Log Menu, TaskLogs, Add, Task List, Task_List Menu, Tray, Add, Log Files, :TaskLogs Menu, Tray, Add, SlideShow, TraySlideShow Menu, Tray, Add Menu, Tray, Add, Exit, TrayExit Menu, Tray, Default, Settings Return TrayStart: If !Started Menu, Tray, Delete, Start Started := 1 Working := 1 SetTimer, UpdateTray, 250 Time1 := A_TickCount SetTimer, EndWorkBreak, % WorkTime*60*1000 ;% If ScreenCap = 1 SetTimer, ScreenCapTimer, % ScreenCapTime*1000 ;% Return TrayNewTask: /* dddd = Full name for the day of the week (e.g. Monday) in the current user's language yyyy = Year with century. For example: 2005 MM = Month with leading zero (01 – 12) dd = Day of the month with leading zero (01 – 31) HH = Hours with leading zero; 24-hour format (00– 23) mm = Minutes with leading zero (00 – 59) ss = Seconds with leading zero (00 – 59) For a complete list: http://www.autohotkey.com/docs/commands/FormatTime.htm */ FormatTime, Day ,, dddd FormatTime, Date ,, yyyy.MM.dd FormatTime, Time ,, HH:mm:ss Gui, 99: Destroy Gui, 99: Color, 339933 Gui +LastFound WinSet, TransColor, 339933 Gui, 99: Font, Bold Gui, 99: Add, Text, x125 y26 w300 h13, Task Gui, 99: Font, Norm Gui, 99: Add, Edit, x125 y46 w300 h21 vTask, Gui, 99: Font, Bold Gui, 99: Add, Text, x435 y26 w150 h13, Tags Gui, 99: Font, Norm Gui, 99: Add, Edit, x435 y46 w150 h21 vTags, Gui, 99: Font, Bold Gui, 99: Add, Text, x6 y80 w130 h30, Comments Gui, 99: Font, Norm Gui, 99: Add, Edit, x6 y100 w580 h50 vComments, Gui, 99: Font, Normal Gui, 99: Add, Button, x155 y170 w100 h30 default vSubmitNewTask gSubmitNewTask, &Submit Gui, 99: Add, Button, x265 y170 w100 h30 vTask_List gTask_List, View &Task List Gui, 99: Add, Button, x376 y170 w100 h30 vWork_List gWork_Log, View &Work Log Gui, 99: Add, Button, x486 y170 w100 h30 vTaskCancel gTaskCancel , &Cancel Gui, 99: Font, Bold Gui, 99: Add, Text, x5 y26 w110 h13, TimeStamp Gui, 99: Font, Norm Gui, 99: Add, Edit, x5 y46 w110 h21 vTimestamp, %Date% %Time% GuiWidth=596 GuiHeight=218 X := (A_ScreenWidth / 2) - (GuiWidth / 2) Y := (A_ScreenHeight / 2) - (GuiHeight / 2) Gui, 99: Show, x%X% y%Y% h%GuiHeight% w%GuiWidth%, New Active Task Return CaptureTaskIdea: FormatTime, Day ,, dddd FormatTime, Date ,, yyyy.MM.dd FormatTime, Time ,, HH:mm:ss Gui, 95: Destroy Gui, 95: Color, FF9900 Gui +LastFound WinSet, TransColor, FF9900 Gui, 95: Font, Bold Gui, 95: Add, Text, x6 y26 w300 h13, New Task/Idea Gui, 95: Font, Norm Gui, 95: Add, Edit, x6 y46 w300 h21 vTask, Gui, 95: Font, Bold Gui, 95: Add, Text, x320 y26 w150 h13, Tags Gui, 95: Font, Norm Gui, 95: Add, Edit, x320 y46 w250 h21 vTags, Gui, 95: Font, Bold Gui, 95: Add, Text, x6 y80 w130 h30, Comments Gui, 95: Font, Norm Gui, 95: Add, Edit, x6 y100 w580 h50 vComments, Gui, 95: Font, Normal Gui, 95: Add, Button, x265 y170 w100 h30 default gSubmitNewTaskIdea, &Submit Gui, 95: Add, Button, x376 y170 w100 h30 vTask_List gTask_List, View &Task List Gui, 95: Add, Button, x486 y170 w100 h30 vTaskCancel gTaskCancel , &Cancel GuiWidth=596 GuiHeight=218 X := (A_ScreenWidth / 2) - (GuiWidth / 2) Y := (A_ScreenHeight / 2) - (GuiHeight / 2) Gui, 95: Show, x%X% y%Y% h%GuiHeight% w%GuiWidth%, Capture Task/Idea List Return TraySlideShow: If IrfanView = 0 { Msgbox, You need to configure IrfanView! Return } FileSelectFolder, SlideShowFld,%Destination%,, Select Slideshow folder ... If !ErrorLevel GuiControl,, SlideShowFld, %SlideShowFld% Run, %IrfanviewExe% /slideshow=%SlideShowFld% Return TraySettings: Gui, 1: Show, w690 h450, %AppName% - v%VersionNumber% Settings Return TrayExit: ExitApp Return Work_Log: Run, notepad taskworklog.txt Return Master_Log: Run, notepad taskmasterjournallog.txt Return Task_List: Run, notepad taskideacapture.txt Return TaskCancel: Gui, 99: Hide Gui, 95: Hide Return SubmitNewTask: Gui, 99: Submit IniWrite, %Task%, %AppName%.ini, Active Task Info, Task IniWrite, %Tags%, %AppName%.ini, Active Task Info, Tags IniWrite, %Comments%, %AppName%.ini, Active Task Info, Comments IfNotExist, TaskWorkLog.txt FileAppend, Date|Time|Task|Tags|Comments`n, TaskWorkLog.txt FileAppend, %Date%|%Time%|%Task%|%Tags%|%Comments%`n, TaskWorkLog.txt If MasterFile =1 ; check if Master Task Journal is enabled { IfNotExist, TaskMasterJournalLog.txt FileAppend, Active|Date|Time|Task|Tags|Comments`n, TaskMasterJournalLog.txt FileAppend, 1|%Date%|%Time%|%Task%|%Tags%|%Comments%`n, TaskMasterJournalLog.txt } ; Function: If enabled, write new task to TDL & start TDL timer If ToDoList =1 ; check if ToDoList is enabled { TDLTask = "%ToDoListExe%" "%TDLTaskFile%" Run %TDLTask% -nt "%Task%" -cm "%Day% - %Date% - %Time%`nTags: %Tags%`nComments:`n%Comments%`n" WinWaitActive, %TDLTaskFile%,,3 ;Start TDL Timer SetTitleMatchMode, 2 PostMessage, 0x111, 32967,,,ToDoList © AbstractSpoon } Return SubmitNewTaskIdea: Gui, 95: Submit IfNotExist, TaskIdeaCapture.txt FileAppend, Date|Time|Task|Tags|Comments`n, TaskIdeaCapture.txt FileAppend, %Date%|%Time%|%Task%|%Tags%|%Comments%`n, TaskIdeaCapture.txt If MasterFile =1 ; check if Master Task Journal is enabled { IfNotExist, TaskMasterJournalLog.txt FileAppend, Active|Date|Time|Task|Tags|Comments`n, TaskMasterJournalLog.txt FileAppend, 0|%Date%|%Time%|%Task%|%Tags%|%Comments%`n, TaskMasterJournalLog.txt } If ToDoList =1 ; If ToDoList is enabled { TDLTask = "%ToDoListExe%" "%TDLTaskFile%" Run %TDLTask% -nt "%Task%" -cm "%Day% - %Date% - %Time%`nTags: %Tags%`nComments:`n%Comments%`n" } Return ;############################################################################################# ScreenCapTimer: If DllCall("IsWindowVisible", "UInt", hwnd) Return If End { SetTimer, ScreenCap, Off Return } dsFolder = %A_YYYY%-%A_MM%-%A_DD% - %A_DDDD% Text = %A_DDDD%`, %A_DD%/%A_MM%/%A_YYYY% - %A_Hour%:%A_Min%:%A_Sec%`n%Task%`n%Tags%`n%Comments% Dest := (SubStr(Destination, StrLen(Destination), 1) = "\") ? Destination dsFolder "\" : Destination "\" dsFolder "\" FileCreateDir, % FileExist(Dest) ? : Dest Height := ScreenSelect0 = 1 ? 15 : 20 TextToImage("Screen", Text, Dest . A_Now . ".jpg", "XP=1:2 YP=9:10 Height=" Height " Align=Bottom|Centre Weight=400 TextColour=990000 Quality=5") Return ;############################################################################################# TextToImage(In="Screen", Text="TextToImage", Output="TextToImage.bmp", Options="XP=1:2 YP=1:2 Height=20 Align=Bottom|Centre Weight=400 TextColour=ffffff", Font="Arial") { hGdiPlus := DllCall("LoadLibrary", "Str", "gdiplus.dll") VarSetCapacity(si, 16, 0), si := Chr(1) DllCall("gdiplus\GdiplusStartup", "UIntP", pToken, "UInt", &si, "UInt", 0) If In in Screen,Window { If (In = "Screen") nL := nT := 0, nW := A_ScreenWidth, nH := A_ScreenHeight ; Get coordinates for full screen Else If (In = "Window") { WinGetPos, nL, nT, nW, nH, A ; Get coordinates for active window WinGet, ID, ID, A WinGetTitle, Title, A Winget, MinMax, MinMax, A If !(DllCall("IsWindowVisible", UInt, ID) && (Title) && (MinMax != -1)) ; Check active window is visible { GoSub, TTS_GdiplusShutdown Return, "Window is not visible" } } mDC := DllCall("CreateCompatibleDC", "UInt", 0) NumPut(VarSetCapacity(bi, 40, 0), bi) NumPut(nW, bi, 4) NumPut(nH, bi, 8) NumPut(32, NumPut(1, bi, 12, "UShort"), 0, "Ushort") hBM := DllCall("gdi32\CreateDIBSection", "UInt", mDC, "UInt", &bi, "UInt", 0, "UIntP", "", "UInt", 0, "UInt", 0) oBM := DllCall("SelectObject", "UInt", mDC, "UInt", hBM) ; Place bitmap object Into compatible DC hDC := DllCall("GetDC", "UInt", 0) ; Get DC of screen and bitblt either whole screen or active window DllCall("BitBlt", "UInt", mDC, "Int", 0, "Int", 0, "Int", nW, "Int", nH, "UInt", hDC, "Int", nL, "Int", nT, "UInt", 0x40000000|0x00CC0020) } Else { VarSetCapacity(wFile, StrLen(In)*2+2) DllCall("kernel32\MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &In, "Int", -1, "UInt", &wFile, "Int", VarSetCapacity(wFile)//2) DllCall("gdiplus\GdipCreateBitmapFromFile", "UInt", &wFile, "UIntP", pBitmap) If !pBitmap { Gosub, TTS_GdiplusShutdown Return, "Failed to load image" } DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "UInt", pBitmap, "UIntP", hBM, "UInt", 0) DllCall("gdiplus\GdipDisposeImage", "Uint", pBitmap) mDC := DllCall("CreateCompatibleDC", "UInt", 0) oBM := DllCall("SelectObject", "UInt", mDC, "UInt", hBM) hDC := DllCall("GetDC", "UInt", 0) } VarSetCapacity(bm, 24, 0) If !DllCall("GetObject", "UInt", hBM, "Int", 24, "UInt", &bm) { GoSub, TTS_GdiplusShutdown Return, "GetObject failed on bitmap {" hBM "}" } Width := NumGet(bm, 4, "Int") ; Get properties of bitmap Height := NumGet(bm, 8, "Int") bpp := NumGet(bm, 18, "Ushort") DllCall("SetBkMode", "UInt", mDC, "UInt", 1) ; Leave background untouched for background mix mode DllCall("SetGraphicsMode", "UInt", mDC, "UInt", 2) ; Set graphics mode for DC to allow world transformations VarSetCapacity(logfont, 400, 0) LogPixelsSY := DllCall("GetDeviceCaps", "UInt", hDC, "Int", 90) ; Number of pixels per logical inch along the screen height LogPixelsSX := DllCall("GetDeviceCaps", "UInt", hDC, "Int", 88) DllCall("ReleaseDC", "UInt", 0, "UInt", hDC) If !Instr(Options, "x=") Options .= " x=1:2" If !Instr(Options, "y=") Options .= " y=1:2" If !Instr(Options, "Height=") Options .= " Height=20" If !Instr(Options, "Align=") Options .= " Bottom|Centre" If !Instr(Options, "Weight=") Options .= " Weight=400" If !Instr(Options, "Font=") Options .= " Font=Arial" If !Instr(Options, "TextColour=") Options .= " TextColour=000000" StringSplit, Options, Options, %A_Space% Loop, %Options0% { If Instr(Options%A_Index%, "XP=") { XP := SubStr(Options%A_Index%, 4, StrLen(Options%A_index%)-3) If InStr(XP, ":") { StringSplit, XP, XP, : XP := XP1*(Width//XP2) } } If InStr(Options%A_Index%, "YP=") { YP := SubStr(Options%A_Index%, 4, StrLen(Options%A_index%)-3) If InStr(YP, ":") { StringSplit, YP, YP, : YP := YP1*(Height//YP2) } } If InStr(Options%A_Index%, "Height=") { TextHeight := (SubStr(Options%A_Index%, 8, StrLen(Options%A_index%)-7)*logPixelsSY)/60 NumPut(TextHeight, logfont, 0) } If InStr(Options%A_Index%, "Width=") NumPut((SubStr(Options%A_Index%, 7, StrLen(Options%A_index%)-6)*logPixelsSX)/100, logfont, 4) If InStr(Options%A_Index%, "Align=") { Align := SubStr(Options%A_Index%, 7, StrLen(Options%A_index%)-6) AlignWord := "Right,Top,Bottom,Centre,Left" AlignNum := "2,0,8,6,0" StringSplit, AlignWords, AlignWord, `, StringSplit, AlignNums, AlignNum, `, Loop, %AlignWords0% StringReplace, Align, Align, % AlignWords%A_Index%, % AlignNums%A_Index%, All StringSplit, Pos, Align, | DllCall("SetTextAlign", "UInt", mDC, "UInt", Pos1|Pos2) } If InStr(Options%A_Index%, "Weight=") NumPut(SubStr(Options%A_Index%, 8, StrLen(Options%A_index%)-7), logfont, 16) If InStr(Options%A_Index%, "TextColour=") { TextColour := SubStr(Options%A_Index%, 12, StrLen(Options%A_Index%)-11) TC := "0x" . TextColour prevColor := DllCall("SetTextColor", "UInt", mDC, "UInt", ((TC & 0xFF) << 16) + (TC & 0xFF00) + ((TC >> 16) & 0xFF), "UInt") } If InStr(Options%A_Index%, "Underline") NumPut(1, logfont, 21) If InStr(Options%A_Index%, "Italic") NumPut(1, logfont, 20) If InStr(Options%A_Index%, "Strikeout") NumPut(1, logfont, 22) If InStr(Options%A_Index%, "Quality=") NumPut(SubStr(Options%A_Index%, 9, StrLen(Options%A_index%)-8), logfont, 26) } StringLeft, Font, Font, 32 DllCall("lstrcpy", "UInt", &logfont + 28, "Str", Font) #hFont := DllCall("CreateFontIndirect", "UInt", &logfont) #hOldFont := DllCall("SelectObject", "UInt", mDC, "UInt", #hFont) ; Change DC Font StringSplit, Text, Text, `n Loop, %Text0% { DllCall("TextOut", "UInt", mDC, "Int", XP, "Int", YP, "Str", Text%A_Index%, "UInt", StrLen(Text%A_Index%)) YP += TextHeight ; Draw text Into device } DllCall("SelectObject", "UInt", mDC, "UInt", #hOldFont) DllCall("DeleteObject", "UInt", #hFont) ; Restore DC Font If (SubStr(Output, 1, 1) = "!") { GoSub, TTS_GdiplusShutdown Return, mDC } Else { StringSplit, OutputArray, Output, . Extension := "." . OutputArray%OutputArray0% If Extension not in .bmp,.jpg,.png,.tif,.gif ; Check file extension is correct { GoSub, TTS_GdiplusShutdown Return, "Invalid file extension. Only bmp,jpg,png,tif,gif are available" } } DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "UInt", hBM, "UInt", 0, "UIntP", pImage) DllCall("SelectObject", "Uint", mDC, "Uint", oBM) DllCall("DeleteObject", "Uint", hBM) DllCall("DeleteDC", "Uint", mDC) DllCall("gdiplus\GdipGetImageEncodersSize", "UIntP", nCount, "UIntP", nSize) ; Get encoder VarSetCapacity(ci, nSize) DllCall("gdiplus\GdipGetImageEncoders", "UInt", nCount, "UInt", nSize, "UInt", &ci) Loop, %nCount% { nSize := DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", NumGet(ci, 76 * (A_Index - 1) + 44), "Int", -1, "UInt", 0, "Int", 0, "UInt", 0, "UInt", 0) VarSetCapacity(sString, nSize) DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", NumGet(ci, 76 * (A_Index - 1) + 44), "Int", -1, "Str", sString, "Int", nSize, "UInt", 0, "UInt", 0) If !InStr(sString, Extension) ; Find encoder matching extension Continue pCodec := &ci + 76 * (A_Index - 1) Break } If pImage ; Save image to file { sString := Output nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", 0, "Int", 0) VarSetCapacity(wString, nSize * 2) DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", &wString, "Int", nSize) DllCall("gdiplus\GdipSaveImageToFile", "UInt", pImage, "UInt", &wString, "UInt", pCodec, "UInt", 0) DllCall("gdiplus\GdipDisposeImage", "Uint", pImage) } GoSub, TTS_GdiplusShutdown Return, XP . "|" . YP TTS_GdiplusShutdown: DllCall("gdiplus\GdiplusShutdown" , "UInt", pToken) ; Shutdown and free library DllCall("FreeLibrary", "UInt", hGdiPlus) Return } ;############################################################################################# SaveHBITMAPToFile(hBitmap, sFile) { DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi) hFile:= DllCall("CreateFile", "Uint", &sFile, "Uint", 0x40000000, "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "int64P", 0x4D42|14+40+NumGet(oi,44)<<16, "Uint", 6, "UintP", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "int64P", 54<<32, "Uint", 8, "UintP", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "Uint", &oi+24, "Uint", 40, "UintP", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44), "UintP", 0, "Uint", 0) DllCall("CloseHandle", "Uint", hFile) } Unicode4Ansi(ByRef wString, sString) { nSize := DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0) VarSetCapacity(wString, nSize * 2) DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize) Return &wString } Ansi4Unicode(pString) { nSize := DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int", 0, "Uint", 0, "Uint", 0) VarSetCapacity(sString, nSize) DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize, "Uint", 0, "Uint", 0) Return sString } ;############################################################################################# Gdip_Startup() { If !DllCall("GetModuleHandle", "Str", "gdiplus") DllCall("LoadLibrary", "Str", "gdiplus") VarSetCapacity(si, 16, 0), si := Chr(1) DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0) Return, pToken } Gdip_CreateBitmapFromFile(sFile) { VarSetCapacity(wFile, 1023) DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sFile, "Int", -1, "Uint", &wFile, "Int", 512) DllCall("gdiplus\GdipCreateBitmapFromFile", "Uint", &wFile, "UintP", pBitmap) Return, pBitmap } Gdip_CreateHBITMAPFromBitmap(pBitmap, ARGB = 0) { DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Uint", pBitmap, "UintP", hBitmap, "Uint", ARGB) Return, hBitmap } Gdip_DisposeImage(pImage) { Return, DllCall("gdiplus\GdipDisposeImage", "Uint", pImage) } GetBitmapSize(h_bitmap, ByRef Width, ByRef Height, ByRef bpp="") { VarSetCapacity(bm, 24, 0) If !DllCall("GetObject", "UInt", h_bitmap, "Int", 24, "UInt", &bm) Return, 0 Width := NumGet(bm, 4, "Int") Height := NumGet(bm, 8, "Int") bpp := NumGet(bm,18, "Ushort") Return, 1 } Gdip_Shutdown(pToken) { DllCall("gdiplus\GdiplusShutdown", "Uint", pToken) If hModule := DllCall("GetModuleHandle", "Str", "gdiplus") DllCall("FreeLibrary", "Uint", hModule) Return, 0 } Gdi_CreateDIBSection(hDC, nW, nH, bpp = 32, ByRef pBits = "") { NumPut(VarSetCapacity(bi, 40, 0), bi) NumPut(nW, bi, 4) NumPut(nH, bi, 8) NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort") Return, DllCall("gdi32\CreateDIBSection", "Uint", hDC, "Uint", &bi, "Uint", 0, "UintP", pBits, "Uint", 0, "Uint", 0) } GDI_SelectObject(hdc, hgdiobj) { Return, DllCall("SelectObject", "uint", hdc, "uint", hgdiobj) } AlphaBlend(hdcDest, dx, dy, dw, dh, hdcSrc, sx, sy, sw, sh, Alpha=255) { Return DllCall("Msimg32\AlphaBlend", "Uint", hdcDest, "Int", dx, "Int", dy, "Int", dw, "Int", dh, "Uint", hdcSrc, "Int", sx, "Int", Sy, "Int", sw, "Int", sh, "Uint", Alpha<<16|1<<24) } ;############################################################################################# ; MakeICOBars Bars by tic ; Usage: MakeICOBars(Numbers, BarColours, FileName, BackgroundColour, BackgroundOpacity) ; ; Numbers: Either 1 number can be sent or many. This numbers will determine the height of the bars ; Sending "00|25|50|100" will create 4 bars at 25% increments. Numbers over 100 will be set to 100, and under 0 will be set to 0. ; Numbers do not need to be rounded when sent. They will be rounded by the function ; ; BarColours: Colours can be set to each bar, or all of them as a whole in RGB format ; Sending "ff0000" will make all bars red, but "ff0000|0000ff" will make the 1st bar red and the second blue. ; If fewer colours are sent than there are bars, then all will be set to the 1st colour. ; If more colours are sent that numbers, thn only the appropriate ones will be used. ; ; FileName: The filename of the file you wish the function to create. Useful when many files are needed ; ; BackGroundColour: The background colour can simply be sent in RGB standard "ff0000" for red. ; ; BackgroundOpacity: The opacity of the background can be set from 0 (transparent) to 255 (opaque). MCode(ByRef Code, Icon) { VarSetCapacity(Code, StrLen(Icon)//2) Loop % StrLen(Icon)//2 ;% NumPut("0x" . SubStr(Icon, (2*A_Index)-1, 2), Code, A_Index-1, "Char") } ;############################################################################################# MakeICOBars(Numbers, Colours = "000000", FileName = "TrayBars.ico", BGColour = "000000", BOpacity = 75) { Global OldICONumbers,OldICOColours,Hex2Bin If (!ICOHeader32) || (!ICOMask32) ; Write values for mask and header { ICOHeader32 := "0000010001002020000001002000a81000001600000028000000200000004000000001002000000000000000000000000000000000000000000000000000" Loop, 32 ICOMask32 .= "00000000" } StringRight, CheckICO, FileName, 4 If (CheckICO != ".ico") ; Check .ico extension FileName .= ".ico" BGColourTrue := "0x" . BGColour BGColourTrue := BGColourTrue & 0x01 If (StrLen(BGColour) != 6) || (BGColourTrue = "") ; Check background colour is RGB hex Return, "The background colour must be in the RGB format, being 6 characters long, specifically """ . BGColour . """" StringLeft, Sign, Numbers, 1 ; Check for signs If Sign in <,>,-,+ StringTrimLeft, Numbers, Numbers, 1 ; Remember sign and remove if exists If BOpacity > 255 ; Make sure opacity is between 0 and 255 BOpacity = 255 If BOpacity < 0 BOpacity = 0 SetFormat, Integer, H BOpacity += 0 SetFormat, Integer, D ; Convert background opacity to hex and remove 0x StringTrimLeft, BOpacity, BOpacity, 2 If StrLen(BOpacity) = 1 BOpacity := "0" . BOpacity StringSplit, NumbersArray, Numbers, | StringSplit, ColoursArray, Colours, | Numbers = ; Clear values and later use stringsplit values to recreate new values Colours = If NumbersArray0 > 32 ; Ensure only maximum of 32 points Return, "Only a maximum of 32 points may be specified. You have specified """ . NumbersArray0 . """" If NumbersArray0 > %ColoursArray0% { Loop, %NumbersArray0% ; If fewer colours than numbers, then make all numbers have the 1st specified colour ColoursArray%A_Index% := ColoursArray1 ; Do not need to check if more colours than numbers, as stringsplit will remove unwanted values } Loop, %NumbersArray0% { If (NumbersArray%A_Index% & 1 = "") ; Check only numbers contained Return, "A non numerical value has been entered for Numbers, specifically """ . NumbersArray%A_Index% . """" If NumbersArray%A_Index% < 0 NumbersArray%A_Index% := 0 Else If NumbersArray%A_Index% > 100 NumbersArray%A_Index% := 100 Else ; Make sure all numbers are between 0 and 100 and are whole numbers NumbersArray%A_Index% := Round(NumbersArray%A_Index%) Numbers .= NumbersArray%A_Index% . "|" ; Recreate Numbers after checking ColourTrue := "0x" . ColoursArray%A_Index% ColourTrue := ColourTrue & 0x01 If (ColourTrue = "") ; Check only hex values contained Return, "A non colour value has been entered for Colours, specifically """ . ColoursArray%A_Index% . """" If StrLen(ColoursArray%A_Index%) != 6 Return, "Colours must be in the RGB format, being 6 characters long, specifically """ . ColoursArray%A_Index% . """" Colours .= ColoursArray%A_Index% . "|" ; Recreate Colours after checking } StringTrimRight, Numbers, Numbers, 1 StringTrimRight, Colours, Colours, 1 If Sign = + ; Add right { If NumbersArray0 >= 32 Return, "+> cannot be used when there are already 32 numbers in the array" Numbers := OldICONumbers . "|" . Numbers Colours := OldICOColours . "|" . Colours } If Sign = - ; Add left { If NumbersArray0 >= 32 Return, "<+ cannot be used when there are already 32 numbers in the array" Numbers .= "|" . OldICONumbers Colours .= "|" . OldICOColours } If Sign = < ; Shift left { GoSub, Shift Numbers := OldICONumbers . "|" . Numbers StringTrimLeft, OldICOColours, OldICOColours, % 7*NumbersArray0 ;% Colours := OldICOColours . "|" . Colours } If Sign = > ; Shift right { StringSplit, OldICONumbersArray, OldICONumbers, | GoSub, ReverseOrder ; Reverse order so that left shift method can be reused GoSub, Shift StringSplit, OldICONumbersArray, OldICONumbers, | GoSub, ReverseOrder Numbers .= "|" . OldICONumbers StringTrimRight, OldICOColours, OldICOColours, % 7*NumbersArray0 ;% Colours .= "|" . OldICOColours } StringSplit, NumbersArray, Numbers, | ; Put new values for colours and numbers back into array ready to create icon StringSplit, ColoursArray, Colours, | Loop, %ColoursArray0% ; Convert Colours and BGColour from RGB to BGR ColoursArray%A_Index% := SubStr(ColoursArray%A_Index%, 5, 2) . SubStr(ColoursArray%A_Index%, 3, 2) . SubStr(ColoursArray%A_Index%, 1, 2) BGColour := SubStr(BGColour, 5, 2) . SubStr(BGColour, 3, 2) . SubStr(BGColour, 1, 2) Loop, %NumbersArray0% { If NumbersArray%A_Index% Loops := 32//(100/NumbersArray%A_Index%) Else Loops := 0 ; Set loops to 0 if blank as blank var will cause infinite error Num++ Loop, % (32//NumbersArray0)*Loops ; Create each bar Bar%Num% .= ColoursArray%Num% . "ff" Loop, % (32//NumbersArray0)*(32-Loops) ; Create background for each bar Bar%Num% .= BGColour . BOpacity } Icon := ICOHeader32 ; Create icon with 32*32 @ 32bpp header info Start := 1 Loop, 32 { Loop, %NumbersArray0% ; Glue bars together Icon .= SubStr(Bar%A_Index%, Start, (32//NumbersArray0)*8) Loop, % 32-(NumbersArray0*(32//NumbersArray0)) ;% Icon .= BGColour . BOpacity ; Right pad bars until edge of icon Start += (32//NumbersArray0)*8 } Icon .= ICOMask32 ; Add blank mask, as it is not needed for gui use Len := Ceil(StrLen(Icon)/2) VarSetCapacity(Bin, Len) DllCall(&Hex2Bin, "UInt", &Bin, "UInt", &Icon, "CDECL") h := DllCall("CreateFile", "Str", FileName, "Uint", 0x40000000, "Uint", 0, "UInt", 0, "UInt", 4, "Uint", 0, "UInt", 0) Result := DllCall("WriteFile", "UInt", h, "Str", Bin, "UInt", Len, "UInt*", Written, "UInt", 0) h := DllCall("CloseHandle", "Uint", h) ; Binary write using machine code by Laszlo If !h Return, "Handle could not be closed after writing file" OldICONumbers := Numbers OldICOColours := Colours ; Store values ready in case of modifier on repeat Return, 0 ;############################################################################################# ReverseOrder: OldICONumbers = R_Index := OldICONumbersArray0 Loop, %OldICONumbersArray0% ; Reverse order of array { OldICONumbers .= OldICONumbersArray%R_Index% . "|" R_Index-- } StringTrimRight, OldICONumbers, OldICONumbers, 1 Return ;############################################################################################# Shift: Loop, %NumbersArray0% ; Remove old values when shifting { OldICONumbers := RegExReplace(OldICONumbers, "[0-9]+", "", "", 1, 1) If (SubStr(OldICONumbers, 1, 1) = "|") StringTrimLeft, OldICONumbers, OldICONumbers, 1 } Return } ~Enter:: If !DllCall("IsWindowVisible", "UInt", hwnd) Return Gui, 2: Hide Working := !Working, Time1 := A_TickCount SetTimer, UpdateTray, 250 SetTimer, EndWorkBreak, % Working ? WorkTime*60*1000 : BreakTime*60*1000 Return