WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Screensaver

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Fake Screensaver Sample Code

Keywords:    fake screensaver

Screensaver comes on after 10 seconds of no mouse activity:
;Fake screensaver
   timeout=10
   activitycheck=1
   pswd="abcd"

;Make difficut to cancel
IntControl(12,1+8,0,0,0)
;handle cancel button
IntControl(72,2,0,0,0)


while 1
   ;Start Hidden
   WinHide("")
   BoxTitle("Hospital Screensaver")
   BoxText("Hi there")
   ;Screen saver timeout 5 minutes = 300 seconds
   
   ; Activity check = 10 seconds
   
   
   ;Get current info
   previousmouse=MouseInfo(2)
   previouswin=WinGetActive()
   
   ;start waiting for delay
   countdown=timeout
   
   while 1
      if countdown <= 0 then break
      Timedelay(activitycheck)
      currentmouse=MouseInfo(2)
      currentwin=WinGetActive()
      if (currentmouse != previousmouse) || (currentwin != previouswin)
         previousmouse=currentmouse
         previouswin=currentwin
         countdown=timeout
      else
         countdown=countdown-activitycheck
      endif
   endwhile
   
   
   ; Timeout expired.  start fake screensaver
   while 1
      WinShow("")
      WinZoom("")
      IntControl(54,"",1,0,0)
      ;disable minimize and maximize window menus
      SC_MINIMIZE = 61472
      SC_MAXIMIZE = 61488
      hwnd=DllHwnd("") 
      sysmenu=DllCall(strcat(DirWindows(1),"USER32.DLL"),long:"GetSystemMenu",long:hwnd,long:0)
      DllCall(strcat(DirWindows(1),"USER32.DLL"),long:"RemoveMenu",long:sysmenu,long:SC_MINIMIZE,long:0)
      DllCall(strcat(DirWindows(1),"USER32.DLL"),long:"RemoveMenu",long:sysmenu,long:SC_MAXIMIZE,long:0)

      
      ;get mouse position
      previousmouse=MouseInfo(2)
      
      ;wait for avtivity
      While 1
         TimeDelay(1)
         currentmouse=MouseInfo(2)
         if currentmouse!=previousmouse then break
      endwhile
      
      ;Activity!!!  Prompt for password
      
      p=AskPassword("Screensaver","Enter Password")
      
      if p==pswd then break
      
      Display(5,"Ooop","Bad password")
      previousmouse=MouseInfo(2)
   endwhile
   WinHide("")
endwhile

;should never get here 
exit

;;;;;;;CANCEL ROUTINE
:CANCEL
   IntControl(72,2,0,0,0)
   return








Article ID:   W15295
File Created: 2002:09:05:13:51:08
Last Updated: 2002:09:05:13:51:08