Brightness and Temperature Fast Control

Post your working scripts, libraries and tools for AHK v1.1 and older
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Brightness and Temperature Fast Control

Post by hasantr » 18 Dec 2019, 16:23

It aims to make the computer's screen brightness as easy as a smartphone's.
Developed with AutoHotkey. The brightness class of Jinzime is based on its foundation.
It was developed by hasantr using many functions belonging to the AHK community.
Control brightness and sound
from screen corners with the mouse wheel.

________________________
|Brightnes ...:..Temperature| <----------- screen top
|............................... |
|............................... |
|.........monitor..........|
|............................... |
|............................... |
|_____Sound Control_____|<----------- screen bottom
............./...\
.........../_____\
  • Controls the brightness level when you move the mouse cursor to the upper left half of the screen and start turning the wheel.
  • Controls the color temperature level when you move the mouse cursor to the upper right half of the screen and start turning the wheel.
  • Controls the volume when you move the mouse cursor to the bottom edge of the screen and start turning the wheel.
  • Turns on/off the volume when the middle mouse button is clicked on the Status Bar.
  • The application interface comes with one click on the icon in the notification area.
  • Edge controls can be disabled from the interface.
[/list]

brightnestemprature.png
brightnestemprature.png (13.92 KiB) Viewed 6762 times
photo_2019-12-18_21-40-54.jpg
photo_2019-12-18_21-40-54.jpg (21.91 KiB) Viewed 6924 times

Downloads Script And Exe:
https://github.com/hasantr/WinM


Sorry about the spaghetti codes. :)

Code: Select all

; GLOBAL SETTINGS ===============================================================================================================
Menu, Tray, NoStandard

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance Force
#Persistent

CoordMode, Mouse, Screen
SetBatchLines -1


RegRead, FirstStartVal,HKEY_CURRENT_USER\SOFTWARE\WinM,FirstStart
if FirstStartVal != 1
{	
	GuiGoster := 1
	RegWrite, REG_SZ, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run,BrightTempAutoStart,%A_ScriptFullPath% /systemStartup
	RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, Temperature, 6400
	RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, Brightness, 50
	RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, MouseControl, 1
	RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, FirstStart, 1
	RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, TryNotifyIcon, 1
	RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, ShiftAndWheel, 0
}

RegRead, AutoStart, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run,BrightTempAutoStart
RegRead, Bright,HKEY_CURRENT_USER\SOFTWARE\WinM,Brightness
RegRead, Temp,HKEY_CURRENT_USER\SOFTWARE\WinM,Temperature
RegRead, CheckStatus,HKEY_CURRENT_USER\SOFTWARE\WinM,MouseControl
RegRead, TryNotifyIconStat,HKEY_CURRENT_USER\SOFTWARE\WinM,TryNotifyIcon
RegRead, ShiftAndWheelOption,HKEY_CURRENT_USER\SOFTWARE\WinM,ShiftAndWheel
Monitor.SetColorTemperature(Temp, Bright / 100)
if(TryNotifyIconStat != 1)
	Menu, Tray, NoIcon

Menu Tray, Add, &Save Settings, RegistrySave
Menu Tray, Icon, &Save Settings, shell32.dll, 259
Menu Tray, Add, Hotkeys..., HotkeysGui
Menu Tray, Icon, Hotkeys..., shell32.dll, 166


Menu FileMenu, Add, &Save Settings, RegistrySave
Menu FileMenu, Icon, &Save Settings, shell32.dll, 259
Menu FileMenu, Add, &Exit, ExitAll
Menu FileMenu, Icon, &Exit, shell32.dll,28
Menu MenuBar, Add, &File, :FileMenu
Menu MenuBar, Icon, &File, shell32.dll,5

Menu Heys, Add, &Hotkeys, HotkeysGui
Menu Heys, Icon, &Hotkeys, shell32.dll,174
Menu MenuBar, Add, &Hotkeys, :Heys
Menu MenuBar, Icon, &Hotkeys, shell32.dll,174

Menu AboutMenu, Add, &Help`tF1, Help
Menu AboutMenu, Icon, &Help`tF1, shell32.dll, 24
Menu AboutMenu, Add, &About, About
Menu AboutMenu, Icon, &About, shell32.dll, 278
Menu MenuBar, Add, &Help, :AboutMenu
Menu MenuBar, Icon, &Help, shell32.dll, 24
Gui Menu, MenuBar



Gui +hWndhMainWnd
Gui Color, 0xFEFFDD
Gui Add, Slider, x16 y61 w321 h44  Line2 Page5 TickInterval3 Range0-100 Thick30 +Center +0x20 Tooltip vVBright  gGBright AltSubmit, % Bright
Gui Add, Slider, x16 y184 w321 h43 Line2 Page100 TickInterval180 Range600-5600 Thick30 +Center +0x20 +Tooltip vVTemp  gGTemp AltSubmit, % Temp
Gui Add, CheckBox, x8 y248  h16 gGChecked vVChecked, Control of the edges of the screen.
Gui Add, CheckBox, x200 y248  h16 gGShiftWheel vVShiftWheel,With Shift + Wheel control.
Gui Add, CheckBox, x200 y270  h16 gGTRYMenuShow vVTRYMenuShow, Show notification area.
Gui Add, CheckBox, x8 y270  h16 vVAutoStart gGAutoStart, Start at the start of the system.
GuiControl,,VChecked,% CheckStatus
GuiControl,,VTRYMenuShow,% TryNotifyIconStat
StartupAdress := A_ScriptFullPath . " /systemStartup"
if(AutoStart == StartupAdress) ;"\autostart" registry parameters (detect system startup)
	GuiControl,,VAutoStart, 1
else
	GuiControl,,VAutoStart,0
if(ShiftAndWheelOption == 1)
	GuiControl,,VShiftWheel,1


Gui Font, s13 ;c0xFBFBFB
Gui Add, Text, x172 y32 w59 h23 +0x200 vVBRtext, % Bright
Gui Add, Text, x162 y152 w60 h23 +0x200 vVTPtext, % Temp
Gui Font
Gui Add, GroupBox, x8 y8 w335 h107, Brightness:
Gui Add, GroupBox, x8 y128 w336 h108, Temperature:
Gui Add, Button, x290 y290 w50 h26 gSifirla, Reset

if GuiGoster == 1
	Gui Show, w350 h320, Brightness and Temperature Control

start = %1%
if(start == "") ;if it did not start with windows startup. show gui.
	Gui Show, w350 h320, Brightness and Temperature Control


TrayMinimizer.Init(false)	; <-- Initializes and optionally minimizes

;#Include %A_ScriptDir% \"Bright Temp HotkeyGui.ahk"
;#Include Bright Temp HotkeyGui.ahk


;##################### HOTKEY GUI ############################################
;##################### HOTKEY GUI ############################################
Loop,7
	{
		RegRead, CHstat%A_index%,HKEY_CURRENT_USER\SOFTWARE\WinM,CHKey%A_Index%
		RegRead, HK%A_index%,HKEY_CURRENT_USER\SOFTWARE\WinM,HKey%A_Index%
		
		if(HK%A_index% != "")
			if(CHstat%A_index% == "+Checked")
				Hotkey,  % "#" HK%A_index% , HKg%A_index%
		Else
			Hotkey, % HK%A_index%, HKg%A_index%
	}	
Gui HK:Add, Hotkey, x16 y64 w120 h21 vHK1 , %HK1%
Gui HK:Add, Hotkey, x192 y64 w120 h21 vHK2 , %HK2%
Gui HK:Add, Hotkey, x16 y136 w120 h21 vHK3 , %HK3%
Gui HK:Add, Hotkey, x193 y136 w120 h21 vHK4, %HK4%
Gui HK:Add, Hotkey, x16 y240 w120 h21 vHK5, %HK5%
Gui HK:Add, Hotkey, x192 y240 w120 h21 vHK6, %HK6%
Gui HK:Add, Hotkey, x16 y320 w120 h21 vHK7, %HK7%
Gui HK:Add, GroupBox, x205 y112 w0 h0, GroupBox
Gui HK:Add, GroupBox, x8 y8 w360 h162, Brightness and Temperature Hotkeys
Gui HK:Add, GroupBox, x8 y184 w359 h172, Sound Hotkeys

Gui HK:Add, CheckBox, x144 y62  w36 h23 %CHstat1% vCHX1 , Win
Gui HK:Add, CheckBox, x320 y62  w36 h23 %CHstat2% vCHX2 , Win
Gui HK:Add, CheckBox, x144 y134 w36 h23 %CHstat3% vCHX3 , Win
Gui HK:Add, CheckBox, x320 y134 w36 h23 %CHstat4% vCHX4 , Win
Gui HK:Add, CheckBox, x144 y238 w36 h23 %CHstat5% vCHX5 , Win
Gui HK:Add, CheckBox, x320 y238 w36 h23 %CHstat6% vCHX6 , Win
Gui HK:Add, CheckBox, x144 y318 w36 h23 %CHstat7% vCHX7 , Win 
Gui HK:Add, Button, x288 y360 w80 h23 gBtnSave, Save
Gui HK:Add, Text, x16 y32 w120 h23 +0x200, Brightness Increasing:
Gui HK:Add, Text, x193 y32 w120 h23 +0x200, Brightness Decreasing:
Gui HK:Add, Text, x16 y104 w120 h23 +0x200, Temperature Increasing:
Gui HK:Add, Text, x193 y104 w125 h23 +0x200, Temperature Decreasing:
Gui HK:Add, Text, x16 y208 w120 h23 +0x200, Sound Increasing:
Gui HK:Add, Text, x16 y288 w120 h23 +0x200, Sound On/Off Switch:
Gui HK:Add, Text, x192 y208 w120 h23 +0x200, Sound Decreasing
return
keydown:
ToolTip, %A_ThisHotkey% was pressed
Return
GuiHKEscape:
GuiHKClose:
ExitApp
BtnSave:
Loop,7
{
	GuiControlGet,HKval%A_index%,HK:,HK%A_Index% 
	RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, HKey%A_Index%, % HKval%A_index%
	
	GuiControlGet,CHKey%A_index%,HK:,CHX%A_Index% 
	if (CHKey%A_index% == 1)
		RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, CHKey%A_Index%, +Checked
	else
		RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, CHKey%A_Index%, 0
}
Reload
return
HKg1:
BR := 5
Gosub,SetBRandTP
return
HKg2:
BR := -5
Gosub,SetBRandTP
return
HKg3:
TP := 100
Gosub,SetBRandTP
return
HKg4:
TP := -100
Gosub,SetBRandTP
return
HKg5:
Send,{Volume_Up}
SoundGet, master_volume
ToolTip("Ses: "  Round(master_volume) , , , 1, 2000)
return
return
HKg6:
Send,{Volume_Down}
SoundGet, master_volume
ToolTip("Ses: "  Round(master_volume) , , , 1, 2000)
return
return
HKg7:
if(MouseIsOVer("ahk_class Shell_TrayWnd") != "0x0")
	Send,{Volume_Mute}
;##################### HOTKEY GUI ############################################
;##################### HOTKEY GUI ############################################

Return




;--- Hotkey to slow the mouse movement upon pressing XButton2 ---
XButton2::
SlowMouse(1,VBright)
SlowMouse(1,VTemp)
KeyWait XButton2
SlowMouse(0,0)
return

SlowMouse(a,s){
	Static OrigMouseSpeed := 10, CurrentMouseSpeed := DllCall("SystemParametersInfo", UInt, 0x70, UInt, 0, UIntP, OrigMouseSpeed, UInt, 0)
	DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, Ptr, a ? (s>0 AND s<=20 ? s : 10) : OrigMouseSpeed, UInt, 0)
}

HotkeysGui:
Gui HK:Show, w374 h390, Hotkeys Panel
return

GAutoStart:
GuiControlGet,AutoStartChcx,,VAutoStart
if(AutoStartChcx == 1)
	RegWrite, REG_SZ, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run,BrightTempAutoStart,%A_ScriptFullPath% /systemStartup
else
	RegDelete,  HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run,BrightTempAutoStart
return

About:
MsgBox,64,İnfo,
(
It aims to make the computer's screen brightness as easy as a smartphone's.

Developed with AutoHotkey. The brightness class of Jinzime is based on its foundation.

It was developed by hasantr using many functions belonging to the AHK community.

For information and advice: [email protected]
)
return

Help:
MsgBox,64,Help,
(
                                                      
Control brightness and sound
from screen corners with the mouse wheel.                                                 
 _________________________    
|.Brightnes : Temperature.| 
|..........................................| 
|..........................................|
|..........................................|
|..........................................| 
|..........................................| 
|_____Sound Control_____|       
..................../     \          
................./_______\         
                           
                                                      
 Controls the brightness level when you move the mouse cursor to the upper left half of the screen and start turning the wheel.                                                     
                                                      
 Controls the color temperature level when you move the mouse cursor to the upper right half of the screen and start turning the wheel.                                                     
                                                      
 Controls the volume when you move the mouse cursor to the bottom edge of the screen and start turning the wheel.                                                     
                                                      
 Turns on/off the volume when the middle mouse button is clicked on the Status Bar.                                                     
                                                      
 The application interface comes with one click on the icon in the notification area.                                                     

 Edge controls can be disabled from the interface.
                                                         
)
return

GBright:
GuiControlGet,Bright,,VBright,
GuiControl,,VBRtext,% Bright
RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, Brightness, % Bright
RegRead, Temp,HKEY_CURRENT_USER\SOFTWARE\WinM,Temperature
Monitor.SetColorTemperature(Temp, Bright / 100)
return

GTemp:
GuiControlGet,Temp,,VTemp,
GuiControl,,VTPtext,% Temp
RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, Temperature, % Temp
RegRead, Bright,HKEY_CURRENT_USER\SOFTWARE\WinM,Brightness
if Bright < 3
	Bright := 3
Monitor.SetColorTemperature(Temp, Bright / 100)
return

Sifirla:
Monitor.SetBrightness(128, 128, 128)
GuiControl,,VTPtext,6400
GuiControl,,VBRtext,50
GuiControl,,VBright,50
GuiControl,,VTemp,6400
RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, Temperature, 6400
RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, Brightness, 50
return


GChecked:
GuiControlGet,CheckStatus,,VChecked
RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, MouseControl, % CheckStatus
return

GShiftWheel:
GuiControlGet,guiShiftAndWheel,,VShiftWheel
RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, ShiftAndWheel, % guiShiftAndWheel
ShiftAndWheelOption := guiShiftAndWheel
return


GTRYMenuShow:
;RegRead, TryNotifyIconStat,HKEY_CURRENT_USER\SOFTWARE\WinM,TryNotifyIcon
GuiControlGet,ChckBoxStatus,,VTRYMenuShow
if(ChckBoxStatus == 1)
	Menu, Tray, NoIcon
else
	Menu, Tray, Icon
RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, TryNotifyIcon, % ChckBoxStatus
return
 ;*[Bright Temp]

RegistrySave:
RegistrySave := "Windows Registry Editor Version 5.00" "`r `n" "`r `n" "[HKEY_CURRENT_USER\Software\WinM]" "`r `n"
Loop, Reg, HKEY_CURRENT_USER\Software\WinM
{
	if (A_LoopRegType = "key")
		value := ""
	else
	{
		RegRead, value
		if ErrorLevel
			value := "*error*"	
	}
	RegistrySave :=  RegistrySave """" A_LoopRegName """=" """" value """" . "`r `n"
	
}
FileSelectFile, SavePathSelect, S8, , Save Settings Registry ,Registry File (*.reg)

if (SavePathSelect != "")
	FileAppend,%RegistrySave%,%SavePathSelect%.reg

return




GuiEscape:
GuiClose:
TrayMinimizer.Minimize()
return

ExitAll:
ExitApp
return

; SCRIPT ========================================================================================================================
;#Numpad1::Monitor.SetBrightness(100, 100, 100)
#if CheckStatus = 1

	;Başlat Çubuğu üzernde orta tuşla tekerlekle ses kontrolü
MouseIsOver(WinTitle) 
{
	MouseGetPos,,, Win
	return WinExist(WinTitle . " ahk_id " . Win)
}
#if ShiftAndWheelOption = 1
~+MButton::
#if ShiftAndWheelOption = 0
~MButton::

if(MouseIsOVer("ahk_class Shell_TrayWnd") != "0x0")
	Send,{Volume_Mute}
return

#if ShiftAndWheelOption = 1
+WheelDown::
#if ShiftAndWheelOption = 0
WheelDown::
MouseGetPos,XX,YY
if(YY >= A_ScreenHeight - 2){
	Send,{Volume_Down}
	SoundGet, master_volume
	ToolTip("Ses: "  Round(master_volume) , , , 1, 2000)
	return
}

if (YY <= 3) && (XX <= A_ScreenWidth / 2)
	BR := -5
if (YY <= 3) && (XX >= A_ScreenWidth / 2)
	TP -= 100
if (YY <= 3)
	Gosub,SetBRandTP
else
	SendInput,{WheelDown}
return
#if ShiftAndWheelOption = 1
+WheelUp::
#if ShiftAndWheelOption = 0
WheelUp::
MouseGetPos,XX,YY
if(YY >= A_ScreenHeight - 2){
	Send,{Volume_Up}
	SoundGet, master_volume
	ToolTip("Sound: "  Round(master_volume) , , , 1, 2000)
	return
}

if (YY <= 3) && (XX <= A_ScreenWidth / 2)
	BR := 5
if (YY <= 3) && (XX >= A_ScreenWidth / 2)
	TP = 100
if (YY <= 3)
	Gosub,SetBRandTP
else
	SendInput,{WheelUp}
return

SetBRandTP:
RegRead, Bright,HKEY_CURRENT_USER\SOFTWARE\WinM,Brightness
RegRead, Temp,HKEY_CURRENT_USER\SOFTWARE\WinM,Temperature
if (Bright <= 99 && BR == 5 ) || (Bright >= 1 && BR == -5)
	Bright += BR
if (Temp <= 6501 && TP == 100) || (Temp >= 601 && TP == -100)
	Temp += TP



if Temp < 600
	Temp := 600

RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, Brightness, % Bright
RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\WinM, Temperature, % Temp

if Bright < 1 
	Bright := 3
Monitor.SetColorTemperature(Temp, Bright / 100)
BR := 0 , TP := 0
ToolTip("Brightness: "  Bright " Temperature: "  Temp , , , 1, 1500)


GuiControl,,VTPtext,% Temp
GuiControl,,VBRtext,% Bright
GuiControl,,VBright, % Bright
GuiControl,,VTemp, % Temp
return

#if


; Win + Numpad Div (/)    -> Get Brightness
;#NumpadDiv::
;GetBrightness := Monitor.GetBrightness()
;MsgBox % "Red:`t" GetBrightness.Red "`nGreen:`t" GetBrightness.Green "`nBlue:`t" GetBrightness.Blue
;return


; INCLUDES ======================================================================================================================

;#Include Class_Monitor.ahk

; ===============================================================================================================================



ToolTip(Text := "", X := "", Y := "", WhichToolTip := 1, Timeout := "") {
	ToolTip, % Text, X, Y, WhichToolTip	
	If (Timeout) {
		RemoveToolTip := Func("ToolTip").Bind(,,, WhichToolTip)
		SetTimer, % RemoveToolTip, % -Timeout
	}
}



; ===============================================================================================================================

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)
		MsgBox % 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)
	}
}

; ===============================================================================================================================



; Tray Minimizer class by evilC
; Based on Skan's MinimizeToTray

; Include this file, then call TrayMinimizer.Init()
; By default, will minimize Gui on start
; To disable, initialize with TrayMinimizer.Init(false)
class TrayMinimizer {
	Init(minimizeOnStart := true){
		; Store the HWND of the main Gui
		Gui, +HwndhGui
		this.hGui := hGui
		; Create a BoundFunc for the Minimize handler
		this.MinimizeFn := this.Minimize.Bind(this)
		; Build tray menu
		this.Menu("Tray","Nostandard")
		this.Menu("Tray","Add","Restore", this.GuiShow.Bind(this))
		this.Menu("Tray","Add")
		this.Menu("Tray","Default","Restore")
		this.Menu("Tray","Click",1)
		this.Menu("Tray","Standard")
		; Listen to messages to detect minimize click
		OnMessage(0x112, this.WM_SYSCOMMAND.Bind(this))
		if (minimizeOnStart){
			this.Minimize()
		}
	}
	
	; Detects click of Minimize button
	WM_SYSCOMMAND(wParam){
		If ( wParam == 61472 ) {
			fn := this.MinimizeFn
			; Async fire off the minimze function
			SetTimer, % fn, -1
			; Swallow this message (Stop window from doing normal minimze)
			Return 0
		}
	}
	
	; Handles transition from tray minimized to restored
	GuiShow(){
		; Remove tray icon - ToDo: should we not leave this?
		this.Menu("Tray","NoIcon")
		Gui, Show
	}
	
	; Minimizes to tray
	Minimize() {
		WinHide, % "ahk_id " this.hGui
		this.Menu("Tray","Icon")
	}
	
	; Function wrapper for menu command
	Menu( MenuName, Cmd, P3 := "", P4 := "", P5 := "" ) {
		Menu, % MenuName, % Cmd, % P3, % P4, % P5
		Return errorLevel
	}
}
Last edited by hasantr on 23 Apr 2020, 08:46, edited 5 times in total.
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Brightness and Temperature Fast Control

Post by hasantr » 22 Dec 2019, 06:19

Digitally signed x68 and x86 versions.
I hope will be useful.
Attachments
Bright Temp x86.zip
(425.19 KiB) Downloaded 261 times
Bright Temp x64.zip
(565.8 KiB) Downloaded 346 times
Lisa19
Posts: 48
Joined: 07 Apr 2019, 22:25

Re: Brightness and Temperature Fast Control

Post by Lisa19 » 16 Mar 2020, 02:28

Awesome! Thank you!

How to tweak the ahk code above to make it even darker? (Completely dark to make it simple)

(I'm currently using dimmer.exe but I would like to use your app instead. Dimmer has only 1 single "opacity" cursor, I'm using an ahk code to move it either at 50% or 100%. The gamma of my monitor is set to 30 by default (otherwise it's too clear), so sometime I need to manually move the alpha to 80 playing with the screen button).
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Brightness and Temperature Fast Control

Post by hasantr » 17 Apr 2020, 19:23

Lisa19 wrote:
16 Mar 2020, 02:28
Awesome! Thank you!

How to tweak the ahk code above to make it even darker? (Completely dark to make it simple)

(I'm currently using dimmer.exe but I would like to use your app instead. Dimmer has only 1 single "opacity" cursor, I'm using an ahk code to move it either at 50% or 100%. The gamma of my monitor is set to 30 by default (otherwise it's too clear), so sometime I need to manually move the alpha to 80 playing with the screen button).
I am using a class made by Jinzim and the minimum brightness values ​​are set to 0. Although it is possible to make it darker, it may not have good results. It is healthier to change and use the average brightness on the hardware.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: Brightness and Temperature Fast Control

Post by robodesign » 18 Apr 2020, 06:26

Very nice work!

How did you get them digitally signed?
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Brightness and Temperature Fast Control

Post by hasantr » 18 Apr 2020, 11:19

robodesign wrote:
18 Apr 2020, 06:26
Very nice work!

How did you get them digitally signed?
I used this to add a certificate.
https://www.digicert.com/util/

I used the explanation here while creating the certificate. A narration in Turkish may be useful to use google translate.
https://www.sordum.net/52825/kod-imzalama-sertifikanizi-kendiniz-olusturun/
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: Brightness and Temperature Fast Control

Post by robodesign » 18 Apr 2020, 16:44

Thank you for the reply. The application is freeware.

How much did the certificate used cost? I'm interest in acquiring one for my apps as well. Apologies if my question is too direct. Please point me to where /what service you used to obtain a certificate.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Brightness and Temperature Fast Control

Post by hasantr » 19 Apr 2020, 11:09

robodesign wrote:
18 Apr 2020, 16:44
Thank you for the reply. The application is freeware.

How much did the certificate used cost? I'm interest in acquiring one for my apps as well. Apologies if my question is too direct. Please point me to where /what service you used to obtain a certificate.

Best regards, Marius.
I hope it helps. :)
https://www.autohotkey.com/boards/viewtopic.php?f=7&t=74856
burque505
Posts: 1736
Joined: 22 Jan 2017, 19:37

Re: Brightness and Temperature Fast Control

Post by burque505 » 19 Apr 2020, 11:32

@hasantr's post will likely be all you need to make a certificate, or the links in it will get you there. If not, you migh have a look at this link for Win10 certificate creation might help too, there's probably the same link in @hasantr's post but I haven't found it yet.
For Win7 (MakeCert) you might take a look at Scott Brady's article.
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Brightness and Temperature Fast Control

Post by hasantr » 19 Apr 2020, 11:41

burque505 wrote:
19 Apr 2020, 11:32
@hasantr's post will likely be all you need to make a certificate, or the links in it will get you there. If not, you migh have a look at this link for Win10 certificate creation might help too, there's probably the same link in @hasantr's post but I haven't found it yet.
For Win7 (MakeCert) you might take a look at Scott Brady's article.
I cited from another source. I had no knowledge of these issues. Thank you for the links.
InGearX
Posts: 54
Joined: 14 Oct 2016, 15:53

Re: Brightness and Temperature Fast Control

Post by InGearX » 22 Apr 2020, 23:55

finally !!! thank you !!! after years of searching

my eyes are saved on a desktop

thank you!!!

I've set this:
Win+S = increase brightness
Win+X = decrease brightness

Win+Alt+S = increase temperature
Win+Alt+X = decrease temperature
PS and for volume I already had
#A::Send {Volume_Up}
#Z::Send {Volume_Down}
#Q::Send {Volume_Mute}
and on a laptop I use
#S::RUN C:\z\nircmd\nircmd.exe changebrightness 5
#X::RUN C:\z\nircmd\nircmd.exe changebrightness -5
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Brightness and Temperature Fast Control

Post by hasantr » 23 Apr 2020, 08:47

InGearX wrote:
22 Apr 2020, 23:55
finally !!! thank you !!! after years of searching

my eyes are saved on a desktop

thank you!!!

I've set this:
Win+S = increase brightness
Win+X = decrease brightness

Win+Alt+S = increase temperature
Win+Alt+X = decrease temperature
PS and for volume I already had
#A::Send {Volume_Up}
#Z::Send {Volume_Down}
#Q::Send {Volume_Mute}
and on a laptop I use
#S::RUN C:\z\nircmd\nircmd.exe changebrightness 5
#X::RUN C:\z\nircmd\nircmd.exe changebrightness -5
I'm glad it's useful. Enjoy it.
Lisa19
Posts: 48
Joined: 07 Apr 2019, 22:25

Re: Brightness and Temperature Fast Control

Post by Lisa19 » 30 Aug 2020, 07:35

Thanks for your reply! (Sorry for the delay I just got your message today, I used a wrong email).
It is healthier to change and use the average brightness on the hardware.
Unfortunatley I can't use the monitor hardware, it's useless because the darkest level is too bright.
it is possible to make it darker
That's great, but how ? Please tell us how we can do it.
it may not have good results
It will be much better that what I have now using both your app and dimmer.exe !
User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: Brightness and Temperature Fast Control

Post by Tigerlily » 30 Aug 2020, 12:49

Hi @Lisa19,

Check out my screen dimmer, tigerlily's Screen Dimmer, it solves this issue you are having, you get complete adjustment of Red, Green, and Blue Gamma (aka each color level of brightness, adjusting them all is equivalent to adjusting brightness up or down). This means you can have 0% brightness or even 0.05% brightness if desired. It also has support for multi-monitor set ups that support their own monitor brightness and contrast. Additionally, there is a built-in screen overlay that can make your monitor's brightness as dark as possible. And many more features.

I haven't coded in an algorithm to adjust Color Temperature explicitly yet, however you can adjust this implicitly with the gamma sliders (which are the nuts and bolts of Color Temperature). IMO an arbitrary color temperature (such as 2000 kelvins) is less effective than adjusting the color output values exactly where you desire them.

Check it out, there is an EXE download since the code is written in AHK V2 in case you aren't coding in v2 yet. Feel free to ask any questions if you are unsure how to use. Here is a link to my forum thread for the best screen dimmer you can find:


tigerlily's Screen Dimmer



@hasantr: Unfortunately, the version of Monitor Class you are using for your GUI/Code is outdated and does not allow you to adjust brightness completely to 0. The class was written in a way that doesn't allow you to get below 50% brightness. I'd be happy to show you how you could adjust your code to fix this, just let me know (I did this in the past with that class)!

Please see jNizM's updated Monitor Class on GitHub or Forums for an improved, updated version. As mentioned, I've also rewritten the Monitor Class for V2 and improved on it, feel free to check out my GitHub or
Forum Post.



Hope this helps. Cheers! :rainbow:
-TL
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Brightness and Temperature Fast Control

Post by hasantr » 31 Aug 2020, 01:45

Tigerlily wrote:
30 Aug 2020, 12:49
Hi @Lisa19,

Check out my screen dimmer, tigerlily's Screen Dimmer, it solves this issue you are having, you get complete adjustment of Red, Green, and Blue Gamma (aka each color level of brightness, adjusting them all is equivalent to adjusting brightness up or down). This means you can have 0% brightness or even 0.05% brightness if desired. It also has support for multi-monitor set ups that support their own monitor brightness and contrast. Additionally, there is a built-in screen overlay that can make your monitor's brightness as dark as possible. And many more features.

I haven't coded in an algorithm to adjust Color Temperature explicitly yet, however you can adjust this implicitly with the gamma sliders (which are the nuts and bolts of Color Temperature). IMO an arbitrary color temperature (such as 2000 kelvins) is less effective than adjusting the color output values exactly where you desire them.

Check it out, there is an EXE download since the code is written in AHK V2 in case you aren't coding in v2 yet. Feel free to ask any questions if you are unsure how to use. Here is a link to my forum thread for the best screen dimmer you can find:


tigerlily's Screen Dimmer



@hasantr: Unfortunately, the version of Monitor Class you are using for your GUI/Code is outdated and does not allow you to adjust brightness completely to 0. The class was written in a way that doesn't allow you to get below 50% brightness. I'd be happy to show you how you could adjust your code to fix this, just let me know (I did this in the past with that class)!

Please see jNizM's updated Monitor Class on GitHub or Forums for an improved, updated version. As mentioned, I've also rewritten the Monitor Class for V2 and improved on it, feel free to check out my GitHub or
Forum Post.



Hope this helps. Cheers! :rainbow:

Thank you for your helpfulness. Yes, I created it using the old class. I was actually working on a major update and it was going to bring some great features. Unfortunately, I could not spare much time. When I come back again, I will seek your help. Thank you so much.
Lisa19
Posts: 48
Joined: 07 Apr 2019, 22:25

Re: Brightness and Temperature Fast Control

Post by Lisa19 » 31 Aug 2020, 12:20

Tigerlily wrote:
30 Aug 2020, 12:49
Check out my screen dimmer,
Thanks for your reply, but windows blocked the .exe, so I checked it, and windows found a trojan in your app:
Image
User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: Brightness and Temperature Fast Control

Post by Tigerlily » 02 Sep 2020, 17:02

@Lisa19
That is a false-positive, there is no trojan in my app if you downloaded it from GitHub.... check the source yourself by opening the .exe file with notepad to safely examine.
-TL
SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: Brightness and Temperature Fast Control

Post by SOTE » 06 Sep 2020, 00:08

Lisa19 wrote:
31 Aug 2020, 12:20
Tigerlily wrote:
30 Aug 2020, 12:49
Check out my screen dimmer,
Thanks for your reply, but windows blocked the .exe, so I checked it, and windows found a trojan in your app:
There is a tendency for new versions of AutoHotkey to be falsely identified. With AHK v2 x86 having a little more issue than AHK v1 or AHK v2 x64.
The pattern is it takes around a month, and after people go after anti-virus companies for false-positives, then things get stable. Also experienced AHK users tend to be more cutting edge than conservative, so might compile their .exe with the latest version of AHK or might be compressing files with mpress versus older more well known versions of AHK or no compression, thus get more caught up in the false-positive issue.

Thankfully, a lot of people but their source code on GitHub or here on the board, so people can get the .ahk version of the file and compile it themselves. Also, it shows that the issue is usually about false-positives than actually any real threat.
User avatar
SteveMylo
Posts: 233
Joined: 22 Jun 2021, 00:50
Location: Australia
Contact:

Re: Brightness and Temperature Fast Control

Post by SteveMylo » 18 Feb 2022, 18:53

@hasantr Hi, This script is the best out of the lot!! I've tried them all, f.Lux, Tigerlily etc.... thankyou! Its speed and scroll wheel ability is Super Fast.
Although .... now I have a 2nd monitor it doesn't work :(
I only want it to work on my Primary main monitor.
Is there a function to get this to work on just my main monitor as it used to??
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Brightness and Temperature Fast Control

Post by hasantr » 20 Feb 2022, 06:57

SteveMylo wrote:
18 Feb 2022, 18:53
@hasantr Hi, This script is the best out of the lot!! I've tried them all, f.Lux, Tigerlily etc.... thankyou! Its speed and scroll wheel ability is Super Fast.
Although .... now I have a 2nd monitor it doesn't work :(
I only want it to work on my Primary main monitor.
Is there a function to get this to work on just my main monitor as it used to??
Hi @SteveMylo I'm glad the app is useful. Since I don't have two monitors, I haven't had a chance to try it. I have designed major updates for this app but I have no time and motivation. Give me some time and I'll be back for a recheck. I'm also designing a small and inexpensive hardware with Ardiuno, so that it can capture the brightness intensity that the user prefers according to the ambient light. But I hope I will have time for that.
Post Reply

Return to “Scripts and Functions (v1)”