Date Time Widget scripting question

I have done a date time widget with a digital clock,(found a tutorial on that) but how do you do the scripting for a date time with a analog clock? I tried to replace the digital script with the analog script, but it didn't work.
9,847 views 6 replies
Reply #1 Top
There's aclock docklet by 'Judge' (I can't remember what it's called - seach Wincustomise, it's there, something to do with 'Italian') which has the script for an analog clock.

Basically you have to rotate the 'hands' bitmaps by working out the # of degrees per second/minute/hour. It's reasonably obvious once you see an example.

HTH

Reply #2 Top
This is what I use:

Code: vbscript
  1. desktopx.Object("secondhand").rotation = second(now) * 6
  2. desktopx.Object("minutehand").rotation = minute(now) * 6
  3. desktopx.Object("hourhand").rotation = (hour(now) * 30) + (30 * minute(now)/60)
Reply #3 Top
I already have that scripting for the clock,but how do you put the date scripting and the analog clock scripting together to make a date-analog clock? I have a script for the date-time with digital clock. I omitted the lines to the digital clock and replaced it with the analog script and it didnt work.
Reply #4 Top
Sub Object_OnScriptEnter
Object.SetTimer 1000, 30000
Call setinfo
End Sub

Sub Object_OnTimer1000
Call setinfo
End Sub

Sub setinfo
desktopx.Object("DayOfWeek").text=WeekDayName(Weekday(now),False)
desktopx.Object("MonthName").text=MonthName(Month(now)
desktopx.Object("Year").text=Year(now)
desktopx.Object("Date").text=Day(now)
t = FormatDateTime(time(),3)'---Get your system time

h= hour(t)'---Get current hour
desktopx.object("hour_hand").Rotation= h * 30 '---Multiply current hour to get correct rotation
m= minute(t)'---Get current minute
desktopx.object("minute_hand").Rotation= m * 6 '---Multiply current minute to get correct rotation
s= second(t)'---Get current second
desktopx.object("second_hand").Rotation= s * 6 '---Multiply current second to get correct rotation
End Sub
This is what i am trying to put together. Date-Time(analog)Widget.
Reply #5 Top
Just create a system date object and apply it to the face of your analog clock. There's a plug in called "Date using text states" which you should already have with DesktopX. It's format is ddd',' MMM dd yyyy which of course you can format to suit your needs. :) 
Reply #6 Top
For those who are interested. Figured it out. very simple :p
Sub Object_onscriptenter
object.SetTimer 1, 1000
End Sub

Sub object_ontimer1
t = FormatDateTime(time(),3)'---Get your system time

h= hour(t)'---Get current hour
desktopx.object("hour_hand").Rotation= h * 30 '---Multiply current hour to get correct rotation
m= minute(t)'---Get current minute
desktopx.object("minute_hand").Rotation= m * 6 '---Multiply current minute to get correct rotation
s= second(t)'---Get current second
desktopx.object("second_hand").Rotation= s * 6 '---Multiply current second to get correct rotation
desktopx.Object("DayOfWeek").text = WeekDayName(Weekday(now), False)
desktopx.Object("MonthName").text = MonthName(Month(now))
desktopx.Object("Year").text = Year(now)
desktopx.Object("Date").text = Day(now)
End Sub