Post by just me » 17 May 2015, 10:41
Hallo und willkommen im Club!
Die
FN-Tasten sind für AHK nicht auf allen Notebookmodellen problemlos erreichbar. Ich habe deshalb die Tastenkombinationen
Shift+
Ctrl+
+ und
Shift+
Ctrl+
- vorbelegt, Du kannst es alllerdings auch mit anderen Kombinationen ausprobieren. Hier scheint es zu funktionieren, vielleicht bei Dir auch:
Code: Select all
#NoEnv
GetDisplayBrightness(Minimum, Current, Maximum) ; aktuelle Einstellungen abrufen
MsgBox, 0, Bildschirmhelligkeit, Minimum = %Minimum%`nAktuell = %Current%`nMaximum = %Maximum%
Return
; ======================================================================================================================
; Helligkeit erhöhen mit Shift+Ctrl++
+^+::
If (Current < Maximum) {
Current++
SetDisplayBrightness(Current)
ToolTip, %Current%
SetTimer, KillToolTip, -1000
}
Return
; ======================================================================================================================
; Helligkeit verringern mit Shift+Ctrl+-
+^-::
If (Current > Minimum) {
Current--
SetDisplayBrightness(Current)
ToolTip, %Current%
SetTimer, KillToolTip, -1000
}
Return
KillToolTip:
ToolTip
Return
; ======================================================================================================================
GetDisplayBrightness(ByRef Minimum, ByRef Current, ByRef Maximum) {
HMON := DllCall("User32.dll\MonitorFromWindow", "Ptr", 0, "UInt", 0x02, "UPtr")
DllCall("Dxva2.dll\GetNumberOfPhysicalMonitorsFromHMONITOR", "Ptr", HMON, "UIntP", PhysMons, "UInt")
VarSetCapacity(PHYS_MONITORS, (A_PtrSize + 256) * PhysMons, 0) ; PHYSICAL_MONITORS
DllCall("Dxva2.dll\GetPhysicalMonitorsFromHMONITOR", "Ptr", HMON, "UInt", PhysMons, "Ptr", &PHYS_MONITORS, "UInt")
HPMON := NumGet(PHYS_MONITORS, 0, "UPtr")
DllCall("Dxva2.dll\GetMonitorBrightness", "Ptr", HPMON, "UIntP", Minimum, "UIntP", Current, "UIntP", Maximum, "UInt")
DllCall("Dxva2.dll\DestroyPhysicalMonitors", "UInt", PhysMons, "Ptr", &PHYS_MONITORS, "UInt")
}
; ======================================================================================================================
SetDisplayBrightness(Brightness) {
Static Minimum := "", Current := "", Maximum := ""
HMON := DllCall("User32.dll\MonitorFromWindow", "Ptr", 0, "UInt", 0x02, "UPtr")
DllCall("Dxva2.dll\GetNumberOfPhysicalMonitorsFromHMONITOR", "Ptr", HMON, "UIntP", PhysMons, "UInt")
VarSetCapacity(PHYS_MONITORS, (A_PtrSize + 256) * PhysMons, 0) ; PHYSICAL_MONITORS
DllCall("Dxva2.dll\GetPhysicalMonitorsFromHMONITOR", "Ptr", HMON, "UInt", PhysMons, "Ptr", &PHYS_MONITORS, "UInt")
HPMON := NumGet(PHYS_MONITORS, 0, "UPtr")
DllCall("Dxva2.dll\GetMonitorBrightness", "Ptr", HPMON, "UIntP", Minimum, "UIntP", Current, "UIntP", Maximum, "UInt")
If Brightness Is Not Integer
Brightness := Current
If (Brightness < Minimum)
Brightness := Minimum
If (Brightness > Maximum)
Brightness := Maximum
DllCall("Dxva2.dll\SetMonitorBrightness", "Ptr", HPMON, "UInt", Brightness, "UInt")
DllCall("Dxva2.dll\DestroyPhysicalMonitors", "UInt", PhysMons, "Ptr", &PHYS_MONITORS, "UInt")
Return Brightness
}
Edit: Es könnte gut sein, dass das erst ab Win Vista funktioniert.
Edit: Fehler im Dllcall DestroyPhysicalMonitors korrigiert. Danke, pneumatic
Hallo und willkommen im Club!
Die[c]FN[/c]-Tasten sind für AHK nicht auf allen Notebookmodellen problemlos erreichbar. Ich habe deshalb die Tastenkombinationen [c]Shift[/c]+[c]Ctrl[/c]+[c]+[/c] und [c]Shift[/c]+[c]Ctrl[/c]+[c]-[/c] vorbelegt, Du kannst es alllerdings auch mit anderen Kombinationen ausprobieren. Hier scheint es zu funktionieren, vielleicht bei Dir auch:
[code]#NoEnv
GetDisplayBrightness(Minimum, Current, Maximum) ; aktuelle Einstellungen abrufen
MsgBox, 0, Bildschirmhelligkeit, Minimum = %Minimum%`nAktuell = %Current%`nMaximum = %Maximum%
Return
; ======================================================================================================================
; Helligkeit erhöhen mit Shift+Ctrl++
+^+::
If (Current < Maximum) {
Current++
SetDisplayBrightness(Current)
ToolTip, %Current%
SetTimer, KillToolTip, -1000
}
Return
; ======================================================================================================================
; Helligkeit verringern mit Shift+Ctrl+-
+^-::
If (Current > Minimum) {
Current--
SetDisplayBrightness(Current)
ToolTip, %Current%
SetTimer, KillToolTip, -1000
}
Return
KillToolTip:
ToolTip
Return
; ======================================================================================================================
GetDisplayBrightness(ByRef Minimum, ByRef Current, ByRef Maximum) {
HMON := DllCall("User32.dll\MonitorFromWindow", "Ptr", 0, "UInt", 0x02, "UPtr")
DllCall("Dxva2.dll\GetNumberOfPhysicalMonitorsFromHMONITOR", "Ptr", HMON, "UIntP", PhysMons, "UInt")
VarSetCapacity(PHYS_MONITORS, (A_PtrSize + 256) * PhysMons, 0) ; PHYSICAL_MONITORS
DllCall("Dxva2.dll\GetPhysicalMonitorsFromHMONITOR", "Ptr", HMON, "UInt", PhysMons, "Ptr", &PHYS_MONITORS, "UInt")
HPMON := NumGet(PHYS_MONITORS, 0, "UPtr")
DllCall("Dxva2.dll\GetMonitorBrightness", "Ptr", HPMON, "UIntP", Minimum, "UIntP", Current, "UIntP", Maximum, "UInt")
DllCall("Dxva2.dll\DestroyPhysicalMonitors", "UInt", PhysMons, "Ptr", &PHYS_MONITORS, "UInt")
}
; ======================================================================================================================
SetDisplayBrightness(Brightness) {
Static Minimum := "", Current := "", Maximum := ""
HMON := DllCall("User32.dll\MonitorFromWindow", "Ptr", 0, "UInt", 0x02, "UPtr")
DllCall("Dxva2.dll\GetNumberOfPhysicalMonitorsFromHMONITOR", "Ptr", HMON, "UIntP", PhysMons, "UInt")
VarSetCapacity(PHYS_MONITORS, (A_PtrSize + 256) * PhysMons, 0) ; PHYSICAL_MONITORS
DllCall("Dxva2.dll\GetPhysicalMonitorsFromHMONITOR", "Ptr", HMON, "UInt", PhysMons, "Ptr", &PHYS_MONITORS, "UInt")
HPMON := NumGet(PHYS_MONITORS, 0, "UPtr")
DllCall("Dxva2.dll\GetMonitorBrightness", "Ptr", HPMON, "UIntP", Minimum, "UIntP", Current, "UIntP", Maximum, "UInt")
If Brightness Is Not Integer
Brightness := Current
If (Brightness < Minimum)
Brightness := Minimum
If (Brightness > Maximum)
Brightness := Maximum
DllCall("Dxva2.dll\SetMonitorBrightness", "Ptr", HPMON, "UInt", Brightness, "UInt")
DllCall("Dxva2.dll\DestroyPhysicalMonitors", "UInt", PhysMons, "Ptr", &PHYS_MONITORS, "UInt")
Return Brightness
}[/code]
Edit: Es könnte gut sein, dass das erst ab Win Vista funktioniert.
Edit: Fehler im Dllcall DestroyPhysicalMonitors korrigiert. Danke, pneumatic