Guest Posted June 6, 2013 Posted June 6, 2013 (edited) Hi there, I've started coding this, because no commercial Pomodoro app fullfilled my needs. For those of you who don't know what Pomodoro is - it's a simple system that keeps you being productive as long as possible. More info and the source code in the link below. http://tiny.cc/pomo-app Edit: This application is not affiliated or associated with or endorsed by the Pomodoro Technique® or Francesco Cirillo Edited September 2, 2013 by Guest
JohnOne Posted June 6, 2013 Posted June 6, 2013 (edited) No example here, and why the hidden/shortened url? EDIT: Real url https://bitbucket.org/syk3s/pomo EDIT2: code expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/striponly /mergeonly #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <IE.au3> #include <Debug.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <SliderConstants.au3> #include <Date.au3> #include <Misc.au3> #include"includes\CreateBlankBox\CreateBlankBox.au3" #include"includes\BlockInputEx.au3" #include"includes\_AudioEndpointVolume.au3" _DebugSetup("Pomodoro", False, 2) _DebugOut('#################################################################################') _DebugOut(' ____ ____ _ ____ ____ ____ ____ ____ ') _DebugOut('/ __\/ _ \/ \__/|/ _ \/ _ \/ _ \/ __\/ _ \') _DebugOut('| \/|| / \|| |\/||| / \|| | \|| / \|| \/|| / \|') _DebugOut('| __/| \_/|| | ||| \_/|| |_/|| \_/|| /| \_/|') _DebugOut('\_/ \____/\_/ \|\____/\____/\____/\_/\_\\____/') _DebugOut(' ') _DebugOut(_Now() & " - " & _DebugBugReportEnv()) _DebugOut('--------------------------------- > POMODORO < ---------------------------------') HotKeySet("^!q", "Prompt") _BlockInputEx(3, "{CTRL}|{ALT}|Q") ;block keyboard except Ctrl, Alt and Q Global $MusicURLSArray[1] Global $SettingsFile = @ScriptDir & "\settings.ini" Local $CentralGUIWidth = 600 Local $CentralGUIHeight = 400 ;Global $CentralGUIFontColor = 0x33B5E5 ;Global $CentralGUIBkColor = 0x3C3C3D Global $CentralGUIFontColor = "0x"&IniRead($SettingsFile, "Colors", "BlueLight", '0x33B5E5') Global $CentralGUIBkColor = "0x"&IniRead($SettingsFile, "B/W", "GrayLight", '0x3C3C3D') _DebugReportVar("$CentralGUIFontColor",$CentralGUIFontColor) _DebugReportVar("$CentralGUIBkColor",$CentralGUIBkColor) Global $CentralGUISize[4] = [@DesktopWidth / 2 - $CentralGUIWidth / 2, @DesktopHeight / 2 - $CentralGUIHeight / 2, $CentralGUIWidth, $CentralGUIHeight] Global $TimerInSeconds = 900 If $CmdLine[0] > 0 Then $TimerInSeconds = $CmdLine[1] Global $TimerEndDate = _DateAdd("s", $TimerInSeconds, _NowCalc()) _DebugOut("TimerEndDate = " & $TimerEndDate) Global $btn1, $oIE Global $PlayingState = 0, $RandomColorRandomize=0,$RandomColorMin=5000,$RandomColorMax=30000 $IniRadioArray = IniReadSection($SettingsFile, "RadioList") If IsArray($IniRadioArray) Then For $i = 1 To $IniRadioArray[0][0] _ArrayAdd($MusicURLSArray, $IniRadioArray[$i][1]) Next EndIf $IniColorsArray = IniReadSection($SettingsFile, "Colors") Local $oIE = _IECreateEmbedded() $hGUI = _GUICreate_BlankBox(0, 0, @DesktopWidth, @DesktopHeight, 0x000000, 155, False, Default, True) $ctrlIE = GUICtrlCreateObj($oIE, 0, 0, 0, 0) GUICtrlSetState($ctrlIE, $GUI_HIDE) $h1GUI = _GUICreate_BlankBox($CentralGUISize[0], 0, $CentralGUISize[2], 100, 0x000000, 200, True, $hGUI, True) $Title=GUICtrlCreateLabel('Take your time!', 0, 10, $CentralGUISize[2], 100, $SS_CENTER) GUICtrlSetFont(-1, 40, 600, Default, "Segoe UI", 5) GUICtrlSetColor(-1, $CentralGUIFontColor) $h2GUI = _GUICreate_BlankBox($CentralGUISize[0], $CentralGUISize[1], $CentralGUISize[2], $CentralGUISize[3], 0x000000, 200, True, $hGUI, True) Dim $lblSpacing = 5 Dim $lbl1_size[4] = [50, 0, 120, 120] ;this moves with the whole countdown Dim $lbl2_size[4] = [$lbl1_size[0] + $lbl1_size[2] + $lblSpacing, $lbl1_size[3], 100, 40] $lbl2_size[1] = $lbl2_size[1] - $lbl2_size[3] Dim $lbl3_size[4] = [$lbl2_size[0] + $lbl2_size[2] + $lblSpacing, $lbl1_size[1], $lbl1_size[2], $lbl1_size[3]] Dim $lbl4_size[4] = [$lbl3_size[0] + $lbl3_size[2] + $lblSpacing, $lbl3_size[3], 100, 40] $lbl4_size[1] = $lbl4_size[1] - $lbl4_size[3] $lblMinutes = GUICtrlCreateLabel("0", $lbl1_size[0], $lbl1_size[1], $lbl1_size[2], $lbl1_size[3], $SS_RIGHT) GUICtrlSetFont(-1, 80, 600, Default, "Segoe UI", 5) GUICtrlSetColor(-1, 0x0099CC) $lbl2Minutes = GUICtrlCreateLabel("minutes", $lbl2_size[0], $lbl2_size[1], $lbl2_size[2], $lbl2_size[3], $SS_LEFT) GUICtrlSetFont(-1, 20, 400, Default, "Segoe UI", 5) GUICtrlSetColor(-1, 0xA3A3A3) $lblSeconds = GUICtrlCreateLabel("0", $lbl3_size[0], $lbl3_size[1], $lbl3_size[2], $lbl3_size[3], $SS_RIGHT) GUICtrlSetFont(-1, 80, 600, Default, "Segoe UI", 5) GUICtrlSetColor(-1, 0xCC0000) $lbl2Seconds = GUICtrlCreateLabel("seconds", $lbl4_size[0], $lbl4_size[1], $lbl4_size[2], $lbl4_size[3], $SS_LEFT) GUICtrlSetFont(-1, 20, 400, Default, "Segoe UI", 5) GUICtrlSetColor(-1, 0xA3A3A3) $btn1 = GUICtrlCreateButton('Stop the music', $CentralGUISize[2] - 100, $CentralGUISize[3] - 30, 90, 25) GUICtrlSetBkColor(-1, $CentralGUIBkColor) GUICtrlSetColor(-1, $CentralGUIFontColor) GUICtrlSetFont(-1, 9, 400, Default, "Segoe UI") $btn2 = GUICtrlCreateButton('Clip radio URL', $CentralGUISize[2] - 200, $CentralGUISize[3] - 30, 90, 25) GUICtrlSetBkColor(-1, $CentralGUIBkColor) GUICtrlSetColor(-1, $CentralGUIFontColor) GUICtrlSetFont(-1, 9, 400, Default, "Segoe UI") $btn3 = GUICtrlCreateButton("Don't close", $CentralGUISize[2] - 300, $CentralGUISize[3] - 30, 70, 25) GUICtrlSetBkColor(-1, $CentralGUIBkColor) GUICtrlSetColor(-1, $CentralGUIFontColor) GUICtrlSetFont(-1, 9, 400, Default, "Segoe UI") $btn4 = GUICtrlCreateButton("Close", $CentralGUISize[2] - 60, 5, 50, 25) GUICtrlSetBkColor(-1, $CentralGUIBkColor) GUICtrlSetColor(-1, $CentralGUIFontColor) GUICtrlSetFont(-1, 9, 400, Default, "Segoe UI") GUICtrlSetState(-1, $GUI_HIDE) $chck = GUICtrlCreateCheckbox("", $CentralGUISize[2] - 300 - 13, $CentralGUISize[3] - 30 + 6, 15, 15, Default, $WS_EX_TOPMOST) ;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT ) GUICtrlSetBkColor(-1, 0x000000) ;DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($chck), "wstr", 0, "wstr", 0) GUICtrlCreateLabel("Volume:", $CentralGUISize[2] - 100 - 50 - 50, $CentralGUISize[3] - 30 - 30, 50, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, $CentralGUIBkColor) GUICtrlSetColor(-1, $CentralGUIFontColor) GUICtrlSetFont(-1, 9, 400, Default, "Segoe UI") $slider = GUICtrlCreateSlider($CentralGUISize[2] - 100 - 50, $CentralGUISize[3] - 30 - 30, 140, 25, $TBS_NOTICKS) GUICtrlSetData(-1, _GetMasterVolumeLevelScalar()) GUICtrlSetBkColor(-1, $CentralGUIBkColor) GUICtrlSetColor(-1, $CentralGUIFontColor) $time = GUICtrlCreateLabel("", 5, $CentralGUISize[3] - 25, 60, 20, BitOR($SS_LEFT, $SS_CENTERIMAGE)) GUICtrlSetColor(-1, $CentralGUIFontColor) GUICtrlSetFont(-1, 10, 600, Default, "Segoe UI") Switch IniRead($SettingsFile, "PomorodoPause", "PlayImmediately", 0) Case 0 StopPlaying() Case 1 StartPlaying() EndSwitch CountdownPoll() GUISetState() Ring() If IniRead($SettingsFile, "PomorodoPause", "RandomizeColors", 0) = 1 Then $interval = IniRead($SettingsFile, "PomorodoPause", "RandomizeColorsInterval", 30000) _DebugReportVar("$interval",$interval) If $interval > 0 Then If $interval < 1000 Then $interval = 1000 ;pojistka proti extra rychl�mu p�ep�n�n� AdlibRegister("ColorRandomizer", $interval) _DebugReport("AdlibRegister@ColorRandomizer",True) Else $RandomColorRandomize=1 _DebugReportVar("$RandomColorRandomize",$RandomColorRandomize) $RandomColorMin = IniRead($SettingsFile, "PomorodoPause", "RandomizeColorsIntervalMin", 5000) _DebugReportVar("$RandomColorMin",$RandomColorMin) $RandomColorMax = IniRead($SettingsFile, "PomorodoPause", "RandomizeColorsIntervalMax", 30000) _DebugReportVar("$RandomColorMax",$RandomColorMax) AdlibRegister("ColorRandomizer", Random($RandomColorMin, $RandomColorMax, 1)) _DebugReport("AdlibRegister@ColorRandomizer",True) EndIf EndIf AdlibRegister("CountdownPoll", 1000) _EndpointVolume_Init() Global $loop = 1 While 1 GUIPoll() $loop += 1 If $loop >= 20 Then $loop = 1 OtherLoopFunctions() EndIf WEnd Func GUIPoll() Switch GUIGetMsg() Case $btn1 Switch $PlayingState Case 1 StopPlaying() Case 0 StartPlaying() Case Else $PlayingState = 0 EndSwitch Case $btn2 For $i = 1 To 10 ClipPut(GetURL()) If ClipGet() <> "" Then ExitLoop Next Case $btn3 Switch GUICtrlRead($chck) Case $GUI_UNCHECKED GUICtrlSetState($chck, $GUI_CHECKED) Case $GUI_CHECKED GUICtrlSetState($chck, $GUI_UNCHECKED) EndSwitch Case $btn4 Terminate() EndSwitch EndFunc ;==>GUIPoll Func CountdownPoll() $SecondsToEnd = _DateDiff("s", _NowCalc(), $TimerEndDate) If $SecondsToEnd < 0 Then AdlibUnRegister("CountdownPoll") _DebugOut('$SecondsToEnd<0 --> AdlibUnRegister("CountdownPoll")') Ring(1) If GUICtrlRead($chck) = $GUI_UNCHECKED Then StopPlaying() Terminate() EndIf GUICtrlSetState($btn4, $GUI_SHOW) Return 0 EndIf $SecondsToEnd = Mod($SecondsToEnd, 86400) $iHours = Int($SecondsToEnd / 3600) $SecondsToEnd = Mod($SecondsToEnd, 3600) $iMins = Int($SecondsToEnd / 60) $iSecs = Mod($SecondsToEnd, 60) GUICtrlSetData($lblMinutes, $iMins) GUICtrlSetData($lblSeconds, $iSecs) Select Case $iMins > 1 Or $iMins = 0 GUICtrlSetData($lbl2Minutes, "minutes") Case $iMins = 1 GUICtrlSetData($lbl2Minutes, "minute") EndSelect Select Case $iSecs > 1 Or $iSecs = 0 GUICtrlSetData($lbl2Seconds, "seconds") Case $iSecs = 1 GUICtrlSetData($lbl2Seconds, "second") EndSelect GUICtrlSetData($time, _NowTime(5)) EndFunc ;==>CountdownPoll Func OtherLoopFunctions() If Not WinGetState($h2GUI) = 8 Then WinActivate($h2GUI) _MouseTrap($CentralGUISize[0], $CentralGUISize[1], $CentralGUISize[0] + $CentralGUISize[2] - 8, $CentralGUISize[1] + $CentralGUISize[3] - 8) _SetMasterVolumeLevelScalar(Round(GUICtrlRead($slider), 1)) EndFunc ;==>OtherLoopFunctions Func StartPlaying() $PlayingState = 1 GUICtrlSetData($btn1, "Stop the music") _DebugOut("Random:" & Random(1, UBound($MusicURLSArray) - 1, 1)) Return _IENavigate($oIE, $MusicURLSArray[Random(1, UBound($MusicURLSArray) - 1, 1)], 0) EndFunc ;==>StartPlaying Func StopPlaying() $PlayingState = 0 GUICtrlSetData($btn1, "Play the music") Return _IENavigate($oIE, "about:blank", 0) EndFunc ;==>StopPlaying Func GetURL() Return _IEPropertyGet($oIE, "locationurl") EndFunc ;==>GetURL Func ColorRandomizer() GUICtrlSetColor($lblMinutes, '0x' & $IniColorsArray[Random(1, $IniColorsArray[0][0], 1)][1]) GUICtrlSetColor($lblSeconds, '0x' & $IniColorsArray[Random(1, $IniColorsArray[0][0], 1)][1]) GUICtrlSetColor($Title, '0x' & $IniColorsArray[Random(1, $IniColorsArray[0][0], 1)][1]) GUICtrlSetColor($time, '0x' & $IniColorsArray[Random(1, $IniColorsArray[0][0], 1)][1]) if $RandomColorRandomize=1 Then AdlibRegister("ColorRandomizer", Random($RandomColorMin, $RandomColorMax, 1)) EndFunc ;==>ColorRandomizer Func Prompt() If _DateDiff("s", _NowCalc(), $TimerEndDate) <= 11 Then Terminate() $id = MsgBox(4 + 32 + 262144 + 8192, "It's just for your own good...", "Do you really want to skip the rest?!", 10, $h2GUI) Switch $id Case 6 ;yes Terminate() EndSwitch EndFunc ;==>Prompt Func Ring($wait = 0) SoundPlay("C:\Windows\Media\done.wav", $wait) EndFunc ;==>Ring Func Terminate() _BlockInputEx(0) _MouseTrap() _EndpointVolume_Close() Exit EndFunc ;==>Terminate Terminate() Edited June 6, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Guest Posted June 6, 2013 Posted June 6, 2013 On 6/6/2013 at 10:49 AM, JohnOne said: No example here, and why the hidden/shortened url? EDIT: Real url https://bitbucket.org/syk3s/pomo Examples are for UDFs, this is standalone app, the image has to be enough and the url is shortened because I'm just curious, how many visitors come.
mesale0077 Posted June 6, 2013 Posted June 6, 2013 (edited) label dont show why? 'Take your time!' Clip radio URL dont show why? Edited June 6, 2013 by mesale0077
Guest Posted June 6, 2013 Posted June 6, 2013 (edited) On 6/6/2013 at 1:00 PM, mesale0077 said: adsız78787.JPG label dont show why? 'Take your time!' Clip radio URL dont show why? check line 35-36 Global $CentralGUIFontColor = "0x"&IniRead($SettingsFile, "Colors", "BlueLight", '0x33B5E5') Global $CentralGUIBkColor = "0x"&IniRead($SettingsFile, "B/W", "GrayLight", '0x3C3C3D') and try to replace it with Global $CentralGUIFontColor = 0x33B5E5 Global $CentralGUIBkColor = 0x3C3C3D Did you downloaded/extracted/cloned the whole repo? Including settings.ini? Edit: If the problem were in these two lines, it's repaired now. The pain was probably in double '0x' prefix before hex color code when ini cannot be read. Edited June 6, 2013 by Guest
BrewManNH Posted June 6, 2013 Posted June 6, 2013 On 6/6/2013 at 1:21 PM, syk3s said: check line 35-36Global $CentralGUIFontColor = "0x"&IniRead($SettingsFile, "Colors", "BlueLight", '0x33B5E5') Global $CentralGUIBkColor = "0x"&IniRead($SettingsFile, "B/W", "GrayLight", '0x3C3C3D')and try to replace it withGlobal $CentralGUIFontColor = 0x33B5E5 Global $CentralGUIBkColor = 0x3C3C3DDid you downloaded/extracted/cloned the whole repo? Including settings.ini? Edit:If the problem were in these two lines, it's repaired now. The pain was probably in double '0x' prefix before hex color code when ini cannot be read.Color values don't need to be in hex to have them work. You can use decimal values instead or hex, they're equivalent, so there's no need to convert the string to look like it's a hex value, just store the decimal value of the color in the ini file. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! Reveal hidden contents I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Guest Posted June 6, 2013 Posted June 6, 2013 On 6/6/2013 at 2:18 PM, BrewManNH said: Color values don't need to be in hex to have them work. You can use decimal values instead or hex, they're equivalent, so there's no need to convert the string to look like it's a hex value, just store the decimal value of the color in the ini file. Yeah, that's possible as well, but most of the colors I can find on the web is in hex so I would have to convert something to something else anyway. And now when I changed it to this... Global $CentralGUIFontColor = "0x"&IniRead($SettingsFile, "Colors", "BlueLight", '33B5E5') Global $CentralGUIBkColor = "0x"&IniRead($SettingsFile, "B/W", "GrayLight", '3C3C3D') ...it works flawlessly once again. It was only my inattention.
BrewManNH Posted June 6, 2013 Posted June 6, 2013 On 6/6/2013 at 2:26 PM, syk3s said: Yeah, that's possible as well, but most of the colors I can find on the web is in hex so I would have to convert something to something else anyway. And now when I changed it to this...There's no need to convert it except in your script, just save it in the INI file as a number instead of as a string (e.g. "IniWrite($settingsfile, "Colors", "BlueLight", Number($CentralGUIFontColor))"). If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! Reveal hidden contents I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Guest Posted June 6, 2013 Posted June 6, 2013 Quote There's no need to convert it except in your script, just save it in the INI file as a number instead of as a string (e.g. "IniWrite($settingsfile, "Colors", "BlueLight", Number($CentralGUIFontColor))"). Well, as a matter of fact this is pointless, the script works well now and it won't work faster with decimal color codes. I apprecciate your help, but please spend your time with something more important e.g. with the sound gap, when radio starts. Btw in the whole script i do NOT use IniWrite, so I WOULD have to convert these values somewhere out of the script with another script or a program in order to have them decimal.
BrewManNH Posted June 6, 2013 Posted June 6, 2013 Why do you use an ini file if there's no way to change it? If there's no ini file in the script folder, you're going to get all default values anyways, so why bother having one at all? You might as well hard code all the values in the script. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! Reveal hidden contents I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Guest Posted June 6, 2013 Posted June 6, 2013 On 6/6/2013 at 4:01 PM, BrewManNH said: Why do you use an ini file if there's no way to change it? If there's no ini file in the script folder, you're going to get all default values anyways, so why bother having one at all? You might as well hard code all the values in the script. Because this script is just a part of the story, my main hero is gonna be in charge of all of these configs. Pomo-pause.au3 is just a reader. The writer, pomo.au3, is on the way, period
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now