Advertisement
jcunews

blankout.vbs

Mar 5th, 2023
2,015
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Save this script into a file named as e.g.: blankout.vbs.
  2. 'The file name should end with ".vbs".
  3. 'Run this script (or double click this script file) to start or stop it.
  4. 'A message dialog will be shown to indicate its status.
  5. '
  6. 'blankInterval and blankDuration values are in seconds unit.
  7. 'Fractional values can be used. e.g. 0.5 for half a second, or 20.5.
  8. '
  9. 'Notes:
  10. '- Blanking may not work if there's an application running in *exclusive*
  11. '  fullscreen mode. e.g. video players, games, etc.
  12. '- If Windows taskbar is set to auto-hide, and blanking occurs when user is
  13. '  typing or clicking, the thin lined collapsed taskbar may still be shown.
  14. '  Or the whole taskbar may still be shown if it occurs when user is clicking
  15. '  on the taskbar.
  16.  
  17. '-------- CONFIG BEGIN
  18.  
  19. blankInterval     = 20 * 60
  20. blankDuration     = 20
  21.  
  22. '-------- CONFIG END
  23.  
  24. set fs = createobject("scripting.filesystemobject")
  25. fn = fs.getspecialfolder(2) & "\blankout-running.marker"
  26. if fs.fileexists(fn) then
  27.   fs.deletefile fn
  28.   msgbox "Blankout has been stopped.", 64, "Blankout"
  29.   wsh.quit
  30. end if
  31. msgbox "Blankout will be started after closing this message.", 64, "Blankout"
  32. fs.createtextfile(fn, true).close
  33. set ws = createobject("wscript.shell")
  34. cmdline = "mshta.exe ""javascript:'<body bgcolor=#000><hta:application border=none caption=no contextmenu=no innerborder=no scroll=no windowstate=maximize /><script>setTimeout(close," & blankDuration & "*000)</script>'"""
  35. tc = 1
  36. t = blankInterval - int(blankInterval)
  37. if t > 0 then
  38.   t = t / 2
  39.   if t < 0.1 then t = 0.1
  40.   if t < tc then tc = t
  41. end if
  42. t = blankDuration - int(blankDuration)
  43. if t > 0 then
  44.   t = t / 2
  45.   if t < 0.1 then t = 0.1
  46.   if t < tc then tc = t
  47. end if
  48. tc = tc * 1000
  49. tthen = timer
  50. do while fs.fileexists(fn)
  51.   tnow = timer
  52.   if tnow >= tthen then
  53.     tthen2 = tthen
  54.   else
  55.     tthen2 = tthen + 86400
  56.   end if
  57.   if (tnow - tthen2) >= blankInterval then
  58.     tthen = tnow
  59.     ws.run cmdline
  60.   else
  61.     wsh.sleep tc
  62.   end if
  63. loop
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement