Screen Saver Tricks
In a prior blog entry I describe how a couple lines of code can start the currently registered screen saver instantly and how to disable the screen saver.
Screen savers are funny animals. They are simply executable programs that typically will terminate whenever a mouse or keyboard event occurs. However, you can write a screen saver that reacts in other ways to user input.
(See Handling Screen Savers on MSDN for more info)
Run the code below, which creates a VFP Win32 executable and copies it to test.scr.
When explorer comes up, right click on test.scr and choose Install, which will install test.scr as a screen saver.
When the screen saver starts (see prior blog entry to see how to start the screen saver instantly) it presents a single textbox into which you can type VFP commands to execute.
For example, you can type “?4+5” and you have a screen saver calculator.
More interestingly, you can type these 3 lines:
PUBLIC x
x=CREATEOBJECT("internetexplorer.application")
x.Visible=1
Try hitting Alt-Tab and you can switch between your application and IE, but none of your other desktop applications (if you’re running with “On Resume Password Protect”)
One of my computers is easily visible in our home. Its screen saver is a VFP program that cycles randomly through my database of 16,000 family photos every 6 seconds. I can interactively query or search the picture data while still in screen saver mode.
*test.prg: screen saver
ERASE test.*
TEXT TO myvar TEXTMERGE noshow
PROCEDURE test(parm1,parm2,parm3)
PUBLIC oScreenSaver
IF parm1="/p" &&"preview mode in the config dlog box not supported
RETURN
ENDIF
oScreenSaver=NEWOBJECT("myform")
oScreenSaver.show()
ON KEY LABEL f4 clear events
READ events
quit
DEFINE CLASS myform as Form
showwindow=2 && in desktop
ADD OBJECT txtCmd as textbox WITH ;
width=SYSMETRIC(1)-100,left=100,height=30,;
selectonentry=1,;
fontsize=14,fontname="verdana"
PROCEDURE init
thisform.Width=SYSMETRIC(1)
thisform.Height=SYSMETRIC(2)
PROCEDURE txtCmd.valid
cCmd= ALLTRIM(this.value)
IF LEN(cCmd)>0
try
&cCmd
this.value=""
CATCH TO oErr
this.value=oErr.message
this.selectonentry=1
ENDTRY
ENDIF
ENDDEFINE
ENDTEXT
STRTOFILE(myvar,"test.prg")
STRTOFILE("screen=off","config.fpw")
MODIFY PROJECT test nowait
_vfp.ActiveProject.Files.Add("test.prg")
_vfp.ActiveProject.Files.Add("config.fpw")
_vfp.ActiveProject.Close
BUILD EXE test FROM test
ERASE config.fpw
*!/n test
COPY FILE test.exe TO test.scr
*MODIFY COMMAND startssave nowait
!start . && start Explorer in the curdir
43413
Comments
- Anonymous
August 02, 2005
Sometimes it’s useful to run some code in response to an event like somebody locking or unlocking your... - Anonymous
February 28, 2006
yes - Anonymous
August 13, 2006
I think it's great. I wish I had theose programming skills as My system locks up or crashes when I enable the Windows XP screensaver. Any ideas or solutions? - Anonymous
September 27, 2007
I have 23,000 digital pictures and movies taking many gigabytes of storage from the past decade or so.