/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" Using ADO to get data from Excel to Dataset in Monad. "," Monad Really Does Rock "," Passing (not so) mandatory Parameters to WMI metho... "," Saving a WMI instance to a XML-file from MSH "," MSH Orphan share remover Tool "," MSH Welcome screen "," Read the raw Monad XML helpfiles "," MSH prompt-User function with Help "," Monad IRC Bot "," Getting performanceMonitor info from Monad "," ")

Monday, December 26, 2005

 


Monad NewYears Clock



Getting a clock Counting down the time till new Year,
and giving the current day and time.


















Enjoy and Best wishes for 2006

/\/\o\/\/

# Clock.msh
# gives time till NewYear and clock
# /\/\o\/\/ 2005

function Main {
  $pos  = $host.ui.rawui.windowposition
  $size = $host.ui.rawui.buffersize
  $rect = "system.management.automation.host.rectangle" 
  $posOld = $pos 
  $re = new-object $rect $pos.x,$pos.y,$size.width,($pos.y + 10
  $buffer = $host.ui.rawui.getbuffercontents($re) 
 
  While (!$host.ui.rawui.KeyAvailable) {
    $pos = $posOld
    ([datetime]"1-1-2006").Subtract((get-date)).tostring().Substring(0,([datetime]"1-1-2006").Subtract((get-date)).tostring().LastIndexOf(".")).getEnumerator() | foreach {
      DrawNum $_  "Red"
      $pos.x += 4
    }
    $pos.Y += 6 ; $pos.x = 0
    ((get-date)).tostring("dd-MM HH:mm").getEnumerator() | foreach {
      DrawNum $_  "Green"
      $pos.x += 4
    }
    sleep 1
  }
  $host.ui.rawui.SetBufferContents($posOld,$buffer)
}

Function DrawNum ($num = 0 ,$color){
  Switch($Num){
    0 {$ia = (367,61)} 
    1 {$ia = (292,36)} 
    2 {$ia = (487,57)} 
    3 {$ia = (487,60)} 
    4 {$ia = (493,36)} 
    5 {$ia = (463,60)} 
    6 {$ia = (463,61)} 
    7 {$ia = (295,36)} 
    8 {$ia = (495,61)} 
    9 {$ia = (495,60)} 
    ":" {$ia = (16,2)} 
    "." {$ia = (0,2)} 
    " " {$ia = (0,16)} 
    "-" {$ia = (448,0)} 
  }

  $row = ""
  foreach ($int in $ia) {
    0..8 | foreach {
      if ($int -band [math]::pow(2,$_)) {$row += [char]9608else {$row +=" "}
      if (($_ +1)%3 -eq 0) {$row += "`n"}
    }
  }
  $Buf = $host.ui.rawui.NewBufferCellArray(($row.trimEnd().Split("`n")),[System.ConsoleColor]$color,"black")
  $host.ui.rawui.SetBufferContents($pos,$buf)
}

. main



Comments: Post a Comment



<< Home

Archives

October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Google
 
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?