AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

basic screensaver
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Zed Gecko



Joined: 23 Sep 2006
Posts: 149

PostPosted: Sat Sep 23, 2006 1:12 pm    Post subject: basic screensaver Reply with quote

iīve made a little script, that acts like a screensaver.
If compiled and renamed to *.scr it will be launched by windows
like any other screensaver. So far it will only show a blank screen.
But i guess it can be a base for making own screensavers.

this is the 3rd version actually:

Code:
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795



this post was updated with new code, so the answers may refer to nonexisting code
_________________
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795


Last edited by Zed Gecko on Sat Jan 28, 2012 2:12 am; edited 4 times in total
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Sun Sep 24, 2006 9:40 pm    Post subject: Reply with quote

Nice script. Although I haven't tried it, I think your approach appeals to people who like simple, working solutions (like me).
Back to top
View user's profile Send private message Send e-mail
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Mon Sep 25, 2006 10:12 am    Post subject: Reply with quote

Well, it looks like a screen saver, but isn't one by Windows standards... See How to write a 32bit screen saver for the gory details...

Among other things, it should handle at least the /c /p (or /l) and /s parameters (plus /a), manage password in Win9x, call SystemParametersInfo(SPI_SETSCREENSAVERRUNNING,TRUE, ...) to lock Ctrl+Alt+Del), and so on...
Note also that theoritically, WinXP awaken the screen saver itself, ie. no need for monitoring the mouse or keyboard.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Zed Gecko



Joined: 23 Sep 2006
Posts: 149

PostPosted: Sat Sep 30, 2006 10:59 pm    Post subject: Reply with quote

Thanks for the link, itīs quite interesting but difficult.
I think reacting to command-line options is mostly harmless, but
the SystemParemetersInfo call is probably way out of my league.

After several hours of reaserch i came up with this line:
Code:

DllCall("SystemParametersInfo", "Str", "SPI_SETSCREENSAVERRUNNING", "UInt", "1", "Str", "&oldval", "UInt", "0")

to indicate the screensaver is running and
Code:
DllCall("SystemParametersInfo", "Str", "SPI_SETSCREENSAVERRUNNING", "UInt", "0", "Str", "&oldval", "UInt", "1")

to indicate it has stoped again.

Both DllCalls return the Errorlevel 0, so it should be a success,
but i canīt observe any effect.

Am I just wrong, or is it trickier?
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Sun Oct 01, 2006 9:52 am    Post subject: Reply with quote

Well, if I understood correctly, these calls should make the screen saver immune to the use of Ctrl+Alt+Del to bypass the password entry phase, plus it allows other programs to check if the SS is running or not.

Thanks for reseaching. Being fully compliant isn't probably mandatory, I have seen many SSs written in Visual Basic that felt in the same pitfall. But then, they are unusable in some cases, because they offer no protection.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Zed Gecko



Joined: 23 Sep 2006
Posts: 149

PostPosted: Sun Oct 01, 2006 4:36 pm    Post subject: Reply with quote

I found now the right article on msdn http://support.microsoft.com/?scid=kb%3Ben-us%3B226359&x=19&y=11
it says:
Quote:
SUMMARY
This article describes how to disable task switching and other system functions accessed through key combinations such as CTRL+ESC and ALT+TAB on Win32 Platforms.
Back to the top Back to the top
Windows 95 and Windows 98
Applications can enable and disable ALT+TAB and CTRL+ESC, for example, by calling SystemParametersInfo (SPI_SETSCREENSAVERRUNNING). To disable ALT+TAB and CTRL+ESC, set the uiParam parameter to TRUE; to enable the key combinations, set the parameter to FALSE:

UINT nPreviousState;

// Disables task switching
SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);

// Enables task switching
SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 0);


Note Applications that use SystemParametersInfo (SPI_SETSCREENSAVERRUNNING) to disable task switching must enable task switching before exiting or task switching remains disabled after the process terminates.


So I found out that

1. SPI_SETSCREENSAVERRUNNING is only neccessary for Win9x Systems.
My Win2000 System blocks Alt+Tab, etc. with anything run as a Screensaver (even a MsgBox). So I guess, all WinNT-based Systems will block these Key-Combinations on their own, when the screensaver is running.

2. My Code-Guess was incorrect, i know believe that it should be
Code:
DllCall("SystemParametersInfo", "Str", "SPI_SETSCREENSAVERRUNNING", "UInt", "1", "UInt*", previousstate, "UInt", "0")

for blocking , and
Code:
DllCall("SystemParametersInfo", "Str", "SPI_SETSCREENSAVERRUNNING", "UInt", "0", "UInt*", previousstate, "UInt", "0")

for unblocking, where "previousstate" is just the name of the var which will contain the previous state of SPI_SETSCREENSAVERRUNNING.
but this is still untested, caused by the lack of a Win9x System
Back to top
View user's profile Send private message
Zed Gecko



Joined: 23 Sep 2006
Posts: 149

PostPosted: Mon Oct 02, 2006 4:39 am    Post subject: Version 2 of my little try Reply with quote

After some more research and downloading the newest ahk version Wink
i came up with a new version
it uses OnMessage instead of timed subroutines and
supports (partially) the command-line arguments
it can be configured and saves the configuration in the registry
only about 10 lines of code have survived

Code:
See this topic's top post for latest code.
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Mon Oct 02, 2006 9:24 am    Post subject: Reply with quote

Great, you are a persistent guy, and you created a real framework now.
I suggest that you edit the first message and either you replace the first script, or point to the "final" one.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Zed Gecko



Joined: 23 Sep 2006
Posts: 149

PostPosted: Mon Oct 02, 2006 6:15 pm    Post subject: Reply with quote

thnx,
and i have learned a lot by doing this
Back to top
View user's profile Send private message
Maurice118



Joined: 03 Dec 2006
Posts: 1

PostPosted: Sun Dec 03, 2006 11:14 pm    Post subject: Reply with quote

Very Happy I want to say thank you for this nice script. It helped me alot to write my own screensaver that can start a program.
Saved me alot of time to do this not from scratch.

Thanks Zed Gecko

Maurice Cool
Back to top
View user's profile Send private message
Zed Gecko



Joined: 23 Sep 2006
Posts: 149

PostPosted: Fri Dec 08, 2006 4:05 am    Post subject: Reply with quote

thnx a lot
Back to top
View user's profile Send private message
gmoney
Guest





PostPosted: Mon Jan 29, 2007 10:43 pm    Post subject: run a command on screen saver exit? Reply with quote

Is it possible to run a command on screensaver exit?

I tried inserting a "Run" command in the WM_ENDAPP() subroutine, but it does not work. Also tried WM_CHECKEND() and tried at the end of the script right before "ExitApp".

The funny thing is if I test from the command line or use the "Preview" button it works fine. When the system launches the screensaver it doesn't work.

Any idea how to fix? or any idea what is different about the system calling the screensaver as opposed to calling in manually?
Back to top
Zed Gecko



Joined: 23 Sep 2006
Posts: 149

PostPosted: Thu Feb 08, 2007 4:22 am    Post subject: Reply with quote

Well, to run a command on screensaver exit, i suggest to
add a OnExit subrutine to the code.
http://www.autohotkey.com/docs/commands/OnExit.htm

This is probably the savest way.
To be honest, i donīt know how the system stops
the screensaver when itīs really running.
I just followed the guidelines Philo posted above.
And from what i found out about screensavers, there are several
things that work different on the different versions of Windows.
So i would not rely on the functions triggered by Windows Messages,
maybe some versions of Windows just kill the process.
Back to top
View user's profile Send private message
Murp|e



Joined: 12 Jan 2007
Posts: 531
Location: Norway

PostPosted: Tue Dec 16, 2008 10:08 am    Post subject: Reply with quote

Has anyone actually used this framework to create a screensaver and/or updated the framework itself? I searched the forums for "screensaver" and -oddly- didn't find this thread, but when I searched the documentation I did. This framework is exactly what I've been looking for and more than I had hoped for!

I briefly tested it yesterday and it seems to work fine out of the box. Is there any way to preview a small version of the screensaver in the Display Properties window itself? As shown here.

Alternatively, does anyone know how I could an image in the Display Properties window? I think somehow a BMP image would need to be included in the .EXE file as a resource for this to work (ResourceHacker type thing.) Would it be possible to update this image dynamically or would it be static?
Back to top
View user's profile Send private message Visit poster's website
Z_Gecko
Guest





PostPosted: Tue Dec 16, 2008 2:12 pm    Post subject: Reply with quote

I think it is possible to show a live preview in the Display Properties Screen.
To qoute myself:
Code:
;if argument = /p ####, or /l #### - here the saver should treat the #### as the decimal representation of an HWND, and  pop up a child window to run in preview mode inside that window.


So you need to react on that cmd-line parameter and display a small gui, and make it a child of the Display Properties Screen. Iīm not shure how to position it(not even if itīs neccessary), but you could try to get the coordinates of the Static1-Control.
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group