Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

TinyBrightnessControler v 1.0.0.2


  • Please log in to reply
23 replies to this topic

#1 wakillon

wakillon

    Tiny Tools Coder

  • Active Members
  • PipPipPipPipPipPip
  • 2,867 posts

Posted 16 April 2011 - 09:14 AM

It's late and Screen brightness hurts your eyes
and you do not remember how you can regulate it ?

I get a solution ! :graduated:

TinyBrightnessControler

Left click on Tray Icon for show Controler and Right click for Tray Menu, that's all !

AutoIt         
#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Electric bulb1.ico #AutoIt3Wrapper_outfile=TinyBrightnessControler.exe #AutoIt3Wrapper_Res_Description=Adjust Screen Brightness #AutoIt3Wrapper_Res_Fileversion=1.0.0.2 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p #AutoIt3Wrapper_Res_LegalCopyright=Copyright 2011 wakillon #AutoIt3Wrapper_Res_SaveSource=y ://////=__= ://////=__= #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ----------------------------------------------------------------------------------------------------------- AutoIt Version : 3.3.6.1 Author       : wakillon                  Based on the noctis Post : <a href='http://autoit.de/index.php?page=Thread&postID=83474#post83474' class='bbc_url' title='External link' rel='nofollow external'>http://autoit.de/index.php?page=Thread&postID=83474#post83474</a> Title : TinyBrightnessControler Script Fonction : Adjust Screen Brightness.                  Left click on Tray Icon for show Controler and Right click for Tray Menu. #ce ----------------------------------------------------------------------------------------------------------- #include <WindowsConstants.au3> #include <GuiSlider.au3> Opt ( "TrayOnEventMode", 1 ) Opt ( "TrayMenuMode", 1 ) OnAutoItExitRegister ( "_Exit" ) Global Const $TRAY_UNCHECKED = 4 Global Const $TRAY_EVENT_PRIMARYDOWN = -7 Global $_Rgb, $_DefaultItem, $_GetPosOld, $_AboutItem, $_TitleItem, $_UpdateItem, $_SaveItem Global $_Gui, $_Slider, $_Label1, $_Label2, $_Dll Global $_Version = _GetScriptVersion ( ) _TrayMenu ( ) $_Rgb = RegRead ( "HKEY_LOCAL_MACHINESoftwareTBC", "Gamma" ) If $_Rgb = '' Then $_Rgb =128 $_GetPosOld=$_Rgb _SetGamma ( $_Rgb, $_Rgb, $_Rgb ) While 1     Sleep ( 10 ) WEnd Func _DisplaySlider ( )     Local $_MousePos = MouseGetPos ( )     Local $_GuiWight= 50, $_GuiHeight=230     Local $_Gui = GUICreate ( "", $_GuiWight, $_GuiHeight, $_MousePos[0]-$_GuiWight/2, @DesktopHeight - $_GuiHeight - _GetTaskbarHeight ( ) -2, _     BitOR ( $WS_POPUP, $WS_BORDER ), $WS_EX_TOPMOST, WinGetHandle ( AutoItWinGetTitle ( ) ) )     $_Label1 = GUICtrlCreateLabel ( "Min", 15, 10 )     $_Slider = GUICtrlCreateSlider ( 15, 30, 20, 180, BitOR ( $TBS_VERT, $TBS_TOOLTIPS, $TBS_AUTOTICKS ) )     GUICtrlSetLimit ( -1, 256, 0 )     $_Label2 = GUICtrlCreateLabel ( "Max", 15, 210 )     GUISetState ( )     _GUICtrlSlider_SetPos ( $_Slider, $_GetPosOld )     $_TimerInit = TimerInit ( )     While 1         $_GetPos = _GUICtrlSlider_GetPos ( $_Slider )         If $_GetPos <> $_GetPosOld Then             $_Rgb = $_GetPos          _SetGamma ( $_Rgb, $_Rgb, $_Rgb )          $_GetPosOld = $_GetPos          $_TimerInit = TimerInit ( )      EndIf      If _IsMouseOverCtrls ( $_Gui ) Then $_TimerInit = TimerInit ( )      $_TimerDiff = Round ( TimerDiff ( $_TimerInit )/ 1000 )      If $_TimerDiff > 2 Then ExitLoop     WEnd     GUIDelete ( ) EndFunc ;==> _DisplaySlider ( ) Func _IsMouseOverCtrls ( $_GuiHwnd, $_Active=0 )     $_CursorInfo = GUIGetCursorInfo ( $_GuiHwnd )     If Not @error Then         Switch $_CursorInfo[4]             Case $_Slider, $_Label1, $_Label2                 Return 1         EndSwitch     EndIf EndFunc ;==> _IsMouseOverCtrls ( ) Func _Normal ( )     TrayItemSetState ( $_DefaultItem, $TRAY_UNCHECKED )     $_Rgb = 128     $_GetPosOld = 128     _SetGamma ( $_Rgb, $_Rgb, $_Rgb ) EndFunc ;==> _Normal ( ) Func _Exit ( )     DllClose ( $_Dll )     Exit EndFunc ;==> _Exit ( ) Func _SetGamma ( $vRed=128, $vGreen=128, $vBlue=128 )     Local $n_ramp, $rVar, $gVar, $bVar, $Ret, $i, $dc     If $vRed < 0 Or $vRed > 386 Then Return -1     If $vGreen < 0 Or $vGreen > 386 Then Return -1     If $vBlue < 0 Or $vBlue > 386 Then Return -1     $dc = DLLCall ( "user32.dll", "int", "GetDC","hwnd", 0 )     $n_ramp = DllStructCreate ( "short[" & ( 256*3 ) & "]" )     For $i = 0 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     $ret = DLLCall ( "gdi32.dll", "int", "SetDeviceGammaRamp", "int", $dc[0], "ptr", DllStructGetPtr ( $n_Ramp ) )     $dc = 0     $n_Ramp = 0 EndFunc ;==> _SetGamma ( ) Func _TrayMenu ( )     $_TempDir = @TempDir & 'TBCskin'     If Not FileExists ( $_TempDir ) Then DirCreate ( $_TempDir )     If Not FileExists ( $_TempDir & 'Electric bulb1.ico' ) Then _     InetGet ( 'http://tinyurl.com/d3srkot', $_TempDir & 'Electric bulb1.ico', 9, 0 )     TraySetToolTip ( $_Version & @CRLF & @CRLF & '* Left click for show Controler' & @CRLF & '* Right click for Tray Menu' & @CRLF )     TraySetIcon ( $_TempDir & 'Electric bulb1.ico' )     TraySetClick ( 16 )     TraySetOnEvent ( $TRAY_EVENT_PRIMARYDOWN, '_DisplaySlider' )     $_TitleItem = TrayCreateItem ( $_Version )     TrayItemSetOnEvent ( -1, '_UnCheck' )     TrayCreateItem ( '' )     $_DefaultItem = TrayCreateItem ( 'Set Brightness To Normal' )     TrayItemSetOnEvent ( -1, '_Normal' )     TrayCreateItem ( '' )     $_UpdateItem = TrayCreateItem ( "See For Update" )     TrayItemSetOnEvent ( -1, '_SeeForUpdate' )     TrayCreateItem ( "" )     $_AboutItem = TrayCreateItem ( "About" )     TrayItemSetOnEvent ( -1, '_About' )     TrayCreateItem ( "" )     $_SaveItem = TrayCreateItem ( "Save Settings" )     TrayItemSetOnEvent ( -1, '_Save' )     TrayCreateItem ( "" )     $_ExitItem = TrayCreateItem ( 'Exit' )     TrayItemSetOnEvent ( -1, '_Exit' )     TraySetState ( 4 ) EndFunc ;==> _TrayMenu ( ) Func _Save ( )     TrayItemSetState ( $_SaveItem , $TRAY_UNCHECKED )     RegWrite ( "HKEY_LOCAL_MACHINESoftwareTBC", "Gamma", "REG_SZ", $_Rgb )     Msgbox ( 262144+4160, "Saved", "Gamma Settings have been saved", 3 ) EndFunc Func _SeeForUpdate ( )     TrayItemSetState ( $_UpdateItem , $TRAY_UNCHECKED )     ShellExecute ( 'http://www.autoitscript.com/forum/topic/127668-tinybrightnesscontroler/' ) EndFunc ;==> _SeeForUpdate ( ) Func _UnCheck ( )     TrayItemSetState ( $_TitleItem , $TRAY_UNCHECKED ) EndFunc ;==> _UnCheck ( ) Func _GetScriptVersion ( )     If Not @Compiled Then         Return StringTrimRight ( @ScriptName, 4 ) & ' © wakillon 2010 - 2011'     Else         Return StringTrimRight ( @ScriptName, 4 ) & ' v' & FileGetVersion ( @ScriptFullPath ) & ' © wakillon 2010 - 2011'     EndIf EndFunc ;==> _GetScriptVersion ( ) Func _About ( )     TrayItemSetState ( $_AboutItem , $TRAY_UNCHECKED )     Msgbox ( 262144+4160, "About : ", $_Version & @CRLF & @CRLF & "April 2011" & @CRLF & @CRLF & "Based on the noctis's Gamma Topic on AutoIt.de" & @CRLF & @CRLF & "wakillon." & @CRLF & " " ) EndFunc ;==> _About ( ) Func _GetTaskbarHeight ( )     $_OptOld = Opt ( "WinTitleMatchMode", 4 )     $_WinPos = WinGetPos ( "classname=Shell_TrayWnd" )     If @error Then Return -1     Opt ( "WinTitleMatchMode", $_OptOld )     Return $_WinPos[3] EndFunc ;==> _GetTaskbarHeight ( )


Scripts and executables with full embeded files are available on GoogleCode, see link in my sig.

Comments are welcome !

All this time spent in front of the screen, remember to protect your eyes ! ;)

Edited by wakillon, 08 October 2012 - 04:42 PM.

       AutoIt Version : 3.3.12.0 / Beta 3.3.13.19 SciTE 3.4.1 OS:WIN7/WIN8.1 CPU:X64 OS:X64








#2 Foxhound

Foxhound

    Wayfarer

  • Active Members
  • Pip
  • 76 posts

Posted 16 April 2011 - 10:12 PM

Nice one Wakil, but question:

Is there any way you could use the DeviceIoControl to set backlight brightness instead of Gamma? I've gotten started on it but I'm having trouble with creating the handle from CreateFile (first parameter).
#include "winapi.au3"   ;CreateFile ;$cHandle = DllCall("User32.dll","HANDLE","CreateFile","str", ;IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS  $DISPLAY_BRIGHTNESS = DllStructCreate("uchar 0x00000003;uchar 50;uchar 10") DllCall("User32.dll","int","DeviceIoControl","HANDLE",$cHandle,"dword","IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS","ptr",DllStructGetPtr($DISPLAY_BRIGHTNESS),"int",500,"int","none","int",0,"int","none","ptr","none")  ConsoleWrite(_WinAPI_GetLastError()&@CRLF)


I'm not so good with DllCall yet :>

Anyway nice script :unsure:

#3 JScript

JScript

    I'm back ... I miss, why not!

  • Active Members
  • PipPipPipPipPipPip
  • 1,230 posts

Posted 16 April 2011 - 11:49 PM

I like it! Very good indeed!
Thanks for sharing...
http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)
Spoiler

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!       


#4 reb

reb

    Prodigy

  • Active Members
  • PipPipPip
  • 154 posts

Posted 17 April 2011 - 02:42 AM

This is really a good script and works well on my win7 64 laptop.

Thanks a lot for sharing with us.

REB
MEASURE TWICE - CUT ONCE

#5 wakillon

wakillon

    Tiny Tools Coder

  • Active Members
  • PipPipPipPipPipPip
  • 2,867 posts

Posted 17 April 2011 - 09:57 AM

Nice one Wakil, but question:

Is there any way you could use the DeviceIoControl to set backlight brightness instead of Gamma? I've gotten started on it but I'm having trouble with creating the handle from CreateFile (first parameter).

#include "winapi.au3"   ;CreateFile ;$cHandle = DllCall("User32.dll","HANDLE","CreateFile","str", ;IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS  $DISPLAY_BRIGHTNESS = DllStructCreate("uchar 0x00000003;uchar 50;uchar 10") DllCall("User32.dll","int","DeviceIoControl","HANDLE",$cHandle,"dword","IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS","ptr",DllStructGetPtr($DISPLAY_BRIGHTNESS),"int",500,"int","none","int",0,"int","none","ptr","none")  ConsoleWrite(_WinAPI_GetLastError()&@CRLF)


I'm not so good with DllCall yet :>

Anyway nice script :unsure:


Thanks !


I have googling a long time for find an "universal" solution for set screen brightness.
I have found autoit examples with device control, or by others way, but a probem was back often : compatibility with OS or driver.
So i reduce my ambitions to gamma settings who is not a really "brightness" settings,
but who can be used by all ! Posted Image

An example with device control found but not working for me :

Say me if you managed to make it work ! Posted Image
					
					

Edited by wakillon, 17 April 2011 - 09:59 AM.

       AutoIt Version : 3.3.12.0 / Beta 3.3.13.19 SciTE 3.4.1 OS:WIN7/WIN8.1 CPU:X64 OS:X64


#6 wakillon

wakillon

    Tiny Tools Coder

  • Active Members
  • PipPipPipPipPipPip
  • 2,867 posts

Posted 17 April 2011 - 10:01 AM

Sorry but i can't edit my AutoIt tags part it return error each time !

@Foxhound

here is the script :

AutoIt         
#include <WinAPI.au3> $tagDISPLAY_BRIGHTNESS = "ubyte ucDisplayPolicy;ubyte ucACBrightness;ubyte ucDCBrightness" Global Const $IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS = Int(0x00230498) Global Const $IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS = Int(0x0023049C) Global Const $IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS = Int(0x00230494) Global Const $hLCD = _WinAPI_CreateFile("\\.\LCD", 3, 2, 7) ConsoleWrite ( "_GetDisplayBrightness() : " & _GetDisplayBrightness() & @Crlf ) ConsoleWrite ( "_GetSupportedBrightness() : " & _GetSupportedBrightness() & @Crlf ) Func _GetDisplayBrightness()     $DISPLAY_BRIGHTNESS = DllStructCreate($tagDISPLAY_BRIGHTNESS)     DllStructSetData($DISPLAY_BRIGHTNESS, "ucDisplayPolicy", 0x1)     DllStructSetData($DISPLAY_BRIGHTNESS, "ucACBrightness", 0x20)     DllStructSetData($DISPLAY_BRIGHTNESS, "ucDCBrightness", 0x20)     $ret = DllCall( _     "kernel32.dll", "int", _     "DeviceIoControl", _     "hwnd", $hLCD, _     "int", $IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS, _     "ptr", 0, _     "int", 0, _     "ptr", DllStructGetPtr($DISPLAY_BRIGHTNESS), _     "int", DllStructGetSize($DISPLAY_BRIGHTNESS), _     "int*", 0, _     "ptr", 0 )     Return SetError(@error, DllStructGetData($DISPLAY_BRIGHTNESS, "ucDCBrightness"), DllStructGetData($DISPLAY_BRIGHTNESS, "ucACBrightness")) EndFunc ;==> _GetDisplayBrightness ( ) Func _GetSupportedBrightness()     $SURPPORTED_BRIGHTNESS = DllStructCreate("ubyte suported[256]")     $ret = DllCall( _     "kernel32.dll", "int", _     "DeviceIoControl", _     "hwnd", $hLCD, _     "int", $IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS, _     "ptr", 0, _     "int", 0, _     "ptr", DllStructGetPtr($SURPPORTED_BRIGHTNESS), _     "int", DllStructGetSize($SURPPORTED_BRIGHTNESS), _     "int*", 0, _     "ptr", 0 )     If $ret[0] = 0 Or $ret[7] = 0 Then Return SetError(@error, 0, 0)     Dim $brightness[$ret[7]]     For $i = 0 To UBound($brightness) - 1         $brightness[$i] = DllStructGetData($SURPPORTED_BRIGHTNESS, "suported", $i + 1)     Next     Return SetError(0, $ret[7], $brightness) EndFunc ;==> _GetSupportedBrightness ( ) Func _SetDisplayBrightness($ac = -1, $dc = -1)     $DISPLAY_BRIGHTNESS = DllStructCreate($tagDISPLAY_BRIGHTNESS)     Local $policy = 0     If $ac > -1 Then         $policy += 1         DllStructSetData($DISPLAY_BRIGHTNESS, "ucACBrightness", $ac)     EndIf     If $dc > -1 Then         $policy += 2         DllStructSetData($DISPLAY_BRIGHTNESS, "ucDCBrightness", $dc)     EndIf     DllStructSetData($DISPLAY_BRIGHTNESS, "ucDisplayPolicy", $policy)     $ret = DllCall( _     "kernel32.dll", "int", _     "DeviceIoControl", _     "hwnd", $hLCD, _     "int", $IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS, _     "ptr", DllStructGetPtr($DISPLAY_BRIGHTNESS), _     "int", DllStructGetSize($DISPLAY_BRIGHTNESS), _     "ptr", 0, _     "int", 0, _     "int*", 0, _     "ptr", 0 )     Return SetError(@error, 0, $ret[0]) EndFunc ;==> _SetDisplayBrightness ( )

Edited by wakillon, 17 April 2011 - 10:07 AM.

       AutoIt Version : 3.3.12.0 / Beta 3.3.13.19 SciTE 3.4.1 OS:WIN7/WIN8.1 CPU:X64 OS:X64


#7 wakillon

wakillon

    Tiny Tools Coder

  • Active Members
  • PipPipPipPipPipPip
  • 2,867 posts

Posted 17 April 2011 - 10:07 AM

I like it! Very good indeed!
Thanks for sharing...




This is really a good script and works well on my win7 64 laptop.

Thanks a lot for sharing with us.

REB


I'm glad you like it !
Thanks to both. Posted Image

       AutoIt Version : 3.3.12.0 / Beta 3.3.13.19 SciTE 3.4.1 OS:WIN7/WIN8.1 CPU:X64 OS:X64


#8 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 17 April 2011 - 12:22 PM

Look nice but there is one suggestion. It would be nice if you kept the proportions of RGB values ​​in the LUT. For examples:

Here is the LUT before using TBC.

Posted Image

After using TBC.

Posted Image

#9 Foxhound

Foxhound

    Wayfarer

  • Active Members
  • Pip
  • 76 posts

Posted 17 April 2011 - 02:03 PM

It worked! But it only to decrease brightness, not increase it. :unsure:

Supported brightness for my laptop says 95, I put 92 for _SetDisplayBrightness() but it decreases the brightness all the way down for some reason

Edited by Foxhound, 17 April 2011 - 02:06 PM.


#10 wakillon

wakillon

    Tiny Tools Coder

  • Active Members
  • PipPipPipPipPipPip
  • 2,867 posts

Posted 17 April 2011 - 02:45 PM

Look nice but there is one suggestion. It would be nice if you kept the proportions of RGB values ​​in the LUT. For examples:



Thanks ! Posted Image
Idea is interesting but i don't find any working function for get gamma settings and proportions !
If you have any suggestion...

Edit : I'm searching for GetDeviceGammaRamp but unsuccessfully.

Edited by wakillon, 17 April 2011 - 03:12 PM.

       AutoIt Version : 3.3.12.0 / Beta 3.3.13.19 SciTE 3.4.1 OS:WIN7/WIN8.1 CPU:X64 OS:X64


#11 wakillon

wakillon

    Tiny Tools Coder

  • Active Members
  • PipPipPipPipPipPip
  • 2,867 posts

Posted 17 April 2011 - 02:46 PM

It worked! But it only to decrease brightness, not increase it. :unsure:

Supported brightness for my laptop says 95, I put 92 for _SetDisplayBrightness() but it decreases the brightness all the way down for some reason


You're lucky !
On what OS are you ?
I'm on xpsp3 and functions return 0 ! Posted Image

       AutoIt Version : 3.3.12.0 / Beta 3.3.13.19 SciTE 3.4.1 OS:WIN7/WIN8.1 CPU:X64 OS:X64


#12 Foxhound

Foxhound

    Wayfarer

  • Active Members
  • Pip
  • 76 posts

Posted 17 April 2011 - 02:56 PM

You're lucky !
On what OS are you ?
I'm on xpsp3 and functions return 0 ! Posted Image



Windows 7 Professional x86 :unsure:

#13 wakillon

wakillon

    Tiny Tools Coder

  • Active Members
  • PipPipPipPipPipPip
  • 2,867 posts

Posted 17 April 2011 - 03:00 PM

Windows 7 Professional x86 :unsure:


So, i was right when i talk about compatibility with OS ! Posted Image
Let me know If you find a multi OS solution !

       AutoIt Version : 3.3.12.0 / Beta 3.3.13.19 SciTE 3.4.1 OS:WIN7/WIN8.1 CPU:X64 OS:X64


#14 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 17 April 2011 - 04:35 PM

Windows 7 Professional x86

Works fine for me under this OS! Note, not all adapters support downloadable gamma ramps in hardware.

I'm searching for GetDeviceGammaRamp but unsuccessfully.

AutoIt         
#Include <Array.au3> #Include <WinAPIEx.au3> Dim $Delta[256][3] $hForm = GUICreate('Lookup Table', 256, 256) $Pic = GUICtrlCreatePic('', 0, 0, 255, 255) $hDC = _WinAPI_GetDC(0) $tRamp = DllStructCreate('ushort[768]') $Ret = DllCall('gdi32.dll', 'int', 'GetDeviceGammaRamp', 'hwnd', $hDC, 'ptr', DllStructGetPtr($tRamp)) $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 256, 256, 0) $hSv1 = _WinAPI_SelectObject($hMemDC, $hBitmap) $hPen = _WinAPI_GetStockObject($DC_PEN) $hSv2 = _WinAPI_SelectObject($hMemDC, $hPen) _WinAPI_SetROP2($hMemDC, $R2_XORPEN) _WinAPI_ReleaseDC(0, $hDC) $Rgb = 0xFF0000 $Count = 1 For $i = 0 To 2     _WinAPI_SetDCPenColor($hMemDC, BitShift($Rgb, 8 * $i))     For $j = 0 To 255         $Delta[$j][$i] = Round(DllStructGetData($tRamp, 1, $Count) - $j / 255 * 65280) ; 65280 ???         If $j Then             _WinAPI_LineTo($hMemDC, $j + 1, Round(255 * (1 - DllStructGetData($tRamp, 1, $Count) / 65280)) - 1)         Else             _WinAPI_MoveTo($hMemDC, 0, Round(255 * (1 - DllStructGetData($tRamp, 1, $Count) / 65280)))         EndIf         $Count += 1     Next Next _WinAPI_SelectObject($hMemDC, $hSv1) _WinAPI_SelectObject($hMemDC, $hSv2) _WinAPI_DeleteObject($hPen) _WinAPI_DeleteDC($hMemDC) GUICtrlSendMsg($Pic, 0x0172, 0, $hBitmap) GUISetState() _ArrayDisplay($Delta) Do Until GUIGetMsg() = -3

Edited by Yashied, 17 April 2011 - 05:02 PM.


#15 wakillon

wakillon

    Tiny Tools Coder

  • Active Members
  • PipPipPipPipPipPip
  • 2,867 posts

Posted 17 April 2011 - 05:00 PM

@Yashield
I have found this one, but doesn't give same results as yours...Posted Image

AutoIt         
#include <Array.au3> $_GetGammaRamp = _GetGammaRamp() _ArrayDisplay ( $_GetGammaRamp ) Func _GetGammaRamp()     Local $dc, $m_RampSaved,$ret,$avDisplay     $dc = DLLCall("user32.dll","int","GetDC","hwnd",0)     $m_RampSaved = DllStructCreate("short[" & (256*3) & "]")     $ret = DLLCall("gdi32.dll","int","GetDeviceGammaRamp", "int",$dc[0],"ptr",DllStructGetPtr($m_RampSaved))     If Not $ret[0] Then MsgBox(4096,"WARNING", "WARNING: Cannot initialize DeviceGammaRamp.")     $avDisplay = _GammaTo2d($m_RampSaved)     $dc = 0     $m_RampSaved = 0     Return $avDisplay EndFunc ;==> _GetGammaRamp() Func _GammaTo2d($vm_RampSaved)     Local $avDisplay[257][3]     For $i = 0 to 256         $avDisplay[$i][0] = DllStructGetData($vm_RampSaved,1,$i)         $avDisplay[$i][1] = DllStructGetData($vm_RampSaved,1,$i + 256)         $avDisplay[$i][2] = DllStructGetData($vm_RampSaved,1,$i + 512)     Next     Return $avDisplay EndFunc ;==> _GammaTo2d()

       AutoIt Version : 3.3.12.0 / Beta 3.3.13.19 SciTE 3.4.1 OS:WIN7/WIN8.1 CPU:X64 OS:X64


#16 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 17 April 2011 - 05:11 PM

Not all direct color video boards support loadable gamma ramps.

What gives the following code?

#Include <WinAPI.au3> $hDC = _WinAPI_GetDC(0) $tRamp = DllStructCreate('ushort[768]') $Ret = DllCall('gdi32.dll', 'int', 'GetDeviceGammaRamp', 'hwnd', $hDC, 'ptr', DllStructGetPtr($tRamp)) If (@error) Or (Not $Ret[0]) Then     MsgBox(16, @error, _WinAPI_GetLastErrorMessage()) Else     MsgBox(0, '', 'OK') EndIf _WinAPI_ReleaseDC(0, $hDC)

Edit:

Func _GammaTo2d($vm_RampSaved)     Local $avDisplay[256][3]     For $i = 0 To 255         $avDisplay[$i][0] = DllStructGetData($vm_RampSaved, 1, $i + 1)         $avDisplay[$i][1] = DllStructGetData($vm_RampSaved, 1, $i + 1 + 256)         $avDisplay[$i][2] = DllStructGetData($vm_RampSaved, 1, $i + 1 + 512)     Next     Return $avDisplay EndFunc   ;==>_GammaTo2d

Edited by Yashied, 17 April 2011 - 05:19 PM.


#17 wakillon

wakillon

    Tiny Tools Coder

  • Active Members
  • PipPipPipPipPipPip
  • 2,867 posts

Posted 17 April 2011 - 05:23 PM

What gives the following code?


It gives Ok

Edit : And your function ( #post 14 ) give an array with only 256 in all the array.

Edited by wakillon, 17 April 2011 - 05:27 PM.

       AutoIt Version : 3.3.12.0 / Beta 3.3.13.19 SciTE 3.4.1 OS:WIN7/WIN8.1 CPU:X64 OS:X64


#18 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 17 April 2011 - 05:26 PM

It gives Ok

Then structure was filled successfully.

:unsure:

#19 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 18 April 2011 - 06:59 AM

Maximum value for each color is 65280 instead of 65535. Why? Maximum number of 8-bit number is 0xFF (255). Maximum number of gradations for each channel is 256.

255 * 256 = 65280

#20 tonycst

tonycst

    Adventurer

  • Active Members
  • PipPip
  • 141 posts

Posted 11 October 2013 - 01:55 AM

Its not working right. It does not brighten the screen or dim it out. It makes it brightening colors, not increasing/decreasing output power.

As cool as it is, its not doing what it suppose to do.

Still have to go to power options and adjust it from there.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users