You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#NoEnv; Recommended for performance and compatibility with future AutoHotkey releases.
2
+
#SingleInstance; Only allows one instance of the script to run.
3
+
#Warn; Enable warnings to assist with detecting common errors.
4
+
SendModeInput ; Recommended for new scripts due to its superior speed and reliability.
5
+
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
6
+
7
+
8
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9
+
;;;;;; REDSHIFT KEYS by ImOnMars ;;;;;;
10
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
+
; Created so that you can manually modify screen color temperature using hotkeys on Windows
12
+
;
13
+
; To make this run automatically when your PC starts, put it (or a shortcut to it) in the Startup folder (For Windows 10: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp)
14
+
;
15
+
; Requirements:
16
+
; - AutoHotkey
17
+
; - Redshift
18
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19
+
20
+
21
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22
+
;;;;;; CONFIG OPTIONS ;;;;;;
23
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24
+
25
+
; Redshift Settings
26
+
REDSHIFT_PATH = redshift ; The path where redshift is, if redshift is in your path environment variable, then you can leave as is
27
+
28
+
; Options File
29
+
SAVE_OPTIONS := true ; Whether or not to save options to a file after script restart or PC reboot
30
+
OPTIONS_PATH = C:\redshiftKeysOptions.ini ; Path of where to save options if SAVE_OPTIONS is true
31
+
32
+
; Shift Values
33
+
STARTING_SHIFT = 5500 ; Shift to set when starting the script (on boot or restart) and SAVE_OPTIONS is false or the ini file isn't set
34
+
DEFAULT_SHIFT = 6500 ; Default Windows color temperature when shift is disabled
35
+
MIN_SHIFT = 3500 ; Minimum shift that the script will decrement to
36
+
MAX_SHIFT = 7500 ; Maximum shift that the script will increment to
37
+
SHIFT_INCREMENT = 250 ; Amount that the shift will increment/decrement by
38
+
39
+
; Hotkeys, see here for key combinations: https://autohotkey.com/docs/Hotkeys.htm
40
+
TOGGLE_SHIFT_HOTKEY = <#y ; Default: (Left Windows Key + y)
41
+
INCREASE_SHIFT_HOTKEY = <#[ ; Default: (Left Windows Key + [)
42
+
DECREASE_SHIFT_HOTKEY = <#] ; Default: (Left Windows Key + ])
43
+
44
+
; General Options
45
+
START_ON_RUN := true ; Whether to start with shift or not when starting the script (on boot or restart) and SAVE_OPTIONS is false or the ini file isn't set
46
+
SHOW_SHIFT_GUI := true ; Whether the current shift GUI should be shown when pressing hotkeys
47
+
SHIFT_AMOUNT_GUI_RELATIVE := false ; Whether the current shift GUI should be relative to the DEFAULT_SHIFT (ex: if DEFAULT_SHIFT = 6500 and the current shift is 5500, it will display -1000)
48
+
49
+
50
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
51
+
;;;;;; INITIAL RUN ;;;;;;
52
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
53
+
54
+
; Defaults
55
+
isEnabled := START_ON_RUN
56
+
curShift := STARTING_SHIFT
57
+
58
+
; If necessary, read or write all of the options
59
+
if (SAVE_OPTIONS)
60
+
{
61
+
if (FileExist(OPTIONS_PATH))
62
+
{
63
+
readAllOptionsFromFile()
64
+
}
65
+
else
66
+
{
67
+
writeAllOptionsToFile()
68
+
}
69
+
}
70
+
71
+
; Set the initial shift values
72
+
if (isEnabled)
73
+
{
74
+
Run, %REDSHIFT_PATH% -O %curShift%,, Hide
75
+
shiftAmountBox(curShift, true)
76
+
}
77
+
else
78
+
{
79
+
Run, %REDSHIFT_PATH% -x,, Hide
80
+
}
81
+
82
+
83
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
84
+
;;;;;; HOTKEY BINDINGS ;;;;;;
85
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
86
+
87
+
; Apply the hotkeys set above to their respective actions
88
+
Hotkey, %TOGGLE_SHIFT_HOTKEY%, ToggleShift
89
+
Hotkey, %INCREASE_SHIFT_HOTKEY%, IncreaseShift
90
+
Hotkey, %DECREASE_SHIFT_HOTKEY%, DecreaseShift
91
+
return
92
+
93
+
ToggleShift:
94
+
if (isEnabled)
95
+
{
96
+
Run, %REDSHIFT_PATH% -x,, Hide
97
+
isEnabled := false
98
+
shiftAmountBox(DEFAULT_SHIFT, true)
99
+
}
100
+
else
101
+
{
102
+
Run, %REDSHIFT_PATH% -O %curShift%,, Hide
103
+
isEnabled := true
104
+
shiftAmountBox(curShift, true)
105
+
}
106
+
writeOptionToFile("startShifted", isEnabled)
107
+
return
108
+
109
+
IncreaseShift:
110
+
if (isEnabled)
111
+
{
112
+
if ((curShift + SHIFT_INCREMENT) < MAX_SHIFT)
113
+
{
114
+
curShift += SHIFT_INCREMENT
115
+
}
116
+
else
117
+
{
118
+
curShift := MAX_SHIFT
119
+
}
120
+
Run, %REDSHIFT_PATH% -O %curShift%,, Hide
121
+
shiftAmountBox(curShift)
122
+
writeOptionToFile("currentShift", curShift)
123
+
}
124
+
return
125
+
126
+
DecreaseShift:
127
+
if (isEnabled)
128
+
{
129
+
if ((curShift - SHIFT_INCREMENT) > MIN_SHIFT)
130
+
{
131
+
curShift -= SHIFT_INCREMENT
132
+
}
133
+
else
134
+
{
135
+
curShift := MIN_SHIFT
136
+
}
137
+
Run, %REDSHIFT_PATH% -O %curShift%,, Hide
138
+
shiftAmountBox(curShift)
139
+
writeOptionToFile("currentShift", curShift)
140
+
}
141
+
return
142
+
143
+
144
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
145
+
;;;;;; INI FILE MANAGEMENT ;;;;;;
146
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
147
+
148
+
writeOptionToFile(optionName, optionValue)
149
+
{
150
+
global SAVE_OPTIONS
151
+
global OPTIONS_PATH
152
+
153
+
if (NOT SAVE_OPTIONS)
154
+
{
155
+
return
156
+
}
157
+
158
+
IniWrite, %optionValue%, %OPTIONS_PATH%, General, %optionName%
159
+
}
160
+
161
+
readOptionFromFile(optionName, ByRef optionValue)
162
+
{
163
+
global SAVE_OPTIONS
164
+
global OPTIONS_PATH
165
+
166
+
if (NOT SAVE_OPTIONS)
167
+
{
168
+
return
169
+
}
170
+
171
+
IniRead, optionValue, %OPTIONS_PATH%, General, %optionName%
0 commit comments