Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Disable f.lux when specific display connected
; Listens for display connected and checks its name against TARGET_DISPLAYS
; then automates "disable for fullscreen apps" option
; CONFIGURE your projector/TV here. Use the names from Screen resolution control panel
global TARGET_DISPLAYS := "MP-CL1A,SONY TV XV" ; MatchList
; [Beginner question and script for dual monitors](
OnMessage(0x7E, "onDisplayChange")
onDisplayChange() {
Sleep 500
; If projectors or TVs attached disable f.lux for fullscreen apps
; Disregards software disconnection. If the cable is attached it counts
getMonitors() {
wmi := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" A_ComputerName "\root\wmi")
; SWbemObjectSet with InstanceName properties
return wmi.ExecQuery("Select * from WMIMonitorID")
areDisplaysAttached(targetUserFriendlyNames) {
areAttached := 0
For monitor in getMonitors() {
fname :=
for char in monitor.UserFriendlyName
fname .= chr(char)
if fname in %targetUserFriendlyNames%
areAttached = 1
return areAttached
; f.lux automation by registry write and restart
; :+1: no UI automation
; :-1: requires process restart for settings to take effect (FOHCTLAN)
; *[FOHCTLAN]: flash of high color temperature light at night
getFluxPath() {
A_DetectHiddenWindowsOld := A_DetectHiddenWindows
DetectHiddenWindows, On
WinGet, fluxPath, ProcessPath, ahk_exe flux.exe
DetectHiddenWindows, %A_DetectHiddenWindowsOld%
return fluxPath
restartFlux() {
fluxPath := getFluxPath()
Process, Close, flux.exe
; Try path from process and fallback to default if not
if (fluxPath)
; Set working dir to something that won't be moved or renamed
; because it will be locked while running
Run, %fluxPath%, "%LOCALAPPDATA%"
Run, "%LOCALAPPDATA%\FluxSoftware\Flux\flux.exe", "%LOCALAPPDATA%"
setFluxFullscreenDisable(val := "toggle") {
fluxPrefs = HKEY_CURRENT_USER\Software\Michael Herf\flux\Preferences
setting = fullscreendisable
; Read current setting value
RegRead, currentVal, %fluxPrefs%, %setting%
; No valid argument passed, toggle current value
val := !(val = 0 or val = 1) ? !currentVal : val
; Only if changed, save a restart cycle
if (val != currentVal) {
; Write new value
RegWrite, REG_DWORD, %fluxPrefs%, %setting%, %val%
FileAppend, % setting "=" val "`n", *
return val

This comment has been minimized.

Copy link
Owner Author

@akaleeroy akaleeroy commented Mar 1, 2019

Alpha release, subject to change, made obsolete since f.lux 4.86 beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment