[code] Batch Clock Widget

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
carlos
Expert
Posts: 501
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: [code] Batch Clock Widget

#16 Post by carlos » 28 Oct 2013 22:06

@Aacini: I did a last optimization to model 1.
Now I want use your small model 1. I have a idea.

Aacini
Expert
Posts: 1670
Joined: 06 Dec 2011 22:15
Location: México City, México

Re: [code] Batch Clock Widget

#17 Post by Aacini » 29 Oct 2013 01:29

DOS_Probie wrote:Good Job Aacini, Like how you have everything balanced and centered. How do you implement the 12 hr format?

The variables involved in the 12 hr format are "ampm1" and "ampm2"; for example:

Code: Select all

set "ampm1= "
set "ampm2= "
if /I "%~1" equ "/12" set "ampm2=M" & shift

if "%ampm2%" neq " " (
   set "ampm1=A"
   if %hour% geq 12 set /A hour-=12 & set "ampm1=P"
   if "!hour!" equ "0" set hour=12
)


carlos wrote:@Aacini: good code.

I'm sure that we can optimize replacing if else for:

Code: Select all

set /a "h1=hour/10,h2=hour-10*h1"
set /a "m1=minute/10,m2=minute-10*m1"


Or other arithmetic operation.

that is better than old:

Code: Select all

if %hour% lss 10 (set /a "h1=0,h2=%hour%"
) else set /a "h1=%hour:~0,1%,h2=%hour:~1,1%"
if %minute% lss 10 (set /a "m1=0,m2=%minute%"
) else set /a "m1=%minute:~0,1%,m2=%minute:~1,1%"


Good idea! I just added such modification and also optimized another IF.


The "blinking dots" option has been added! See the updated code above...

Antonio

carlos
Expert
Posts: 501
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: [code] Batch Clock Widget

#18 Post by carlos » 29 Oct 2013 12:12

@Aacini: Very good fork. I will wait the timer and alarm.

Also, I posted a tiny model.

Dos_Probie
Posts: 233
Joined: 21 Nov 2010 08:07
Location: At My Computer

Re: [code] Batch Clock Widget

#19 Post by Dos_Probie » 29 Oct 2013 12:47

carlos wrote:@Aacini: Very good fork. I will wait the timer and alarm.

Also, I posted a tiny model.


Carlos, Like what you did on the Mini Clock, Fits well with my sidebar gadgets, hey
is there any way to make the time font heavier and keep with same size? DP

carlos
Expert
Posts: 501
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: [code] Batch Clock Widget

#20 Post by carlos » 29 Oct 2013 14:53

@Dos_Probie: updated the code for use wide numbers.

carlos
Expert
Posts: 501
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: [code] Batch Clock Widget

#21 Post by carlos » 29 Oct 2013 15:01

Updated again, few seconds after post.
I look that in the title using 12 hour format is not showed the AM or PM.
Fixed it.

Dos_Probie
Posts: 233
Joined: 21 Nov 2010 08:07
Location: At My Computer

Re: [code] Batch Clock Widget

#22 Post by Dos_Probie » 29 Oct 2013 15:48

carlos wrote:@Dos_Probie: updated the code for use wide numbers.


Like the Bigger readout Carlos, good job (instead of the digital readout) and since you had a partial time in the title block I revised mine to show the current year of 2013. DP :D

carlos
Expert
Posts: 501
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: [code] Batch Clock Widget

#23 Post by carlos » 29 Oct 2013 17:00

@DosProbie: thanks.
and @Aacini: I found a little improvement for the getdate function, i will post.

carlos
Expert
Posts: 501
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: [code] Batch Clock Widget

#24 Post by carlos » 29 Oct 2013 18:05

Posted the updated codes with the improved getdate function.
Now it not show errors messages (generally for asynchronus access for the same function) and recover.

Also before it specify as inffilename=nul thats is ok except that makecab in that case create a file called like CAB00692.TMP or with similar name. Then if you close the cmd "application" makecab is closed and can left this file.

edit:
after other test I found that the CAB00692.TMP similar file is created always and deleted, but makecab works from the current directory that is the folder where is located our .cmd. Then if error ocurrs, this CAB00692.TMP left in this folder, for avoid it, I specify a /L %temp% as switch of makecab, for work with the files in the temp folder. In case of error, the files that left makecab are in temp folder.
Also I again specify inffilename=nul for avoid that makecab write a .inf file, that size is round 4 kb. With this: in a loop we not write to many times 4kb to disk that is unnecessary.

Now, the function is better.
Last edited by carlos on 29 Oct 2013 19:00, edited 1 time in total.

carlos
Expert
Posts: 501
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: [code] Batch Clock Widget

#25 Post by carlos » 29 Oct 2013 18:47

I posted my two version of clock with the last version of getdate function.
That have the next remark:

Code: Select all

::revisited improves to getdate function


note: revisited.

@Aacini and @DosProbie: I hope the new revisited getdate function will be useful. I will like write a calendar but i not have more free time.

Aacini
Expert
Posts: 1670
Joined: 06 Dec 2011 22:15
Location: México City, México

Re: [code] Batch Clock Widget

#26 Post by Aacini » 30 Oct 2013 02:14

The alarm and timer options in my program are working now! See the updated code above. This new version also features a calendar, although in a preliminary version (it requires some cosmetic details). NOTE: The two "set /P" commands in :alarm subroutine requires a Bell character (Ctrl-G) in order to buzzing when the alarm/timer ends. If the alarm does not sound, insert the Ctrl-G in the right place:

Code: Select all

   set /P "=" < NUL
            ^-- Insert a Ctrl-G character here


@carlos: Yes, I reviewed the revisited getdate function, but I have not time to include it in my code right now; I will include it in the next version. However, the /D blinking dots and /T: timer options in my program requires that getdate function be as fast as possible, so I must do some test before include the changes.

Antonio

carlos
Expert
Posts: 501
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: [code] Batch Clock Widget

#27 Post by carlos » 30 Oct 2013 15:09

I fix the code of tiny model for show the full title in windows 7.

@Aacini: I like the calendar. I like as default option the display with calendar. Is possible set a variable with the default configuration.

b8two
Posts: 5
Joined: 31 Oct 2013 00:12

Re: [code] Batch Clock Widget

#28 Post by b8two » 31 Oct 2013 04:05

An alternative for getDate that avoids creating a file, then deleting it.

Code: Select all

:getDate
for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j
set /a "year=%ldt:~0,4%,month=1%ldt:~4,2%-100,day=1%ldt:~6,2%-100,hour=1%ldt:~8,2%-100,minute=1%ldt:~10,2%-100"
set "second=%ldt:~12,6%"
for /f %%A in ("%DATE%") DO set weekday=%%A
exit /B


Also weekday can be used directly
replace;

Code: Select all

Set wdp=!w:~%index%,3!

with; (or just put after above)

Code: Select all

set wdp=%weekday%
Last edited by b8two on 31 Oct 2013 20:04, edited 1 time in total.

carlos
Expert
Posts: 501
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: [code] Batch Clock Widget

#29 Post by carlos » 31 Oct 2013 15:25

@b8two: thanks for share the routine using wmic. I avoid wmic because it not works in a limit account or account that not are in Administrators or Administradores (in spanish) group.

Aacini
Expert
Posts: 1670
Joined: 06 Dec 2011 22:15
Location: México City, México

Re: [code] Batch Clock Widget

#30 Post by Aacini » 02 Nov 2013 00:57

The new version of MxPower clock is complete now. It has the calendar fully functional and it also features two new small sizes. See the updated code above. Note that from my point of view this version is the first one, that is, is my first version with all its features fully implemented.

Antonio

Post Reply