AutoHotkey Community

It is currently May 27th, 2012, 7:46 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: basic screensaver
PostPosted: September 23rd, 2006, 2:12 pm 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
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 January 28th, 2012, 3:12 am, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 24th, 2006, 10:40 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Nice script. Although I haven't tried it, I think your approach appeals to people who like simple, working solutions (like me).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 25th, 2006, 11:12 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 30th, 2006, 11:59 pm 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2006, 10:52 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2006, 5:36 pm 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
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


Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 2nd, 2006, 5:39 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
After some more research and downloading the newest ahk version ;-)
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2006, 10:24 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2006, 7:15 pm 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
thnx,
and i have learned a lot by doing this


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 4th, 2006, 12:14 am 
Offline

Joined: December 4th, 2006, 12:09 am
Posts: 1
:D 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 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2006, 5:05 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
thnx a lot


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 29th, 2007, 11:43 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2007, 5:22 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 16th, 2008, 11:08 am 
Offline

Joined: January 12th, 2007, 4:30 am
Posts: 531
Location: Norway
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 16th, 2008, 3:12 pm 
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.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Cristi®, nothing and 10 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group