home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / free_security / msshared / Shared_Computer_Toolkit_ENU.msi / FileBin011 < prev    next >
Encoding:
Text File  |  2005-09-02  |  6.4 KB  |  229 lines

  1. <html>
  2. <head>
  3. <META http-equiv="Content-Type" content="text/html; charset=utf-8" >
  4.     <!--
  5.     ' ------------------------------------------------------------------------------
  6.     ' Filename:        toast.hta
  7.     ' ------------------------------------------------------------------------------
  8.     ' Description:    Produces Messenger Style Toast Popups above the SysTray
  9.     ' ------------------------------------------------------------------------------
  10.     ' Version:        1.0
  11.     ' Notes:        
  12.     ' ------------------------------------------------------------------------------
  13.     ' Copyright (C) Microsoft Corporation 2005, All Rights Reserved
  14.     ' ------------------------------------------------------------------------------
  15.     -->
  16.     <title> </title>
  17.  
  18.     <bgsound id="backgroundSound" src="toast.wav" loop="0">
  19.     <script  id="toast" language="vbscript">
  20.         <!--
  21.         Option Explicit
  22.         
  23.         ' declare variables and constants
  24.         Dim Debug, iTimerId, iCount, iSeconds, iSession
  25.         Const TOASTWIDTH   = 280
  26.         Const TOASTHEIGHT  = 120
  27.         Const TOASTOFFSETX = 5
  28.         Const TOASTOFFSETY = 5
  29.  
  30.         ' ------------------------------------------------------------------------------
  31.         ' Name:            Setup()
  32.         ' ------------------------------------------------------------------------------
  33.         ' Purpose:        
  34.         ' ------------------------------------------------------------------------------
  35.         Sub Setup()
  36.             Dim oWMIService, colProcesslist, oProcess, bMagnify
  37.             bMagnify = False
  38.  
  39.             ' set debugging variable
  40.             Debug = False
  41.  
  42.             ' if we are not in debug mode, ignore all errors
  43.             If Not(Debug) Then On Error Resume Next
  44.  
  45.             ' set the application size and initial position
  46.             'Self.ResizeTo 180, 180
  47.             Self.ResizeTo TOASTWIDTH, TOASTHEIGHT
  48.  
  49.             ' Check whether magnifier is running 
  50.             Set oWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")
  51.             Set colProcesslist = oWMIService.ExecQuery("Select * from Win32_Process Where Name = 'magnify.exe'")
  52.             For Each oProcess in colProcesslist
  53.                 Self.MoveTo Screen.availWidth-TOASTWIDTH+TOASTOFFSETX, Screen.availHeight-TOASTOFFSETY
  54.                 bMagnify = True
  55.                 Exit For
  56.             Next
  57.  
  58.             If Not bMagnify Then Self.MoveTo Screen.availWidth-(TOASTWIDTH+TOASTOFFSETX), Screen.availHeight-(TOASTHEIGHT+TOASTOFFSETY)
  59.         End Sub
  60.  
  61.         ' ------------------------------------------------------------------------------
  62.         ' Name:            Main()
  63.         ' ------------------------------------------------------------------------------
  64.         ' Purpose:        
  65.         ' ------------------------------------------------------------------------------
  66.         Sub Main()
  67.             Dim sCmdLine, iTempSec, iSpace
  68.  
  69.             iCount   = 0
  70.             iSeconds = 60
  71.         
  72.             ' work out what was passed
  73.             sCmdLine = oToast.CommandLine
  74.  
  75.             iSpace = Len(sCmdLine) - InStrRev(sCmdLine, " ")
  76.  
  77.             ' ~~~ Ensure that a command-line parameter was passed, and use it to set time remaining
  78.             If iSpace <> 0 Then
  79.                 iTempSec = CInt(Right(sCmdLine, iSpace))
  80.  
  81.                 If iTempSec <> "" Then
  82.                     iSeconds = iTempSec
  83.                     iSession = iTempSec
  84.                 End If
  85.             End If
  86.  
  87.             ' position divs based on constants, can not be done in style sheet
  88.             btnClose.style.left   = TOASTWIDTH-16
  89.             divTitle.style.width  = TOASTWIDTH-26
  90.             tabMessg.style.width  = TOASTWIDTH-10
  91.             tabMessg.style.height = TOASTHEIGHT-35
  92.  
  93.             ' update the message
  94.             Call SetMessage()
  95.  
  96.             ' execute TimedSub() every 1000 milliseconds
  97.             iTimerId = Self.SetInterval ("Countdown()", 1000)
  98.         End Sub
  99.  
  100.         ' ------------------------------------------------------------------------------
  101.         ' Name:            Countdown()
  102.         ' ------------------------------------------------------------------------------
  103.         ' Purpose:        Update the countdown timer
  104.         ' ------------------------------------------------------------------------------
  105.         Sub Countdown()
  106.  
  107.             'If you replace this code make sure it works!    
  108.             If iSeconds = 280 then Self.Close
  109.             If iSeconds = iSession - 30 then Self.Close
  110.             
  111.             If iSeconds > 0 Then
  112.                 iSeconds = iSeconds - 1
  113.             Else
  114.                 Self.Close
  115.             End If
  116.  
  117.             ' update the message
  118.             Call SetMessage()
  119.         End Sub
  120.  
  121.         ' ------------------------------------------------------------------------------
  122.         ' Name:            SetMessage()
  123.         ' ------------------------------------------------------------------------------
  124.         ' Purpose:        Update the countdown timer
  125.         ' ------------------------------------------------------------------------------
  126.         Sub SetMessage()
  127.             Dim iMins, iSecs
  128.  
  129.             ' calculate mins and seconds
  130.             iMins = Int(iSeconds / 60)
  131.             iSecs = iSeconds - (iMins * 60)
  132.  
  133.             ' update the div
  134.             If iMins <> 1 Then
  135.                 divMessage.innerHTML = resPreMin.innerText & CStr(iMins) & resPostMin.innerText & CStr(iSecs) & resPostSec.innerText
  136.             Else
  137.                 divMessage.innerHTML = resPreMin.innerText & CStr(iMins) & resPostMin1.innerText & CStr(iSecs) & resPostSec.innerText
  138.             End If
  139.         End Sub
  140.     
  141.         ' setup location and size before hta is displayed
  142.         Call Setup()
  143.         -->
  144.     </script>
  145.     
  146.     <style type="text/css">
  147.         body
  148.         {
  149.             margin: 0px;
  150.             padding: 0px;
  151.             overflow: hidden;
  152.             color: navy;
  153.             background-image: URL(../graphics/toast.gif);
  154.         }
  155.  
  156.         .close
  157.         {
  158.             position: absolute;
  159.             top: 8px;
  160.             width: 11px;
  161.             height: 11px;
  162.             display: block;
  163.             font-size: 1pt;
  164.         }
  165.  
  166.         .title
  167.         {
  168.             position: absolute;
  169.             top: 5px;
  170.             left: 5px;
  171.             height: 15px;
  172.             display: block;
  173.             font-family: arial;
  174.             font-size: 8pt;
  175.         }
  176.         
  177.         .messg
  178.         {
  179.             position: absolute;
  180.             top: 30px;
  181.             left: 5px;
  182.             display: block;
  183.             font-family: arial;
  184.             font-size: 9pt;
  185.             font-weight: bold;
  186.             text-align: center;
  187.         }
  188.     </style>
  189.  
  190.     <hta:application ID="oToast"
  191.         APPLICATIONNAME="Toast"
  192.         BORDER="none"
  193.         CAPTION="no"
  194.         ICON=""
  195.         INNERBORDER="no"
  196.         MAXIMIZEBUTTON="no"
  197.         MINIMIZEBUTTON="no"
  198.         SCROLL="no"
  199.         SELECTION="no"        
  200.         SHOWINTASKBAR="no"
  201.         SINGLEINSTANCE="no"
  202.         SYSMENU="no"
  203.         VERSION="1.0"
  204.         WINDOWSTATE="normal"/>
  205.  
  206.     <!-- settings and resources -->
  207.     <div id="settings" style="display:none">
  208.         <p id="resPreMin"></p>
  209.         <p id="resPostMin1"> minute and </p>
  210.         <p id="resPostMin"> minutes and </p>
  211.         <p id="resPostSec"> seconds until mandatory logoff. Be sure to save your work.</p>
  212.     </div>
  213.  
  214. </head>
  215.  
  216. <body text="navy" onload="Main()">
  217.     <div id="btnClose"   class="close" onclick="Self.Close()"></div>
  218.     <div id="divTitle"   class="title">Logoff Warning</div>
  219.     <table id="tabMessg" border="0" class="messg">
  220.         <tr valign="middle"><td><div id="divMessage"></div></td></tr>
  221.     </table>
  222. </body>
  223. </html>
  224.  
  225.  
  226.  
  227.  
  228.  
  229.