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 

Reducing system volume / muting when screensaver comes on

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Fuzz
Guest





PostPosted: Mon Apr 21, 2008 6:53 pm    Post subject: Reducing system volume / muting when screensaver comes on Reply with quote

Hi,

I've been looking for a way to reduce the volume when a screensaver comes on and so far have been unable to do so. The reducing volume bit is fairly easy, but I have been unable to find a way to detect when the screensaver is running. Any help would be greatly appreciated!

On a side note I was wondering whether there was a way to fade the volume in to a certain level e.g. 25% from a lower value through a script.

Thanks Smile
Back to top
Clash



Joined: 27 Jun 2006
Posts: 182

PostPosted: Mon Apr 21, 2008 9:23 pm    Post subject: Reply with quote

You could write an idle time script with the same idle time as the screensaver.

Code:


time=1 ;activate after 1 minute of idle time.

result := time
result *= 60000

loop {
if(A_TimeIdle = result){
soundset, 0, master,,1
}
sleep, 1000
}


To fade, you use a loop. These will loop 50 times making the volume go up one notch each loop. There's 100 'notches' in the volume. That is to say if the volume was at 0 you would need to press volume up 100 times to get to max.

Code:
;fade up - getting louder

loop 50{
vol:=vol
vol+=1 ; increment by 1. change to 2,3 etc to fade faster
soundset, %vol%, master,,1
sleep, 1000
}

;fade down - getting quieter

loop 50{
vol:=vol
vol-=1 ; decrement by 1. change to 2,3 etc to fade faster
soundset, %vol%, master,,1
sleep, 1000
}


If you really needed to only mute when the screensaver is activate, you'd need to find the reg key to the screensaver filename. then make a script which waits for that filename to be active using the process command.

You could cut out the reg bit by hard coding the screensaver filename. You can find the filenames in C:\WINDOWS\system32.

I made it myself because i thought it'd be useful. turned out to be really easy.

Code:
loop {
process, wait, FLIQLO.scr
soundset, 0, master,,1
sleep, 1
}

_________________
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 1125

PostPosted: Tue Apr 22, 2008 12:06 am    Post subject: Reply with quote

well, here's my crack at it. This script doesn't check the registry and it hasn't been extensively tested.
Code:
#Persistent
#SingleInstance Force
SetTimer, DetectScreenSaver, 1000
DetectScreenSaver:
winget, pn, processname, A
If (SubStr(pn, -3) = ".scr" )
{
   If !sc_on
   {
      SoundGet, OldSound
      SoundSet, 0
      sc_on = 1
   }
}
else If sc_on
{
   SoundSet, %OldSound%
   sc_on = 0
}
return

_________________
My Home Thread
More Common Answers: 1. It's in the FAQ 2. Ternary ( ? : ) guide 3. Post code with [code][/code] tags
Back to top
View user's profile Send private message
Clash



Joined: 27 Jun 2006
Posts: 182

PostPosted: Tue Apr 22, 2008 12:36 am    Post subject: Reply with quote

Works for me. You wouldn't know how to detect if the monitor's off would you? I don't use screensavers.
_________________
Back to top
View user's profile Send private message
orbik



Joined: 09 Apr 2008
Posts: 25
Location: Espoo, Finland

PostPosted: Tue Apr 22, 2008 1:29 am    Post subject: Reply with quote

This sounds like a job for the shell hook method explained here http://www.autohotkey.com/forum/viewtopic.php?p=123323#123323
You'll get notified immediately when the screensaver starts instead of waiting inside a loop.
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 1125

PostPosted: Tue Apr 22, 2008 1:39 am    Post subject: Reply with quote

Clash wrote:
Works for me. You wouldn't know how to detect if the monitor's off would you? I don't use screensavers.

Sry, I don't. I'm sure there's a magic Dll somewhere with a "MonitorStatus" function, but I don't know where.
_________________
My Home Thread
More Common Answers: 1. It's in the FAQ 2. Ternary ( ? : ) guide 3. Post code with [code][/code] tags
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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