Timer

This topic contains 4 replies, has 2 voices, and was last updated by

 
Participant
1 year, 3 months ago.

  • Author
    Posts
  • #83810

    Participant
    Points: 2
    Rank: Member

    Hi,

    i have problem with timer

      $timer1.Interval = 1000
        [datetime]$StartDate = (Get-Date)
        [datetime]$EndDate = (Get-Date).AddMinutes(1)
        $timer1.Start()
        $timer1.Add_Tick({
                If ($EndDate -le 0) 
                {
                    $timer1.Stop()
                    $MainForm.WindowState = 0
                    $MainForm.StartPosition = 'CenterScreen'
                    $MainForm.TopMost = $True
                } 
                Else 
                {
                  # this is just for test
                  Write-Host "booooo"
                }
                
            })
    

    what i try to do, i have a form that i minimize, and after 10 min i want this form will pop up on the center of the screen

    Thanks.

  • #83852

    Participant
    Points: 1
    Rank: Member
  • #83863

    Participant
    Points: 2
    Rank: Member

    Hi Curtis,
    Thank you for link

    i try this

    $TT = 600 #in seconds 
            #Add TotalTime to current time 
            $script:StartTime1 = (Get-Date).AddSeconds($TT) 
               
        $timer1_Tick={
          # countdown timer
          [TimeSpan]$span1 = $script:StartTime1 - (Get-Date)
          # Update the display
          $hours1 = "{0:00}" -f $span1.Hours
          $mins1 = "{0:00}" -f $span1.Minutes
          $secs1 = "{0:00}" -f $span1.Seconds
          $labelTime.Text = "{0}:{1}:{2}" -f $hours1, $mins1, $secs1
          
          $timer1.Start()
          if ($span1.TotalSeconds -le 0)
          {
                
                $timer1.Stop() 
                $MainForm.WindowState = 0
                $MainForm.StartPosition = 'CenterScreen'
                $MainForm.TopMost = $True             
           
          }
          else
          { Write-Host "booooom"}
    
    

    but still not working

    Please help

  • #83873

    Participant
    Points: 2
    Rank: Member

    I try simple

    $a = (Get-Date).AddSeconds(20)
    $PopUp = $false
    while($PopUp -ne $true)
    {
        $b = Get-Date
        if($b -eq $a)
        {
            $c = new-object -comobject wscript.shell
            $d = $c.popup("done",0,"Test Message Box",1)
            $PopUp = $true
        }}
    

    but its not working when i change this on winform
    why?

  • #83902

    Participant
    Points: 1
    Rank: Member

    Where are you registering the event handler as shown on the page in the provided link?

The topic ‘Timer’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort