次の方法で共有


Make an interactive screen saver

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

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
    December 04, 2006
    I was given several dozen digital photos that I wanted to add to my collection. However, the camera used

  • Anonymous
    March 10, 2008
    How can i make a automatic screen savers

  • Anonymous
    March 10, 2008
    just like in our pc's if we stand alone our pc's sreensavers will automatically activated,,how can i do this in visual foxpro? thanx

  • Anonymous
    October 14, 2008
    I'm running VFP 8.0 SP1 on Windows XP as an administrator. I ran this example and test.exe runs just fine.  But when I run test.scr it gives the error message "File 'test.scr' does not exist".  Which is odd because test.scr is the very file that I'm running.  If I change it's name to test2.scr, the error message reads "File 'test2.scr' does not exist". I get this same error whether I right click on the scr and select "Test", "Configure" or "Install". Any advice on getting the scr to run?

  • Anonymous
    February 25, 2009
    Make an interactive screen saver 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

  • Anonymous
    May 29, 2009
    PingBack from http://paidsurveyshub.info/story.php?title=calvin-hsia-s-weblog-make-an-interactive-screen-saver

  • Anonymous
    May 31, 2009
    PingBack from http://woodtvstand.info/story.php?id=11267

  • Anonymous
    June 19, 2009
    PingBack from http://edebtsettlementprogram.info/story.php?id=23640