It's pretty hard to explain without showing the code first, so here goes:
This is the code:
#l::
{
SoundGet, mutestate, , MUTE
if mutestate = Off
Send {Volume_Mute}
Sleep 200
DllCall("LockWorkStation")
Sleep 200
SendMessage,0x112,0xF170,2,,Program Manager
Return
}
And this is the log output:
002: {
003: SoundGet,mutestate,,MUTE
004: if mutestate = Off
005: Sleep,200 (0.20)
006: DllCall("LockWorkStation")
007: Sleep,200 (0.20)
008: SendMessage,0x112,0xF170,2,,Program Manager
009: Return (16.63)
Now to the actual "problem".
There is one part of the actual code that doesn't show up in the log (but still executes), which is the Send {Volume_Mute}
. I've tested that it still runs by setting volume to maximum, then triggering the hotkey. It locks the computer, then mutes it, which is exactly what it's supposed to do.
I'm just wondering why doesn't it show up in the log at all. My only guess would be that the curly braces is probably causing the "problem".
#l::
{ << This brace
SoundGet, mutestate, , MUTE
if mutestate = Off
Send {Volume_Mute} << The 2 braces here
Sleep 200
DllCall("LockWorkStation")
Sleep 200
SendMessage,0x112,0xF170,2,,Program Manager
Return
} << And this brace
I'm not really sure if this is what's causing the problem, but I'd really like to know what exactly is the cause.
Answer
After Windows XP, SoundGet
is not the best way to get the mute state. I recommend checking out the Vista Audio Library which I believe is currently the best method.
Simply save the file to your script's directory and include the it by using #Include
like this:
#Include VA.ahk
And here is the equivalent of your first 3 lines of code:
if ! VA_GetMasterMute()
VA_SetMasterMute(true)
No comments:
Post a Comment