<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Изменение яркости экрана]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=13568&amp;type=atom" />
	<updated>2018-03-27T16:40:02Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=13568</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Изменение яркости экрана]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124283#p124283" />
			<content type="html"><![CDATA[<p>Больше ничего нельзя сделать?</p>]]></content>
			<author>
				<name><![CDATA[Kurskador]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=33207</uri>
			</author>
			<updated>2018-03-27T16:40:02Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124283#p124283</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Изменение яркости экрана]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124234#p124234" />
			<content type="html"><![CDATA[<p>Работает он только в Windows, а в игре - нет. Всё как с первым кодом из первого поста.</p>]]></content>
			<author>
				<name><![CDATA[Kurskador]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=33207</uri>
			</author>
			<updated>2018-03-25T14:37:16Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124234#p124234</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Изменение яркости экрана]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124225#p124225" />
			<content type="html"><![CDATA[<p>Не срабатывает последний код. Ни в Windows, ни в игре.<br />Может nircmd.exe, какая-то особая нужна?<br />У меня 281.2.2.6.</p>]]></content>
			<author>
				<name><![CDATA[Kurskador]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=33207</uri>
			</author>
			<updated>2018-03-24T21:25:48Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124225#p124225</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Изменение яркости экрана]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124215#p124215" />
			<content type="html"><![CDATA[<p>В вашем первом примере меняется все же гамма, а не яркость.<br /></p><div class="codebox"><pre><code>F1::MoveBrightness(1)
F2::MoveBrightness(-1)

;############################################################################
; Functions
;############################################################################

MoveBrightness(IndexMove) {

	VarSetCapacity(SupportedBrightness, 256, 0)
	VarSetCapacity(SupportedBrightnessSize, 4, 0)
	VarSetCapacity(BrightnessSize, 4, 0)
	VarSetCapacity(Brightness, 3, 0)

	hLCD := DllCall(&quot;CreateFile&quot;
	, Str, &quot;\\.\LCD&quot;
	, UInt, 0x80000000 | 0x40000000 ;Read | Write
	, UInt, 0x1 | 0x2  ; File Read | File Write
	, UInt, 0
	, UInt, 0x3  ; open any existing file
	, UInt, 0
	  , UInt, 0)

	if hLCD != -1
	{

		DevVideo := 0x00000023, BuffMethod := 0, Fileacces := 0
		  NumPut(0x03, Brightness, 0, &quot;UChar&quot;)   ; 0x01 = Set AC, 0x02 = Set DC, 0x03 = Set both
		  NumPut(0x00, Brightness, 1, &quot;UChar&quot;)      ; The AC brightness level
		  NumPut(0x00, Brightness, 2, &quot;UChar&quot;)      ; The DC brightness level
		DllCall(&quot;DeviceIoControl&quot;
		  , UInt, hLCD
		  , UInt, (DevVideo&lt;&lt;16 | 0x126&lt;&lt;2 | BuffMethod&lt;&lt;14 | Fileacces) ; IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS
		  , UInt, 0
		  , UInt, 0
		  , UInt, &amp;Brightness
		  , UInt, 3
		  , UInt, &amp;BrightnessSize
		  , UInt, 0)

		DllCall(&quot;DeviceIoControl&quot;
		  , UInt, hLCD
		  , UInt, (DevVideo&lt;&lt;16 | 0x125&lt;&lt;2 | BuffMethod&lt;&lt;14 | Fileacces) ; IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS
		  , UInt, 0
		  , UInt, 0
		  , UInt, &amp;SupportedBrightness
		  , UInt, 256
		  , UInt, &amp;SupportedBrightnessSize
		  , UInt, 0)

		ACBrightness := NumGet(Brightness, 1, &quot;UChar&quot;)
		ACIndex := 0
		DCBrightness := NumGet(Brightness, 2, &quot;UChar&quot;)
		DCIndex := 0
		BufferSize := NumGet(SupportedBrightnessSize, 0, &quot;UInt&quot;)
		MaxIndex := BufferSize-1

		Loop, %BufferSize%
		{
		ThisIndex := A_Index-1
		ThisBrightness := NumGet(SupportedBrightness, ThisIndex, &quot;UChar&quot;)
		if ACBrightness = %ThisBrightness%
			ACIndex := ThisIndex
		if DCBrightness = %ThisBrightness%
			DCIndex := ThisIndex
		}

		if DCIndex &gt;= %ACIndex%
		  BrightnessIndex := DCIndex
		else
		  BrightnessIndex := ACIndex

		BrightnessIndex += IndexMove

		if BrightnessIndex &gt; %MaxIndex%
		   BrightnessIndex := MaxIndex

		if BrightnessIndex &lt; 0
		   BrightnessIndex := 0

		NewBrightness := NumGet(SupportedBrightness, BrightnessIndex, &quot;UChar&quot;)

		NumPut(0x03, Brightness, 0, &quot;UChar&quot;)   ; 0x01 = Set AC, 0x02 = Set DC, 0x03 = Set both
        NumPut(NewBrightness, Brightness, 1, &quot;UChar&quot;)      ; The AC brightness level
        NumPut(NewBrightness, Brightness, 2, &quot;UChar&quot;)      ; The DC brightness level

		DllCall(&quot;DeviceIoControl&quot;
			, UInt, hLCD
			, UInt, (DevVideo&lt;&lt;16 | 0x127&lt;&lt;2 | BuffMethod&lt;&lt;14 | Fileacces) ; IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS
			, UInt, &amp;Brightness
			, UInt, 3
			, UInt, 0
			, UInt, 0
			, UInt, 0
			, Uint, 0)

		DllCall(&quot;CloseHandle&quot;, UInt, hLCD)
	}
}</code></pre></div><div class="codebox"><pre><code>F1::Run C:\nircmd.exe changebrightness 10
F2::Run C:\nircmd.exe changebrightness -10</code></pre></div>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2018-03-23T23:22:34Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124215#p124215</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Изменение яркости экрана]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124212#p124212" />
			<content type="html"><![CDATA[<p>Хотел для игры приспособить код из аналогичной темы в &quot;идеях&quot;: <a href="http://forum.script-coding.com/viewtopic.php?pid=32379#p32379">http://forum.script-coding.com/viewtopi … 379#p32379</a>, но ничего не получилось.<br />Вот это прекрасно работает в самой Windows, но в игре не срабатывает.<br /></p><div class="codebox"><pre><code>#NoTrayIcon ; не отображать иконку скрипта в трее
#MaxHotkeysPerInterval 200
#NoEnv  ; Не использовать переменные окружения
#SingleInstance force
SetBatchLines -1

br := 128   ; Яркость в интервале от 0 до 255 (нормальное значение яркости 128)

#F2:: ; увеличить яркость Win + F2
#F1:: ; уменьшить яркость Win + F1

Brght_Step = 8 ; шаг регулировки

; -------------------
; НАЧАЛО КОНФИГУРАЦИИ
; -------------------

; Как долго отображать прогресс-бар (в миллисекундах)
vol_DisplayTime = 1500
; Прозрачность окна (0-255)
vol_TransValue = 200
; Цвет бэкграунда окна
vol_CW = EEEEEE   
vol_Width = 200  ; ширина прогресс-бара
vol_Thick = 20   ; высота прогресс-бара
; Позиция бара
vol_PosX := A_ScreenWidth/2 - vol_Width/2
vol_PosY := A_ScreenHeight/1.8 - vol_Thick/2
; --------------------
; КОНЕЦ КОНФИГУРАЦИИ
; --------------------
vol_BarOptionsMaster = 1:B1 R0-255 ZH%vol_Thick% ZX8 ZY4 W%vol_Width% X%vol_PosX% Y%vol_PosY% CW%vol_CW%


br += (InStr(A_ThisHotkey, &quot;F1&quot;) ? -Brght_Step : Brght_Step )
If ( br &gt; 256 )
   br := 256
If ( br &lt; 0)
   br := 0
VarSetCapacity(gr, 512*3)
Loop,   256
{
   If  (nValue:=(br+128)*(A_Index-1))&gt;65535
        nValue:=65535
   NumPut(nValue, gr,      2*(A_Index-1), &quot;Ushort&quot;)
   NumPut(nValue, gr,  512+2*(A_Index-1), &quot;Ushort&quot;)
   NumPut(nValue, gr, 1024+2*(A_Index-1), &quot;Ushort&quot;)
}
hDC := DllCall(&quot;GetDC&quot;, &quot;Uint&quot;, 0)
DllCall(&quot;SetDeviceGammaRamp&quot;, &quot;Uint&quot;, hDC, &quot;Uint&quot;, &amp;gr)
DllCall(&quot;ReleaseDC&quot;, &quot;Uint&quot;, 0, &quot;Uint&quot;, hDC)


vol_ShowBars:
; Получаем значение яркости, т.к. пользователь или другие программы могли ее изменить
vol_Master := br
if vol_Master &lt;&gt; 128
{
  vol_Colour = Blue   
  vol_Text = Brightness
}
else
{
;  vol_Colour = Red
  vol_Text = Brightness (normal)

}


; Что бы избежать мигания окна, создаем окно только в том случае, если оно не существует
IfWinNotExist, BrightnessOSDxyz
{
    Progress, %vol_BarOptionsMaster%  CB%vol_Colour% CT%vol_Colour%, , %vol_Text%, BrightnessOSDxyz
    WinSet, Transparent, %vol_TransValue%, BrightnessOSDxyz
}

Progress, 1:%vol_Master% , , %vol_Text%
SetTimer, vol_BarOff, %vol_DisplayTime%
return


vol_BarOff:
SetTimer, vol_BarOff, off
Progress, 1:Off
return</code></pre></div><p>А тот код, что там ниже для Nvidia, c обращением к rundll32.exe, вообще срабатывает странно. С гаммой запускается, но никакого эффекта не производит, а с контрастностью и яркостью даже не запускается даже вот так:<br /></p><div class="codebox"><pre><code>^F12::
rundll32.exe NvCpl.dll,dtcfg setbrightness 1 all 0
Return</code></pre></div><div class="quotebox"><blockquote><p>==&gt; This line does not contain a recognized action.<br />&nbsp; &nbsp; &nbsp;Specifically: rundll32.exe NvCpl.dll,dtcfg setbrightness 1 all 0</p></blockquote></div><p>Что я не так делаю?</p>]]></content>
			<author>
				<name><![CDATA[Kurskador]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=33207</uri>
			</author>
			<updated>2018-03-23T20:42:12Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124212#p124212</id>
		</entry>
</feed>
