AutoHotkey Community

It is currently May 25th, 2012, 3:04 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: August 8th, 2004, 10:12 pm 
Offline

Joined: August 8th, 2004, 10:04 pm
Posts: 25
Location: Lubbock, Texas
How can a hotkey be made to run a screensaver (*.scr)? I would have thought something like this would do it:

#x:: Run, %windir%\system32\ssbezier.scr

But this causes the screensaver setup dialog box to pop up instead.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2004, 12:48 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
The one in particular you mentioned will launch if you pass /s as a parameter:

#x:: Run, %windir%\system32\ssbezier.scr /s

I think /s might be a standard parameter for all screen savers.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 9th, 2004, 4:04 am 
Offline

Joined: April 23rd, 2004, 4:38 am
Posts: 34
Location: Adelaide, South Australia
I found a tiny (4k) program that you can put anywhere (eg. C:\Windows) and call it to start your default screensaver. Here's the readme with site address...

Code:
********************  crayzee's start-screen-saver  v1.00  *******************

This is just a very simple program which tells window to start the chosen
screensaver. I saw such feature only in the m$ office's program bar (or how it
is called) but I don't use it. This is very small, you can make a shortcut to
it and start it with a hotkey etc. Use it when you know that you're going away
and don't trust windows that they will launch the screensaver surely;)
I don't think this is something *great* but it was coded in 5 minutes and the
icon took me about 20 mins;). I'm planning to implement something like turning
off the hard drive and such stuff...

* get the newest version and other utilities at
  http://crayzee.cjb.net or http://crayzee1.cjb.net
* write any comments, suggestions and bug reports to crayzee@mailbox.sk


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2004, 10:58 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Alternatively, I imagine the filename of the default screen saver is somewhere in the registry. If so, you could read it from there and then launch it as discussed above.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2004, 5:09 pm 
Offline

Joined: August 8th, 2004, 10:04 pm
Posts: 25
Location: Lubbock, Texas
Thanks, Mike and Chris. Adding /S activates the screensaver but once the Windows key is released, it's deactivated. If I could flush the keyboard buffer after the program begins, that might do it. Can that be done?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2004, 6:12 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I tested it on XP and it seems that registered hotkeys do not cause that problem. So try to ensure that the hotkey is registered by avoiding the use of the keyboard hook for that particular hotkey (by avoiding the $ prefix and the #UseHook directive).

For example, a script with just this single line in it works okay on my system:

#x::run, %WinDir%\system32\ssbezier.scr /s

But adding a $ before the #x causes the behavior you describe.

If it still doesn't work, maybe try a different hotkey than X. You could also add a Sleep delay in to give yourself time to release the key before the screen saver appears:

#x::
Sleep, 700 ; Prevents user's release of key from dismissing the saver.
run, %WinDir%\system32\ssbezier.scr /s
return

As a side note, it might be interesting to try using SetTimer in conjunction with MouseGetPos to activate the screen saver whenever the mouse is in one of the screen corners.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2004, 6:34 pm 
Offline

Joined: August 8th, 2004, 10:04 pm
Posts: 25
Location: Lubbock, Texas
Your mention of keyhooks got me thinking. Maybe I have some other programs that look for hotkeys that are interferring with AHK. Sure enough, after shutting down WordWeb ([url]http://wordweb.info/[/url]), which looks for Ctrl-Shift-W, the single-line #x code worked. It also works if I start AHK before WordWeb. Thanks, Chris!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 11th, 2004, 7:22 pm 
Offline

Joined: May 4th, 2004, 6:15 pm
Posts: 68
See This, I already have a script for running the current screen saver, just run the following script and u can run the current screen saver with

Ctrl+`

Code:
^`:: ; screensaver

   RegRead, screensaver, HKCU,Control Panel\Desktop ,ScreenSaveActive
   if screensaver = 0
   {
      MsgBox, 0, ScreenSaver, ScreenSaver Not Active,3
   }
   else
   {
   RegRead, screensaver, HKCU,Control Panel\Desktop ,SCRNSAVE.EXE
   run,%screensaver% /s
   }
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Without an AHK
PostPosted: November 12th, 2004, 4:51 am 
Is it possible to use that method without an AHK script? Like, executing the default screensaver from the command line by reading the value from the registry? The reason I ask is because currently we can't do it over at SlickRun and some people have asked for that. SlickRun basically passes commands and parameters to launch stuff, synonymous to typing it in the Run dialog.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2004, 1:55 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Although I couldn't find a way to directly start the user's chosen screensaver, I did find a couple of related things:

From the command prompt, this will show the "screensaver" tab of "Display Properties", which could allow you to press the Preview button to start it:
control desk.cpl,,1

Here is another trick that works in a script:
SendMessage, 0x112, 0xF140, 0,, Program Manager ; 0x112 is WM_SYSCOMMAND -- 0xF140 is SC_SCREENSAVE

What you could do is compile the above into an EXE and execute it from the command line to start the screensaver. If you do that, it's probably best to include #NoTrayIcon at the top of the script to prevent the tray icon from existing briefly.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2004, 6:59 pm 
Offline

Joined: May 4th, 2004, 6:15 pm
Posts: 68
I think the above script does the same thing , it runs the user selected screen saver. If u want to run a screensaver.scr file just run it as an exe file.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2005, 9:17 pm 
Offline

Joined: January 11th, 2005, 7:27 pm
Posts: 13
Chris wrote:

Here is another trick that works in a script:
SendMessage, 0x112, 0xF140, 0,, Program Manager ; 0x112 is WM_SYSCOMMAND -- 0xF140 is SC_SCREENSAVE


Can you tell me, how to get the sendmessage-parameters?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2005, 11:18 pm 
Offline

Joined: March 2nd, 2004, 10:10 pm
Posts: 443
Location: SLC, Utah
Check out Rajat's Tutorial on it:

http://www.autohotkey.com/docs/misc/SendMessage.htm

thanks,
beardboy


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, dra and 15 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