Author Topic: Windows screensaver framework?  (Read 1874 times)

0 Members and 1 Guest are viewing this topic.

Offline bobtheunplayer

  • Newbie
  • Posts: 7
    • View Profile
Windows screensaver framework?
« on: January 31, 2019, 07:04:14 am »
One of the fun things about QB64 has always been making fun graphics demo, or just non-sense that looks cool.  What better way to enjoy the fruits of our efforts than by making it into a bona fide screensaver.  Unfortunately that code is going to be rather system specific, so lets build for the most popular desktop OS.

I'm just jumping into this for the first time, so any help or insight anyone has with Windows specific non-screen-0 stuff (Sorry Pete) would be greatly appreciated.

I found a C# tutorial, so I'm going to get that working someday, time permitting, and I have zero C# experience, so it could take a long minute.
https://www.harding.edu/fmccown/screensaver/screensaver.html

I feel like this might be something we would want to pursue as a community, and I wanted to start with you guys before I even open an editor.

Thanks,
Bob

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Windows screensaver framework?
« Reply #1 on: January 31, 2019, 07:11:26 am »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Windows screensaver framework?
« Reply #2 on: January 31, 2019, 07:43:29 am »
And my go at a screensaver for windows:

Code: QB64: [Select]
  1. CONST WaitBetweenChanges = 2 'seconds
  2.  
  3. IF _FILEEXISTS("PhotoList.txt") = 0 THEN 'no need to shell for a new listing over and over endlessly
  4.     'if you want a fresh file listing, delete the old  file before running the wallpaper changer.
  5.     SHELL _HIDE "DIR " + CHR$(34) + "C:\Users\Public\Pictures\" + CHR$(34) + " /b /s /a-d >PhotoList.txt"
  6.  
  7.  
  8. OPEN "PhotoList.txt" FOR BINARY AS #1
  9.     LINE INPUT #1, junk$
  10.     count = count + 1
  11.  
  12. SEEK #1, 1 'back to the beginning
  13.  
  14. DIM FileList(count) AS STRING
  15. FOR i = 1 TO count
  16.     LINE INPUT #1, FileList(i)
  17.     FileList(i) = FileList(i) + CHR$(0)
  18.  
  19.  
  20.  
  21.  
  22.  
  23. OriginalX = _MOUSEX: OriginalY = _MOUSEY
  24.  
  25.     _LIMIT 10 '10 loop per second
  26.     cycle = (cycle + 1) MOD (WaitBetweenChanges * 10)
  27.     X = _MOUSEX: Y = _MOUSEY
  28.     IF cycle = 1 THEN
  29.         CLS
  30.         loops = 0
  31.         DO
  32.             f = INT(RND * count) + 1
  33.             f$ = FileList(f)
  34.             result = 0
  35.             IF _FILEEXISTS(f$) THEN 'try a few times in case invalid files (like TXT files) are in the list.
  36.                 'I was lazy and didn't bother to just search for image files after all...
  37.                 image = _LOADIMAGE(f$, 32)
  38.                 IF image <> -1 THEN _PUTIMAGE , image: result = -1
  39.             END IF
  40.             loops = loops + 1
  41.         LOOP UNTIL result OR loops > 100
  42.         IF loops > 100 THEN PRINT "ERROR: Over 100 failures and no success... Terminating.": END
  43.         PRINT "Current Background: "; f$
  44.     END IF
  45.     IF X <> OriginalX OR Y <> OriginalY THEN done = -1
  46.     IF _MOUSEBUTTON(1) THEN done = -1
  47.     IF _MOUSEBUTTON(2) THEN done = -1
  48.     IF _KEYHIT THEN done = -1
  49. LOOP UNTIL done

This assumes that you're going to have pictures in the "C:\Users\Public\Pictures\" folder on your Windows PC.  If you don't, then kindly change it to point to a directory where you do have pictures stored, and it'll then use those for you to create an image flipping screensaver.

Instructions:

1) Give it a name and compile it.
2) Find the compiled *.EXE in your QB64 folder and rename it to *.SCR to make it a screen saver.
3) You can now RIGHT CLICK on the SCR file in your QB64 folder, and use the INSTALL option to install your new screensaver.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Windows screensaver framework?
« Reply #3 on: January 31, 2019, 10:10:04 am »
Hello bobtheunplayer,
welcome to the forum...

For some more examples feel free to download and try my small Screen Blanker collection (see signature).
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline bobtheunplayer

  • Newbie
  • Posts: 7
    • View Profile
Re: Windows screensaver framework?
« Reply #4 on: February 05, 2019, 09:59:33 am »
@RhoSigma got some nice screen blankers there.

@SMcNeill, that seems too easy, I'll give it a go.