NegativeScreen icon indicating copy to clipboard operation
NegativeScreen copied to clipboard

Inversion mode per application

Open dharkness opened this issue 8 years ago • 2 comments

Certain applications do not have a day/night mode or theming support, and they are painful to switch to as the screen flashes bright before I can toggle NegativeScreen. It would be great to be able to specify a per-application inversion mode in the config file that would be used when switching or launching applications. It doesn't need to affect only the application's windows; applying system-wide is just fine.

Bonus points for a key combo that would write the current mode for the current application to the config file. Otherwise, I don't know how you'd tie "some text" to application X. Registry key? Application name?

dharkness avatar Jan 03 '18 20:01 dharkness

I was looking for the same feature myself, while it might not be present into the app itself, I found out that AHK could accomplish that for me. Someone wrote this code for the intended purpose and I tested it with windows own color inversion.


win_list := ["winword.exe"
            , "notepad++.exe"]

; OnMessage Section to detect Open, Activate, and Close 
    Gui +LastFound
    hWnd := WinExist()

    DllCall( "RegisterShellHookWindow", UInt,hWnd )
    MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
    OnMessage( MsgNum, "ShellMessage" )

Return

; ------------------------ Activated -------------------------

ShellMessage( wParam,lParam ) {
    static wProcess 
    static oldProcess
    wID := lParam
    
    If (wParam = 4) || (wParam = 32772) ; HSHELL_WINDOWACTIVATED = 4 or 32772
    {
        oldProcess := wProcess

        WinGet, wProcess, ProcessName, ahk_id %wID%

        ; if it is vivaldi.exe 
        if (check(wProcess)) || check(oldProcess)
        {
            Send ^#c     
            return 
        }
    } 
}

check(x) {

    for k, v in win_list
    {
        if (v = x) {
            return 1
        }
    }

    return 0 
}

It's far from perfect since I saw some issues with the current alt tab while using that. But that might be fixable. But the other issue I found was with Negative screen. Instead of enable/disable option it has the toggle mode only just like windows. Which causes issues when two windows (present in the win_list) are activated one after the other which toggles the inversion back. @mlaily I saw that the web api has a disable and enable commands. I haven't tested them out so not sure if they work the same as toggle or differently. Would it be possible to have different hotkeys for enabling and disabling the inversion instead of a toggle?

RaXorX avatar Dec 21 '19 20:12 RaXorX

@RaXorX could you please elaborate a bit more on this script. How should I use it? it doesn't seem to have a hotkey. Should I run it with ahk.exe directly? are there any toggles like setting which apps it could affact?

DavidHJong avatar Nov 09 '22 21:11 DavidHJong