11; @Ahk2Exe-SetName FireFlyFy
22; @Ahk2Exe-SetDescription Changes monitor brightness based on active window.
3- ; @Ahk2Exe-SetVersion 0 .0.1
3+ ; @Ahk2Exe-SetVersion 1 .0.0
44; @Ahk2Exe-SetCopyright Copyright (c) 2025`, elModo7 - VictorDevLog
55; @Ahk2Exe-SetOrigFilename FireFlyFy.exe
66#NoEnv
77#SingleInstance Force
88#Persistent
9+ SetTitleMatchMode , 3
910DetectHiddenWindows , On
1011SetBatchLines - 1
12+ CoordMode , Mouse , Screen
13+ global version := " 0.1.3"
14+ global appName := " FireFlyFy"
15+
16+ ; Libs
1117#Include <Screen>
1218#Include <cJSON>
13- #Include <aboutScreen>
19+ #Include <Utils>
20+ #Include <AboutScreen>
1421#Include <WindowsNightLight>
15- global version := " 0.1"
16- global appName := " FireFlyFy"
17- global appPrev, globalSettings, apps
1822
19- gosub , configureTray
20- gosub , createOrReadConfig
23+ ; Globals
24+ global initialBrightness, appPrev, processPrev, globalConfig, appsConfig, isVisible := 1 , fireFlyFyEnabled := 1
25+
26+ ; Init
27+ createOrReadConfig()
28+ loadTranslations(globalConfig.language)
29+ installResources()
30+ setInitialBrigthness()
31+ configureTray()
2132createNightFilter()
2233
23- SetTimer , checkCurrentApp, 500
24- ; WinShow, nightFilter
25- NightLight_Toggle()
26- Sleep , 2000
27- NightLight_Toggle()
28- return
34+ Gui + LastFound
35+ hWnd := WinExist ()
36+ DllCall (" RegisterShellHookWindow" , UInt, hWnd)
37+ registerWindowMessageId := DllCall (" RegisterWindowMessage" , Str, " SHELLHOOK" )
38+ OnMessage (0x404 , " trayEventsCapture" )
2939
30- checkCurrentApp :
31- ; WinGetActiveTitle, activeTitle
32- ; WinGet, activeProcess, ProcessName
33- if (appCur ! = appPrev) {
34- ; setMonitorBrightnessProgressive(0)
35- }
36- appPrev := appCur
40+ enableFireFlyFy()
41+ gosub , initMouseFollower
3742return
3843
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
44+ detectWindowChanged(wParam, lParam)
45+ {
46+ ; https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms644991(v=vs.85)
47+ if ((wParam > 0 && wParam < 5 ) || wParam == 6 || wParam == 32772 ) {
48+ Settimer , checkCurrentApp, 100
49+ }
50+ }
4851
49- createOrReadConfig :
50- if (! FileExist (" config/global.json" )) {
51- createConfig()
52- } else {
53- FileRead , globalSettings, config/ global.json
54- globalSettings := JSON.Load(globalSettings)
52+ checkCurrentApp :
53+ Settimer , checkCurrentApp, Off
54+ WinGetActiveTitle , appCur
55+ WinGet , processCur, ProcessName , A
56+ if (appCur ! = appPrev || processCur ! = processPrev) {
57+ appPrev := appCur
58+ processPrev := processCur
59+ for appK, appV in appsConfig.apps
60+ {
61+ if (appV.activeBy == " process" ) {
62+ if (processCur == appV.process ) {
63+ applyFireFlyFy(appV)
64+ return
65+ }
66+ } else {
67+ if (appCur == appV.title) {
68+ applyFireFlyFy(appV)
69+ return
70+ }
71+ }
72+ }
73+ removeFireFlyFy()
5574 }
5675return
5776
58- createConfig () {
59- globalSettings := {}
60- globalSettings.language := " en-US"
61- globalSettings.startWithWindows := 0
62- FileAppend , % JSON.Dump(globalSettings), config/ global.json
63- }
77+ #Include <LabelUtils>
6478
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- }
79+ ^Esc ::Reload
7380
74- showAboutScreen :
75- showAboutScreen(appName " v" version, " Changes your monitor brightness automatically based on the currently active window." )
76- return
81+ /* TODO:
82+ Add window / process -> FireFly follows mouse when choosing, enter chooses, escape cancels
83+ title or processName (default by process)
84+ brightnessValue 0-100 (default 50)
85+ nightLightStrength 0-100 (default 50)
86+ Block that if you have by title of the same process, you can not add a rule by process unless you remove the ones by title before, maybe prompt of those that match and offer removing?
7787
78- aboutGuiEscape :
79- aboutGuiClose :
80- AboutGuiClose()
81- return
8288
83- ExitSub :
84- ExitApp
89+ application list
90+
91+ Start with windows (default no)
92+ Scheduler (default no)
93+ progressive change yes/no (default yes)
94+ multilingual
95+ Clear config
8596
86- /*
87- toggleable hotkey
88- trayMenu
89- title or processName
90- brightnessValue 0-100
91- progressive change yes/no
92- add about
97+ Update, autoreplace running executable
98+ Add CLI
9399*/
0 commit comments