Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Desktop Calendar


  • Please log in to reply
7 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
This script will add a small calendar of the current month to any image background. As the calendar is not interactive, the script doesn't require to be running all the time, just run it once to update the calendar.

Posted Image

Optional outside utilities:
Url2Bmp : required if you want to convert the resultant html file to image. otherwise you can set the html as desktop background.
IrfanView : to set image as desktop background. not reqd if you don't use Url2Bmp.

If you don't want to use the above utils then just run the script and set (manually) %temp%\cal.htm as desktop bg. (Tip : sending F5 to desktop refreshes it)

This script requires cal.htm (given below) and url2bmp (if used) in its own folder.

Run the script with the background pic as first cmd-line param. if pic is not specified, the background is blank white.

There are many utils around that add a wallpaper to desk but most of them are interactive and therefore reqd to be running all the time... i made this to save system resources.

Now the best part : The look of the calendar is completely configurable... just edit the cal.htm in any html editor (preferably a wysiwyg one like frontpage) and you can change colors / size / position / font / anything! someone knowing javascript can even add some fancy stuff like translucency etc. just take care not to modify the text of the calendar.


here's the script
/*
___________________________________________

             DESKTOP CALENDAR

                   rajat


___________________________________________
*/

;Path to irfanview (mod script to use any other wallpaper replacer)
IV = E:\Program Files\IrfanView\i_view32.exe

;Today's date highlight color
HCol = CCFFCC


;i like this cmd!
FileRead, CalFile, %A_ScriptDir%\Cal.htm


;use the first cmd line param as the bg pic
IfExist, %1%
{
	StringReplace, BGPic, 1, \, /, A
	StringReplace, CalFile, CalFile, <body background="file:///">, <body background="file:///%BGPic%">, A
}
Else
{
	RegRead, BGPic, HKEY_CURRENT_USER, Control Panel\Desktop, Wallpaper
	StringReplace, CalFile, CalFile, <body background="file:///">,<body background="file:///%BGPic%">, A
}

;easy stuff... get curr year and month
StringReplace, CalFile, CalFile, ThisYear, %A_YYYY%, A
StringReplace, CalFile, CalFile, ThisMonth, %A_MMMM%, A

;tell days to my script
Day1 = Su
Day2 = Mo
Day3 = Tu
Day4 = We
Day5 = Th
Day6 = Fr
Day7 = Sa

;get the day-of-week of first day of month
FormatTime, WDt, %A_YYYY%%A_MM%1, WDay

;increase count of blank days in first week
WDt -= 1
Loop, %WDt%
{
	StringTrimRight, CurrDy, Day%A_Index%, 0
	%CurrDy%Cnt ++
}

;fill in month's days
Loop
{
	FormatTime, DyMon, %A_YYYY%%A_MM%%A_Index%, ddd
	FormatTime, DtMon, %A_YYYY%%A_MM%%A_Index%, d
	IfEqual, DyMon,, Break
	StringLeft, DyMon, DyMon, 2
	%DyMon%Cnt ++
	StringTrimRight, CurrDyMonC, %DyMon%Cnt, 0
	StringReplace, CalFile, CalFile, %DyMon%%CurrDyMonC%, %DtMon%, A
}

;remove unfilled days from 1st, 5th and 6th week
Loop, 7
{
	StringTrimRight, CurrDy, Day%A_Index%, 0
	StringReplace, CalFile, CalFile, %CurrDy%1, %A_Space%, A
	
	StringTrimRight, CurrDy, Day%A_Index%, 0
	StringReplace, CalFile, CalFile, %CurrDy%5, %A_Space%, A
	
	StringTrimRight, CurrDy, Day%A_Index%, 0
	StringReplace, CalFile, CalFile, %CurrDy%6, %A_Space%, A
}


;highlight today
Today = %A_MDay%
StringLeft, test, Today, 1
IfEqual, test, 0, StringTrimLeft, Today, Today, 1
StringReplace, CalFile, CalFile, >%Today%<, ><span style="background-color: #%HCol%">%Today%</span><, A


;if url2bmp is found then create jpg file and if irfanview
;is found then set the jpg file as wallpaper.
FileDelete, %temp%\Cal.htm
FileDelete, %temp%\Cal.jpg
FileAppend, %CalFile%, %temp%\Cal.htm

IfExist, %A_ScriptDir%\url2bmp.exe
{
	RunWait, %A_ScriptDir%\url2bmp.exe -url "%temp%\Cal.htm" -format jpeg -file %temp%\cal.jpg -notinteractive -removesb -bx 800 -by 600
	IfExist, %IV%
		Run, %IV% %temp%\Cal.jpg /wall=0,,hide
}
Else
	Run, %temp%\Cal.htm


here's Cal.htm (put it in script's folder)
<html>

<body background="file:///">
<style><!--
body{font-family:verdana;}
//-->
</style>

<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>
 </p>
<p> </p>
<p> </p>
<p> </p>
<div align="right">
  <table border="1" style="border-collapse: collapse" bordercolor="#808080" id="AutoNumber1" bgcolor="#FFFFFF" cellpadding="0">
    <tr>
      <td colspan="7" align="center" height="25" bordercolor="#FFFFFF"><b>
      <font face="Verdana" color="#996600">ThisMonth <font size="1">ThisYear</font></font></b></td>
    </tr>
    <tr>
      <td width="25" align="center" bordercolor="#FFFFFF" bgcolor="#E2E2E2"><b>
      <font color="#006600" size="2">S</font></b></td>
      <td width="25" align="center" bordercolor="#FFFFFF" bgcolor="#E2E2E2">
      <font color="#333399" size="2"><b>M</b></font></td>
      <td width="25" align="center" bordercolor="#FFFFFF" bgcolor="#E2E2E2">
      <font color="#333399" size="2"><b>T</b></font></td>
      <td width="25" align="center" bordercolor="#FFFFFF" bgcolor="#E2E2E2">
      <font color="#333399" size="2"><b>W</b></font></td>
      <td width="25" align="center" bordercolor="#FFFFFF" bgcolor="#E2E2E2">
      <font color="#333399" size="2"><b>T</b></font></td>
      <td width="25" align="center" bordercolor="#FFFFFF" bgcolor="#E2E2E2">
      <font color="#333399" size="2"><b>F</b></font></td>
      <td width="25" align="center" bordercolor="#FFFFFF" bgcolor="#E2E2E2">
      <font color="#333399" size="2"><b>S</b></font></td>
    </tr>
    <tr>
      <td width="25" align="center" bordercolor="#FFFFFF">
      <font color="#006600" size="2">su1</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">mo1</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">tu1</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">we1</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">th1</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">fr1</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">sa1</font></td>
    </tr>
    <tr>
      <td width="25" align="center" bordercolor="#FFFFFF">
      <font color="#006600" size="2">su2</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">mo2</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">tu2</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">we2</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">th2</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">fr2</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">sa2</font></td>
    </tr>
    <tr>
      <td width="25" align="center" bordercolor="#FFFFFF">
      <font color="#006600" size="2">su3</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">mo3</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">tu3</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">we3</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">th3</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">fr3</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">sa3</font></td>
    </tr>
    <tr>
      <td width="25" align="center" bordercolor="#FFFFFF">
      <font color="#006600" size="2">su4</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">mo4</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">tu4</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">we4</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">th4</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">fr4</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">sa4</font></td>
    </tr>
    <tr>
      <td width="25" align="center" bordercolor="#FFFFFF">
      <font color="#006600" size="2">su5</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">mo5</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">tu5</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">we5</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">th5</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">fr5</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">sa5</font></td>
      </tr>
    <tr>
      <td width="25" align="center" bordercolor="#FFFFFF">
      <font color="#006600" size="2">su6</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">
      mo6</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">
      tu6</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">
      we6</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">
      th6</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">
      fr6</font></td>
      <td width="25" align="center" bordercolor="#FFFFFF"><font size="2" color="#333399">
      sa6</font></td>
    </tr>
  </table>
</div>

</body>

</html>

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


BoBo
  • Guests
  • Last active:
  • Joined: --
@ Rajat
what about to mention a scripts AHK compatibility/requirements/blabla :wink: :p

@ all
would it make sense to set a list of keywords as a footer if a script has been provided, so its topic could be easier identified/found if searched via the forums famous Search function ???

Feedback mandatory :!: :wink:

btw: happy new year 2 everybody out there :D

BoBo
  • Guests
  • Last active:
  • Joined: --
Hey, hey, hey.
Rajat's script reminds me on a thing I've thought about ages ago.
To create whatever (formated) text (e.g. the status of a process) and to display it at the desktop (as a wallpaper).

What I havn't found out was how to update that "message" constantly ... :
The "F5 refresh Desktop" seems not to have worked for whatever reason (as far as I can remember :roll: )

Finaly: Thx Rajat for that extraordinary codelicious thang 8)

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004

@ Rajat
what about to mention a scripts AHK compatibility/requirements/blabla

oops... i forgot to mention that it requires the latest download! ..thanx for reminding!!

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
There was a bug that caused the single digit dates of the month to not be highlighted. I fixed it.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


BoBo
  • Guests
  • Last active:
  • Joined: --

To create whatever (formated) text as a HTML page (e.g. the status of a process) and to display it at the desktop (as a wallpaper).

What I havn't found out was how to update that "message" constantly ... :
The "F5 refresh Desktop" seems not to have worked for whatever reason (as far as I can remember)


*using the famous BoBoBar I've found "the workarround" :arrow: [here...] :D

Eh, think about that - combined with URL2BMP you can get AHK's forum displayed as a frequently changing wallpaper this way. :lol:

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
sounds good!

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004

The "F5 refresh Desktop" seems not to have worked for whatever reason (as far as I can remember )


then try this one... this is bound to work.

Add this to the segment of a .html file
<meta http-equiv="refresh" content="5">
and it will refresh itself every 5 seconds... change 5 to anything! 8) (well...i too wear them at times!)

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat