Most screen savers will terminate when there is any mouse or keyboard activity, but a screen saver is just a program: it can do whatever it wants in response to input.

 

Below is 40 lines of sample code to make a Visual FoxPro screen saver which consists of a form with a textbox on it. When Explorer comes up at the end, right click on TEST.SCR and choose Install to install it as a screen saver. You can even copy the VFP exe file to VFP.SCR and install it as a screen saver!

 

When the screen saver is active (see prior blog entry for a shortcut to start the current screen saver immediately), you can type commands into the textbox much like you can in the VFP command window.

 

If you make your screen saver password protected, it will run in a different desktop (or WindowStation): Alt-Tab allows you to switch between applications running on a particular desktop.

 

Try typing this into the textbox

 

!/n taskmgr            

 

Now you can alt-tab between 2 tasks: the task manager and the screen saver.

 

Try typing these 3 lines into the textbox:

PUBLIC x

x=CREATEOBJECT("word.application")

x.visible=1

 

 

I have my screen saver randomly showing photographs out of my 15000 picture collection): users (my family) can interact with the photo app (What was that picture?: go back and see, make a different query, etc)

 

 

 

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

!start .    && start Explorer in the curdir

 

 

 

 

39262