Skip to content

Commit 0364d11

Browse files
committed
Initial commit.
Signed-off-by: elModo7 <elmodo7yt@gmail.com>
0 parents  commit 0364d11

9 files changed

Lines changed: 1075 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deprecated/

FireFlyFy.ahk

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
;@Ahk2Exe-SetName FireFlyFy
2+
;@Ahk2Exe-SetDescription Changes monitor brightness based on active window.
3+
;@Ahk2Exe-SetVersion 0.0.1
4+
;@Ahk2Exe-SetCopyright Copyright (c) 2025`, elModo7 - VictorDevLog
5+
;@Ahk2Exe-SetOrigFilename FireFlyFy.exe
6+
#NoEnv
7+
#SingleInstance Force
8+
#Persistent
9+
DetectHiddenWindows, On
10+
SetBatchLines -1
11+
#Include <Screen>
12+
#Include <cJSON>
13+
#Include <aboutScreen>
14+
#Include <WindowsNightLight>
15+
global version := "0.1"
16+
global appName := "FireFlyFy"
17+
global appPrev, globalSettings, apps
18+
19+
gosub, configureTray
20+
gosub, createOrReadConfig
21+
createNightFilter()
22+
23+
SetTimer, checkCurrentApp, 500
24+
;WinShow, nightFilter
25+
NightLight_Toggle()
26+
Sleep, 2000
27+
NightLight_Toggle()
28+
return
29+
30+
checkCurrentApp:
31+
;WinGetActiveTitle, activeTitle
32+
;WinGet, activeProcess, ProcessName
33+
if (appCur != appPrev) {
34+
; setMonitorBrightnessProgressive(0)
35+
}
36+
appPrev := appCur
37+
return
38+
39+
configureTray:
40+
Menu, Tray, NoStandard
41+
Menu, Tray, Tip, % appName "v" version
42+
Menu, Tray, Add,
43+
Menu, tray, add, % appName " Info", showAboutScreen
44+
;Menu tray, Icon, % appName " Info", % A_Temp "\" appName "\info.ico"
45+
Menu, Tray, Add, Exit, ExitSub
46+
;Menu tray, Icon, Exit, % A_Temp "\" appName "\close3.ico"
47+
return
48+
49+
createOrReadConfig:
50+
if (!FileExist("config/global.json")) {
51+
createConfig()
52+
} else {
53+
FileRead, globalSettings, config/global.json
54+
globalSettings := JSON.Load(globalSettings)
55+
}
56+
return
57+
58+
createConfig() {
59+
globalSettings := {}
60+
globalSettings.language := "en-US"
61+
globalSettings.startWithWindows := 0
62+
FileAppend, % JSON.Dump(globalSettings), config/global.json
63+
}
64+
65+
createNightFilter() {
66+
global
67+
Gui, nightFilter:+AlwaysOnTop +ToolWindow -Caption -DPIScale +E0x20
68+
Gui, nightFilter:Color, 0xFFFFEB
69+
Gui, nightFilter:Show, x0 y0 w1920 h1080 NoActivate Hide, nightFilter
70+
WinWait, nightFilter
71+
WinSet, Transparent, 35, nightFilter
72+
}
73+
74+
showAboutScreen:
75+
showAboutScreen(appName " v" version, "Changes your monitor brightness automatically based on the currently active window.")
76+
return
77+
78+
aboutGuiEscape:
79+
aboutGuiClose:
80+
AboutGuiClose()
81+
return
82+
83+
ExitSub:
84+
ExitApp
85+
86+
/*
87+
toggleable hotkey
88+
trayMenu
89+
title or processName
90+
brightnessValue 0-100
91+
progressive change yes/no
92+
add about
93+
*/

config/apps.json

Whitespace-only changes.

config/global.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"language": "en-US",
3+
"startWithWindows": false
4+
}

lib/Screen.ahk

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
getMonitorHandle()
2+
{
3+
; Initialize Monitor handle
4+
hMon := DllCall("MonitorFromPoint"
5+
, "int64", 0 ; point on monitor
6+
, "uint", 1) ; flag to return primary monitor on failure
7+
8+
9+
; Get Physical Monitor from handle
10+
VarSetCapacity(Physical_Monitor, 8 + 256, 0)
11+
12+
DllCall("dxva2\GetPhysicalMonitorsFromHMONITOR"
13+
, "int", hMon ; monitor handle
14+
, "uint", 1 ; monitor array size
15+
, "int", &Physical_Monitor) ; point to array with monitor
16+
17+
return hPhysMon := NumGet(Physical_Monitor)
18+
}
19+
20+
destroyMonitorHandle(handle)
21+
{
22+
DllCall("dxva2\DestroyPhysicalMonitor", "int", handle)
23+
}
24+
25+
setMonitorBrightnessProgressive(source)
26+
{
27+
target := source
28+
if (source) {
29+
Loop, 15
30+
{
31+
setMonitorBrightness(A_Index * 6)
32+
}
33+
} else {
34+
Loop, 15
35+
{
36+
setMonitorBrightness(100 - A_Index * 6)
37+
}
38+
}
39+
}
40+
41+
setMonitorBrightness(source)
42+
{
43+
handle := getMonitorHandle()
44+
DllCall("dxva2\SetVCPFeature"
45+
, "int", handle
46+
, "char", 0x10
47+
, "uint", source)
48+
destroyMonitorHandle(handle)
49+
}
50+
51+
getMonitorBrightness()
52+
{
53+
handle := getMonitorHandle()
54+
DllCall("dxva2\GetVCPFeatureAndVCPFeatureReply"
55+
, "int", handle
56+
, "char", 0x10
57+
, "Ptr", 0
58+
, "uint*", currentValue
59+
, "uint*", maximumValue)
60+
destroyMonitorHandle(handle)
61+
return currentValue
62+
}

0 commit comments

Comments
 (0)