Ascend4nt Posted January 8, 2013 Author Share Posted January 8, 2013 (edited) So, I've adjusted the code again, this time it reads in the Base RGB components of the Ramp when the script starts, and therefore it can retain values between runs. I also added a little text label to indicate what the value is changed the 'exit + reset' menu option to reset the value it read on script entry, and changed the name on the 'Reset' button to a more appropriate 'Default'. I've also added error checking and fixed 2 small bugs with _SetDeviceGammaRamp. Maybe there should be a 'Reset' button too, I dunno.. I didn't want to complicate things much. Anyhoo, here's the new version: (*edit: read-blue value on GetDeviceGammaRampBaseRGB was off) expandcollapse popup#NoTrayIcon #include <Constants.au3> #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) Opt("GUIOnEventMode", 1) ;~ $hGUI_Tray = GUICreate(" DGC", 64, 200, 1, 1, Default, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $hGUI_Tray = GUICreate(" DGC", 64, 214, 1, 1, Default, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Tray_GUI_Hide") $c_Button_Reset = GUICtrlCreateButton("Default", 5, 7, 54, 20) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetOnEvent(-1, "_Gamma_Default") $cGammaVal = GUICtrlCreateLabel("128", 20, 202, 22, 14, $SS_CENTER) $c_Slider_Average = GUICtrlCreateSlider(12, 28, 44, 175, BitOR($TBS_BOTH, $TBS_AUTOTICKS, $TBS_VERT)) $h_Slider_Average = GUICtrlGetHandle($c_Slider_Average) GUICtrlSetLimit(-1, 256, 0) $aBaseRGB = _GetDeviceGammaRampBaseRGB() ;~ ConsoleWrite("Gamma Ramp BaseRGB = R:"&$aBaseRGB[0]&", G:"&$aBaseRGB[1]&", B:"&$aBaseRGB[2]&@CRLF) GUICtrlSetData(-1, $aBaseRGB[0]) ; 128 is default base GUICtrlSetData($cGammaVal, $aBaseRGB[0]) GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") TraySetClick(8) TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "_Exit") TrayCreateItem("Exit + Reset Gamma") TrayItemSetOnEvent(-1, "_ExitReset") TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "_Tray_GUI_Show") TraySetState() TraySetToolTip("DGC - Desktop Gamma Changer (left click to change / right click to exit)") ;~ DllCall("psapi.dll","bool","EmptyWorkingSet","handle",-1) While 1 Sleep(100) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _ExitReset() _SetDeviceGammaRamp($aBaseRGB[0], $aBaseRGB[1], $aBaseRGB[2]) Exit EndFunc Func _Tray_GUI_Show() Local $aMousePos = MouseGetPos() WinMove($hGUI_Tray, "", $aMousePos[0] - 70, $aMousePos[1] - 245) GUISetState(@SW_SHOW, $hGUI_Tray) ControlFocus($hGUI_Tray,"",$c_Slider_Average) EndFunc ;==>_Tray_GUI_Show Func _Tray_GUI_Hide() GUISetState(@SW_HIDE, $hGUI_Tray) EndFunc ;==>_Tray_GUI_Hide Func _Gamma_Default() _SetDeviceGammaRamp(128, 128, 128) GUICtrlSetData($c_Slider_Average, 128) GUICtrlSetData($cGammaVal, 128) ControlFocus($hGUI_Tray,"",$c_Slider_Average) EndFunc ;==>_Gamma_Reset Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam) If ($iMsg = $WM_VSCROLL And $lParam = $h_Slider_Average) Then Local $nScrollType, $iPos $nScrollType = BitAND($wParam, 0xFFFF) ; LoWord ; SB_THUMBPOSITION = 4, SB_THUMBTRACK = 5 (note: only 16-bits (0-65535) worth of precision if use $wParam) If ($nScrollType = 4 Or $nScrollType = 5) Then $iPos = BitAND(BitShift($wParam, 16), 0xFFFF) ; HiWord ;~ ConsoleWrite("SB_THUMBPOSITION or SB_THUMBTRACK msg, pos = "&$iPos&@CRLF) Else ; Usually mouse-up brings us here: $iPos = GUICtrlRead($c_Slider_Average) ;~ ConsoleWrite("GuiCtrlRead value:"&$iPos&@CRLF) EndIf _SetDeviceGammaRamp($iPos, $iPos, $iPos) GUICtrlSetData($cGammaVal, $iPos) EndIf Return $GUI_RUNDEFMSG EndFunc Func WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam) Switch $hWnd Case $hGUI_Tray If Not $wParam Then ; Window de-activated _Tray_GUI_Hide() EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_ACTIVATE ; ----------------------------------------------------------------------------------------------------- ; Func _GetDeviceGammaRampBaseRGB() ; ; Function to get the 1st RGB values of the Gamma Ramp. If no other processes have modified the ramp, ; these 3 should be equal, and the rest of the ramp hopefully corresponds to what _SetDeviceGammaRamp() ; sets the values to. ; ; Return: a 3-element array representing the base RGB values of the Gamma Ramp ; $aArray[0] = Red ; $aArray[0] = Red ; $aArray[0] = Red ; ; Author: Ascend4nt ; ----------------------------------------------------------------------------------------------------- Func _GetDeviceGammaRampBaseRGB() Local $n_ramp, $i, $hDC, $aRet, $iErr Local $aBaseRGB[3] = [128, 128, 128] $hDC = _WinAPI_GetDC(0) If ($hDC = 0) Then Return SetError(2,@error,$aBaseRGB) $n_ramp = DllStructCreate("short[" & (256 * 3) & "]") $aRet = DllCall("gdi32.dll", "bool", "GetDeviceGammaRamp", "handle", $hDC, "ptr", DllStructGetPtr($n_ramp)) $iErr = @error _WinAPI_ReleaseDC(0, $hDC) If $iErr Or Not $aRet[0] Then Return SetError(2,$iErr,$aBaseRGB) $aBaseRGB[0] = DllStructGetData($n_ramp, 1, 1) - 128 ; Red $aBaseRGB[1] = DllStructGetData($n_ramp, 1, 1+256) - 128 ; Green $aBaseRGB[2] = DllStructGetData($n_ramp, 1, 1+512) - 128 ; Blue Return $aBaseRGB EndFunc ;==>_GetDeviceGammaRampBaseRGB Func _SetDeviceGammaRamp($vRed = 128, $vGreen = 128, $vBlue = 128) Local $n_ramp, $rVar, $gVar, $bVar, $aRet, $i, $hDC, $iErr If $vRed < 0 Or $vRed > 386 Then SetError(1) Return -1 ;Invalid Red value EndIf If $vGreen < 0 Or $vGreen > 386 Then SetError(2) Return -1 ;Invalid Green value EndIf If $vBlue < 0 Or $vBlue > 386 Then SetError(3) Return -1 ;Invalid Blue value EndIf $n_ramp = DllStructCreate("short[" & (256 * 3) & "]") For $i = 1 To 256 $rVar = $i * ($vRed + 128) If $rVar > 65535 Then $rVar = 65535 $gVar = $i * ($vGreen + 128) If $gVar > 65535 Then $gVar = 65535 $bVar = $i * ($vBlue + 128) If $bVar > 65535 Then $bVar = 65535 DllStructSetData($n_ramp, 1, Int($rVar), $i) ;red DllStructSetData($n_ramp, 1, Int($gVar), $i + 256) ;green DllStructSetData($n_ramp, 1, Int($bVar), $i + 512) ;blue Next $hDC = _WinAPI_GetDC(0) If ($hDC = 0) Then Return SetError(-1,@error,-1) $aRet = DllCall("gdi32.dll", "bool", "SetDeviceGammaRamp", "handle", $hDC, "ptr", DllStructGetPtr($n_ramp)) $iErr = @error _WinAPI_ReleaseDC(0, $hDC) If $iErr Or Not $aRet[0] Then Return SetError(-1,$iErr,-1) Return 0 EndFunc ;==>_SetDeviceGammaRamp Edited January 8, 2013 by Ascend4nt My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs |Â Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) |Â Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
KaFu Posted January 8, 2013 Share Posted January 8, 2013 How about something like this at the top? If WinExists("0bc53fe0-59c2-11e2-bcfd-0800200c9a66") Then Exit AutoItWinSetTitle("0bc53fe0-59c2-11e2-bcfd-0800200c9a66") I've looked through my icon lib and this one seemed the best fit for me. DGC.ico  OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
lorenkinzel Posted January 8, 2013 Share Posted January 8, 2013 This is the icon that accompanied the old version. I thought it a good fit.±.ico Link to comment Share on other sites More sharing options...
Ascend4nt Posted January 9, 2013 Author Share Posted January 9, 2013 Hrm, doesn't matter to me what icon you choose, although I would personally think a typical monitor 'brightness' icon would work (https://www.google.com/search?q=brightness+icon&tbm=isch) My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs |Â Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) |Â Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Ascend4nt Posted January 10, 2013 Author Share Posted January 10, 2013 Okay, after using this for a few days, I've found that it definitely needed that 'reset' button and a few other adjustments. I also figured out that my fix for brightness wasn't completely kosher - I should have been adjusting the DLLStruct indexing instead of the loop condition (although the loop was still off by 1). So, I made some tweaks to those things,and found an article that covers exactly what we are doing here, and probably what everyone else was basing code on, @ Nirsoft (Changing the screen brightness programmingly - By using the Gamma Ramp API). So I used that to make the (maybe) final tweaks to the code, which is below.Also, hey - there's some free brightness icons here: http://findicons.com/search/brightness..Here's the current version (note the 'retained' gamma from any previous runs will be off since this uses the correct ramp method):expandcollapse popup#NoTrayIcon #include <Constants.au3> #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ; See 'Changing the screen brightness programmingly - By using the Gamma Ramp API:' ; @ http://www.nirsoft.net/vc/change_screen_brightness.html ; Singleton code: If WinExists("0bc53fe0-59c2-11e2-bcfd-0800200c9a66") Then Exit AutoItWinSetTitle("0bc53fe0-59c2-11e2-bcfd-0800200c9a66") Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1+2) Opt("GUIOnEventMode", 1) $hGUI_Tray = GUICreate(" DGC", 64, 234, 1, 1, Default, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Tray_GUI_Hide") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $c_Button_Reset = GUICtrlCreateButton("Reset", 5, 5, 54, 20) GUICtrlSetOnEvent(-1, "_ResetGamma") $c_Button_Default = GUICtrlCreateButton("Default", 5, 27, 54, 20) GUICtrlSetOnEvent(-1, "_Gamma_Default") $c_Slider_Average = GUICtrlCreateSlider(12, 48, 44, 175, BitOR($TBS_BOTH, $TBS_AUTOTICKS, $TBS_VERT)) $h_Slider_Average = GUICtrlGetHandle($c_Slider_Average) GUICtrlSetLimit(-1, 255, 0) $cGammaVal = GUICtrlCreateLabel("128", 20, 222, 22, 14, $SS_CENTER) $aBaseRGB = _GetDeviceGammaRampBaseRGB() ;~ ConsoleWrite("Gamma Ramp BaseRGB = R:"&$aBaseRGB[0]&", G:"&$aBaseRGB[1]&", B:"&$aBaseRGB[2]&@CRLF) GUICtrlSetData($c_Slider_Average, $aBaseRGB[0]) ; 128 is default base GUICtrlSetData($cGammaVal, $aBaseRGB[0]) GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") TraySetClick(8) Local $i = TrayCreateItem("Show Brightness Control") TrayCreateItem("") TrayItemSetOnEvent($i, "_Tray_GUI_Show") TrayCreateItem("Default Gamma") TrayItemSetOnEvent(-1, "_Gamma_Default") TrayCreateItem("Reset Gamma") TrayItemSetOnEvent(-1, "_ResetGamma") TrayCreateItem("") TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "_Exit") TrayCreateItem("Exit + Reset Gamma") TrayItemSetOnEvent(-1, "_ExitReset") TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "_Tray_GUI_Show") TraySetState() TraySetToolTip("DGC - Desktop Gamma Changer (left click to change / right click to exit)") DllCall("psapi.dll","bool","EmptyWorkingSet","handle",-1) While 1 Sleep(100) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _ExitReset() _SetDeviceGammaRamp($aBaseRGB[0], $aBaseRGB[1], $aBaseRGB[2]) Exit EndFunc Func _Tray_GUI_Show() Local $aMousePos = MouseGetPos() WinMove($hGUI_Tray, "", $aMousePos[0] - 80, $aMousePos[1] - 260) GUISetState(@SW_SHOW, $hGUI_Tray) ControlFocus($hGUI_Tray,"",$c_Slider_Average) EndFunc ;==>_Tray_GUI_Show Func _Tray_GUI_Hide() GUISetState(@SW_HIDE, $hGUI_Tray) EndFunc ;==>_Tray_GUI_Hide Func _ResetGamma() _SetDeviceGammaRamp($aBaseRGB[0], $aBaseRGB[1], $aBaseRGB[2]) GUICtrlSetData($cGammaVal, $aBaseRGB[0]) GUICtrlSetData($c_Slider_Average, $aBaseRGB[0]) If BitAND(WinGetState($hGUI_Tray), 2) Then ControlFocus($hGUI_Tray,"",$c_Slider_Average) EndFunc ;==>_Gamma_Reset Func _Gamma_Default() _SetDeviceGammaRamp(128, 128, 128) GUICtrlSetData($c_Slider_Average, 128) GUICtrlSetData($cGammaVal, 128) If BitAND(WinGetState($hGUI_Tray), 2) Then ControlFocus($hGUI_Tray,"",$c_Slider_Average) EndFunc ;==>_Gamma_Default Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam) If ($iMsg = $WM_VSCROLL And $lParam = $h_Slider_Average) Then Local $nScrollType, $iPos $nScrollType = BitAND($wParam, 0xFFFF) ; LoWord ; SB_THUMBPOSITION = 4, SB_THUMBTRACK = 5 (note: only 16-bits (0-65535) worth of precision if use $wParam) If ($nScrollType = 4 Or $nScrollType = 5) Then $iPos = BitAND(BitShift($wParam, 16), 0xFFFF) ; HiWord ;~ ConsoleWrite("SB_THUMBPOSITION or SB_THUMBTRACK msg, pos = "&$iPos&@CRLF) Else ; Usually mouse-up brings us here: $iPos = GUICtrlRead($c_Slider_Average) ;~ ConsoleWrite("GuiCtrlRead value:"&$iPos&@CRLF) EndIf _SetDeviceGammaRamp($iPos, $iPos, $iPos) GUICtrlSetData($cGammaVal, $iPos) EndIf Return $GUI_RUNDEFMSG EndFunc Func WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam) Switch $hWnd Case $hGUI_Tray If Not $wParam Then ; Window de-activated _Tray_GUI_Hide() EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_ACTIVATE ; ----------------------------------------------------------------------------------------------------- ; Func _GetDeviceGammaRampBaseRGB() ; ; Function to get the 1st RGB values of the Gamma Ramp. If no other processes have modified the ramp, ; these 3 should be equal, and the rest of the ramp hopefully corresponds to what _SetDeviceGammaRamp() ; sets the values to. ; ; Return: a 3-element array representing the base RGB values of the Gamma Ramp ; $aArray[0] = Red ; $aArray[1] = Green ; $aArray[2] = Blue ; ; Author: Ascend4nt ; ----------------------------------------------------------------------------------------------------- Func _GetDeviceGammaRampBaseRGB() Local $n_ramp, $i, $hDC, $aRet, $iErr Local $aBaseRGB[3] = [128, 128, 128] $hDC = _WinAPI_GetDC(0) If ($hDC = 0) Then Return SetError(2,@error,$aBaseRGB) $n_ramp = DllStructCreate("short[" & (256 * 3) & "]") $aRet = DllCall("gdi32.dll", "bool", "GetDeviceGammaRamp", "handle", $hDC, "ptr", DllStructGetPtr($n_ramp)) $iErr = @error _WinAPI_ReleaseDC(0, $hDC) If $iErr Or Not $aRet[0] Then Return SetError(2,$iErr,$aBaseRGB) ; 1st element should be 0, so second element of each ramp should have the value we need for the base $aBaseRGB[0] = DllStructGetData($n_ramp, 1, 1+1) - 128 ; Red $aBaseRGB[1] = DllStructGetData($n_ramp, 1, 1+1+256) - 128 ; Green $aBaseRGB[2] = DllStructGetData($n_ramp, 1, 1+1+512) - 128 ; Blue If $aBaseRGB[0] > 255 Then $aBaseRGB[0] = 255 If $aBaseRGB[1] > 255 Then $aBaseRGB[1] = 255 If $aBaseRGB[2] > 255 Then $aBaseRGB[2] = 255 Return $aBaseRGB EndFunc ;==>_GetDeviceGammaRampBaseRGB ; ----------------------------------------------------------------------------------------------------- ; Func _SetDeviceGammaRamp($vRed = 128, $vGreen = 128, $vBlue = 128) ; ; Sets GammaRamps for Red, Green, and Blue. If all 3 inputs are equal, the net effect ; is that the brightness is adjusted. ; ; $vRed = value from 0 - 255 ; $vGreen = value from 0 - 255 ; $vBlue = value from 0 - 255 ; ; Original AutoIt version (before fixes) appears to be at: ; http://autoit.de./index.php?page=Thread&postID=156967 ; ; ----------------------------------------------------------------------------------------------------- Func _SetDeviceGammaRamp($vRed = 128, $vGreen = 128, $vBlue = 128) Local $n_ramp, $rVar, $gVar, $bVar, $aRet, $i, $hDC, $iErr If ($vRed < 0 Or $vRed > 255) Or _ ($vGreen < 0 Or $vGreen > 255) Or _ ($vBlue < 0 Or $vBlue > 255) Then Return SetError(1,0,-1) ; Invalid value for one of the colors EndIf $n_ramp = DllStructCreate("short[" & (256 * 3) & "]") For $i = 0 To 255 $rVar = $i * ($vRed + 128) If $rVar > 65535 Then $rVar = 65535 $gVar = $i * ($vGreen + 128) If $gVar > 65535 Then $gVar = 65535 $bVar = $i * ($vBlue + 128) If $bVar > 65535 Then $bVar = 65535 ; +1 to account for 1-based index in a 0-255 based loop DllStructSetData($n_ramp, 1, Int($rVar), $i+1) ;red DllStructSetData($n_ramp, 1, Int($gVar), $i+1 + 256) ;green DllStructSetData($n_ramp, 1, Int($bVar), $i+1 + 512) ;blue Next $hDC = _WinAPI_GetDC(0) If ($hDC = 0) Then Return SetError(-1,@error,-1) $aRet = DllCall("gdi32.dll", "bool", "SetDeviceGammaRamp", "handle", $hDC, "ptr", DllStructGetPtr($n_ramp)) $iErr = @error _WinAPI_ReleaseDC(0, $hDC) If $iErr Or Not $aRet[0] Then Return SetError(-1,$iErr,-1) Return 0 EndFunc ;==>_SetDeviceGammaRamp My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs |Â Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) |Â Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
lorenkinzel Posted January 10, 2013 Share Posted January 10, 2013 Well THAT caterpillar certainly turned into a butterfly. Excellent work, & dang; leaving no stone unturned........ Link to comment Share on other sites More sharing options...
Ascend4nt Posted January 10, 2013 Author Share Posted January 10, 2013 Well, a few more tweaks and that butterfly is now flying my man! haha.. check the first post for the 'final' versions of the Dimmer and other scripts we all helped create. Thanks everyone who contributed And as always, any suggestions, improvements, or novel new ideas, please post! My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs |Â Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) |Â Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Ascend4nt Posted May 15, 2013 Author Share Posted May 15, 2013 Minor updates to WindowsDimmer.au3: Changelog: 2013-05-14 + Added _GraphicsIsGammaRampSupported() function which checks if the graphics device supports Gamma Ramps (used by WindowsDimmer.au3). + Small speedup of DLLCalls Note, running the script in x86 mode appears to be more conservative with memory, if you keep an eye on that sort of thing My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs |Â Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) |Â Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
guinness Posted May 16, 2013 Share Posted May 16, 2013 I tested the update and works as expected. Thanks. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
orbs Posted August 3, 2018 Share Posted August 3, 2018 (edited) great program, very useful, thanks for developing this! i stumbled upon this in my search for a utility that changes the screen "temperature" - i.e. makes the monitor color a bit more red at night - similar to what f.lux does. f.lux works well but is annoyingly hard to configure, with lots of features i don't need. web resources claim that changing the temperature is done via gamma adjustment, which is what this dimmer is doing - except it keeps the RGP values identical, so the color remains in the gray scale. i tried to fiddle around with this line: _SetDeviceGammaRamp($iPos, $iPos, $iPos) (in the WM_VSCROLL function), changing combinations of values to $iPos/2 and other factors - but i can't get the colors quite as "reddish" as i want. my best attempt thus far is: _SetDeviceGammaRamp($iPos/2, $iPos/3, $iPos/4) and that produces an acceptable result only when i scroll all the way down. am i in the right direction about this? Edited August 3, 2018 by orbs Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration -  literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff  Link to comment Share on other sites More sharing options...
Earthshine Posted August 3, 2018 Share Posted August 3, 2018 windows 10 has a night time filter you can turn on. Is this different? My resources are limited. You must ask the right questions  Link to comment Share on other sites More sharing options...
orbs Posted August 3, 2018 Share Posted August 3, 2018 perhaps. since i'm allergic to Windows 10, i cannot test this. there are some alternatives for Windows 7 (i'm also investigating this), yet i believe it can be achieved with the tool presented in this topic, in pure AutoIt. argumentum 1 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration -  literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff  Link to comment Share on other sites More sharing options...
Earthshine Posted August 3, 2018 Share Posted August 3, 2018 Ah.  I see My resources are limited. You must ask the right questions  Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now