Bom dia VadoJMS.
Em se tratando de
"apagar" a tela do computador, a melhor opção é a que você mesmo indentificou. No script abaixo eu coloquei ela para ser ativada através da tecla F2 e desativada através da tecla F3.
Code: Select all
Return
f2::
SendMessage 0x112, 0xF170, 2,,Program Manager
return
f3::
SendMessage 0x112, 0xF170, -1,,Program Manager
Return
Com a tela apagada pela tecla F2 do script acima, eu continuei escutando a musica que estava tocando no PC, o que significa que de fato, somente a tela foi apagada (o computador continuava respondendo).
No entanto, se essa opção não está funcionando por qualquer motivo, acredito que a segunda melhor opção é
criar uma GUI preta que cubra toda a tela e depois reduzir o brilho da tela. No entanto, cabe destacar que a tela acesa tem um brilho mínimo, então nunca vai ficar totalmente escuro. O script abaixo cria a tela preta e coloca o brilho no mínimo com F2 e depois destrói a tela preta e restaura o brilho original com F3.
Code: Select all
CLR := Monitor.GetBrightness()
Return
F2::
Monitor.SetBrightness(1,1,1)
Gui, +AlwaysOnTop
Gui, Color, 0x000000
Width := A_ScreenWidth + 100
Height := A_ScreenHeight + 100
Gui, Show, w%Width% h%Height%
Return
F3::
Gui, Destroy
Monitor.SetBrightness(CLR.Red,CLR.Green,CLR.Blue)
Return
; ===============================================================================================================================
Class Monitor
{
SetBrightness(red := 128, green := 128, blue := 128) ; https://msdn.microsoft.com/en-us/library/dd372194(v=vs.85).aspx
{
loop % VarSetCapacity(buf, 1536, 0) / 6
{
NumPut((r := (red + 128) * (A_Index - 1)) > 65535 ? 65535 : r, buf, 2 * (A_Index - 1), "ushort")
NumPut((g := (green + 128) * (A_Index - 1)) > 65535 ? 65535 : g, buf, 512 + 2 * (A_Index - 1), "ushort")
NumPut((b := (blue + 128) * (A_Index - 1)) > 65535 ? 65535 : b, buf, 1024 + 2 * (A_Index - 1), "ushort")
}
DllCall("gdi32\SetDeviceGammaRamp", "ptr", hDC := DllCall("user32\GetDC", "ptr", 0, "ptr"), "ptr", &buf)
DllCall("user32\ReleaseDC", "ptr", 0, "ptr", hDC)
}
GetBrightness() ; https://msdn.microsoft.com/en-us/library/dd316946(v=vs.85).aspx
{
VarSetCapacity(buf, 1536, 0)
DllCall("gdi32\GetDeviceGammaRamp", "ptr", hDC := DllCall("user32\GetDC", "ptr", 0, "ptr"), "ptr", &buf)
CLR := {}
CLR.Red := NumGet(buf, 2, "ushort") - 128
CLR.Green := NumGet(buf, 512 + 2, "ushort") - 128
CLR.Blue := NumGet(buf, 1024 + 2, "ushort") - 128
return CLR, DllCall("user32\ReleaseDC", "ptr", 0, "ptr", hDC)
}
SetColorTemperature(kelvin := 6500, alpha := 0.5) ; http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
{
kelvin := (kelvin < 1000) ? 1000 : (kelvin > 40000) ? 40000 : kelvin
kelvin /= 100
if (kelvin <= 66) {
red := 255
} else {
red := 329.698727446 * ((kelvin - 60) ** -0.1332047592)
red := (red < 0) ? 0 : (red > 255) ? 255 : red
}
if (kelvin <= 66) {
green := 99.4708025861 * Ln(kelvin) - 161.1195681661
green := (green < 0) ? 0 : (green > 255) ? 255 : green
} else {
green := 288.1221695283 * ((kelvin - 60) ** -0.0755148492)
green := (green < 0) ? 0 : (green > 255) ? 255 : green
}
if (kelvin >= 66) {
blue := 255
} else if (kelvin <= 19) {
blue := 0
} else {
blue := 138.5177312231 * Ln(kelvin - 10) - 305.0447927307
blue := (blue < 0) ? 0 : (blue > 255) ? 255 : blue
}
return this.SetBrightness(red * alpha, green * alpha, blue * alpha)
}
}
; ===============================================================================================================================
Por fim, para fazer com que a tela preta não apareça, ou seja,
que apenas o brilho seja diminuído ao máximo, basta remover os códigos de GUI, conforme fiz abaixo:
Code: Select all
CLR := Monitor.GetBrightness()
Return
F2::
Monitor.SetBrightness(1,1,1)
Return
F3::
Gui, Destroy
Monitor.SetBrightness(CLR.Red,CLR.Green,CLR.Blue)
Return
; ===============================================================================================================================
Class Monitor
{
SetBrightness(red := 128, green := 128, blue := 128) ; https://msdn.microsoft.com/en-us/library/dd372194(v=vs.85).aspx
{
loop % VarSetCapacity(buf, 1536, 0) / 6
{
NumPut((r := (red + 128) * (A_Index - 1)) > 65535 ? 65535 : r, buf, 2 * (A_Index - 1), "ushort")
NumPut((g := (green + 128) * (A_Index - 1)) > 65535 ? 65535 : g, buf, 512 + 2 * (A_Index - 1), "ushort")
NumPut((b := (blue + 128) * (A_Index - 1)) > 65535 ? 65535 : b, buf, 1024 + 2 * (A_Index - 1), "ushort")
}
DllCall("gdi32\SetDeviceGammaRamp", "ptr", hDC := DllCall("user32\GetDC", "ptr", 0, "ptr"), "ptr", &buf)
DllCall("user32\ReleaseDC", "ptr", 0, "ptr", hDC)
}
GetBrightness() ; https://msdn.microsoft.com/en-us/library/dd316946(v=vs.85).aspx
{
VarSetCapacity(buf, 1536, 0)
DllCall("gdi32\GetDeviceGammaRamp", "ptr", hDC := DllCall("user32\GetDC", "ptr", 0, "ptr"), "ptr", &buf)
CLR := {}
CLR.Red := NumGet(buf, 2, "ushort") - 128
CLR.Green := NumGet(buf, 512 + 2, "ushort") - 128
CLR.Blue := NumGet(buf, 1024 + 2, "ushort") - 128
return CLR, DllCall("user32\ReleaseDC", "ptr", 0, "ptr", hDC)
}
SetColorTemperature(kelvin := 6500, alpha := 0.5) ; http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
{
kelvin := (kelvin < 1000) ? 1000 : (kelvin > 40000) ? 40000 : kelvin
kelvin /= 100
if (kelvin <= 66) {
red := 255
} else {
red := 329.698727446 * ((kelvin - 60) ** -0.1332047592)
red := (red < 0) ? 0 : (red > 255) ? 255 : red
}
if (kelvin <= 66) {
green := 99.4708025861 * Ln(kelvin) - 161.1195681661
green := (green < 0) ? 0 : (green > 255) ? 255 : green
} else {
green := 288.1221695283 * ((kelvin - 60) ** -0.0755148492)
green := (green < 0) ? 0 : (green > 255) ? 255 : green
}
if (kelvin >= 66) {
blue := 255
} else if (kelvin <= 19) {
blue := 0
} else {
blue := 138.5177312231 * Ln(kelvin - 10) - 305.0447927307
blue := (blue < 0) ? 0 : (blue > 255) ? 255 : blue
}
return this.SetBrightness(red * alpha, green * alpha, blue * alpha)
}
}
; ===============================================================================================================================
Os códigos 2 e 3 acima utilizam a classe
Class Monitor, que foi escrita por JNIZM e está disponível em:
https://autohotkey.com/boards/viewtopic.php?t=7854