Screen Saver Programs: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "<center>'''Creating a QB64 Screen Saver'''</center> Screen savers are simply graphics EXE programs renamed with the SCR file extension. The program should NOT use a lot of Window's CPU resources! To check the CPU usage, open '''Task Manager''' by pressing ''Ctrl + Alt + Delete'' keys and look for the QB64 program running in the ''Processes'' tab list. CPU usage should be less than 50% and ideally less than 20%. Use _LIMIT or SLEEP when needed. <center>'''Renam...")
 
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 6: Line 6:
<center>'''Renaming an EXE Program to a SCR File and Installing'''</center>
<center>'''Renaming an EXE Program to a SCR File and Installing'''</center>


The program can be renamed several ways using a program or batch file you make or doing it manually in Windows. In Windows you can open an '''Explorer''' window select the ''Tools'' menu and click ''Folder Options...''. Select the ''View'' tab and uncheck the ''Hide extensions for known file types'' box. Then you can simply rename the program file changing the extension. Then  
The program can be renamed several ways using a program or batch file you make or doing it manually in Windows. In Windows you can open an '''Explorer''' window select the ''Tools'' menu and click ''Folder Options...''. Select the ''View'' tab and uncheck the ''Hide extensions for known file types'' box. Then you can simply rename the program file changing the extension. Then
either move the file or ''Install'' it as explained below:
either move the file or ''Install'' it as explained below:


Line 15: Line 15:


''Example:'' A screen saver that un-organizes the Desktop.
''Example:'' A screen saver that un-organizes the Desktop.
{{CodeStart}} '' ''
{{CodeStart}}
S& = {{Cl|_SCREENIMAGE}}                  'get the image of the desktop
S& = {{Cl|_SCREENIMAGE}}                  'get the image of the desktop
{{Cl|RANDOMIZE}} {{Cl|TIMER}}
{{Cl|RANDOMIZE}} {{Cl|TIMER (function)|TIMER}}
screenx = {{Cl|_WIDTH (function)|_WIDTH}}(S&)    'use current screen resolution dimensions
screenx = {{Cl|_WIDTH (function)|_WIDTH}}(S&)    'use current screen resolution dimensions
screeny = {{Cl|_HEIGHT}}(S&)
screeny = {{Cl|_HEIGHT}}(S&)
{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(screenx, screeny, 32)
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(screenx, screeny, 32)
{{Cl|_FULLSCREEN}}
{{Cl|_FULLSCREEN}}
{{Cl|_DISPLAY}}
{{Cl|_DISPLAY}}
Line 41: Line 41:
   {{Cl|LOOP}}
   {{Cl|LOOP}}
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > "" {{Cl|OR (boolean)|OR}} mx <> 0 {{Cl|OR (boolean)|OR}} my <> 0  'check for any key press
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > "" {{Cl|OR (boolean)|OR}} mx <> 0 {{Cl|OR (boolean)|OR}} my <> 0  'check for any key press
{{Cl|SYSTEM}} '' ''                    'close screen saver immediately
{{Cl|SYSTEM}}                     'close screen saver immediately
{{CodeEnd}}
{{CodeEnd}}
{{small|Code by DSMan}}
{{Small|Code by DSMan}}




''See also:''
{{PageSeeAlso}}
 
* [[_MOUSEMOVEMENTX]], [[_MOUSEMOVEMENTY]]
* [[_MOUSEMOVEMENTX]], [[_MOUSEMOVEMENTY]]
* [[SCREEN (statement)]], [[_SCREENIMAGE]]
* [[SCREEN]], [[_SCREENIMAGE]]
* [[SAVEIMAGE]] {{text|(save image to bitmap program)}}
* [[SaveImage SUB]]
 




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 20:08, 5 January 2024

Creating a QB64 Screen Saver

Screen savers are simply graphics EXE programs renamed with the SCR file extension. The program should NOT use a lot of Window's CPU resources! To check the CPU usage, open Task Manager by pressing Ctrl + Alt + Delete keys and look for the QB64 program running in the Processes tab list. CPU usage should be less than 50% and ideally less than 20%. Use _LIMIT or SLEEP when needed.


Renaming an EXE Program to a SCR File and Installing

The program can be renamed several ways using a program or batch file you make or doing it manually in Windows. In Windows you can open an Explorer window select the Tools menu and click Folder Options.... Select the View tab and uncheck the Hide extensions for known file types box. Then you can simply rename the program file changing the extension. Then either move the file or Install it as explained below:

  • Install the program in the SCR file Right click pop-up menu.
  • Copy the SCR program to the C:\Windows\System32 folder so that Windows will list it in the Desktop Properties. Select the Screensaver tab's drop-down Menu List and select the new screensaver from the list.


Example: A screen saver that un-organizes the Desktop.

S& = _SCREENIMAGE                  'get the image of the desktop
RANDOMIZE TIMER
screenx = _WIDTH(S&)    'use current screen resolution dimensions
screeny = _HEIGHT(S&)
SCREEN _NEWIMAGE(screenx, screeny, 32)
_FULLSCREEN
_DISPLAY
temp& = _NEWIMAGE(40, 40, 32)
DO: _LIMIT 10
  x1 = INT(RND * screenx)
  y1 = INT(RND * screeny)
  x2 = x1 + 40
  y2 = y1 + 40
  _PUTIMAGE , S&, temp&, (x1, y1)-(x2, y2)  'place partial image into page box
  xoff1 = INT(40 - RND * 81) + x1
  yoff1 = INT(40 - RND * 81) + y1
  xoff2 = INT(40 - RND * 81) + x2
  yoff2 = INT(40 - RND * 81) + y2
  _PUTIMAGE (xoff1, yoff1)-(xoff2, yoff2), temp&, 0    'place image on the screen
  _DISPLAY
  DO WHILE _MOUSEINPUT                'check for mouse movement
    mx = mx + _MOUSEMOVEMENTX
    my = my + _MOUSEMOVEMENTY
  LOOP
LOOP UNTIL INKEY$ > "" OR mx <> 0 OR my <> 0  'check for any key press
SYSTEM                      'close screen saver immediately
Code by DSMan


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link