Skrommel's 2005 DimInactive--Move dark cover to non-primary monitor Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
samt
Posts: 62
Joined: 09 Sep 2022, 13:29

Skrommel's 2005 DimInactive--Move dark cover to non-primary monitor

Post by samt » 13 Mar 2024, 01:11

https://www.autohotkey.com/board/topic/4263-diminactive-dim-all-inactive-windows/
This works well for the primary monitor on my Windows 10. It auto dims the primary monitor when it becomes inactive.
I'm trying to make the script fully dim the far left monitor whenever it's inactive, while the center monitor is the primary one ( I have 3 monitors-left,centre,right ).


And I've seen Skrommel's updated script to this: https://www.autohotkey.com/board/topic/4288-ghoster-put-a-transparent-image-across-your-screen/
But for some reason, it permanently dims the monitor, even when it's active. I messed around the settings and it didn't change anything except how transparent the grey cover is over the screen.

Back to the original, 2005 DimInactive by @skrommel
I changed/add a few numbers to try to make this happen (like replaced 0's for x axis with -1920 (to move the dark cover -1920 pixels over to the left monitor from the center primary monitor))..its close.. it dims my far left monitor when it's inactive, EXCEPT for the task bar area (even if the taskbar is hidden). What would I change to make it dim everything including the taskbar area?

Code: Select all

Gui,+Owner +AlwaysOnTop -Disabled -SysMenu -Caption

Gui, Color, 000000

Gui,Add,Picture,X-1920 Y0 W%A_ScreenWidth% H%A_ScreenHeight% gCLICK,

Gui,Show,NoActivate X-1920 Y0 W%A_ScreenWidth% H%A_ScreenHeight%,WINDOW

WinSet,Transparent,255,WINDOW



LOOP:

Sleep,100

WinGetActiveStats,wint,winw,winh,winx,winy

winw+=winx

winh+=winy

If winx<-1920

winx=-1920

If winy<0

winy=0

If wint=

{

winx=-1920

winy=1080

winw=%A_ScreenWidth%

winh=%A_ScreenHeight%

}

WinSet,Region,0-0 %A_ScreenWidth%-1920 %A_ScreenWidth%-%A_ScreenHeight% 1080-%A_ScreenHeight% 0-0 %winx%-%winy% %winw%-%winy% %winw%-%winh% %winx%-%winh% %winx%-%winy%,WINDOW

WinSet,Top,,WINDOW ; Rem this line to keep the task bar visible

Goto,LOOP



CLICK:

WinSet,Bottom,,WINDOW

CoordMode,Mouse,Screen

MouseGetPos,mousex,mousey,mousewin

MouseClick,Left,%mousex%,%mousey%

MouseClick,Left,%mousex%,%mousey%

WinSet,AlwaysOnTop,On,WINDOW

Return

Rohwedder
Posts: 7750
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Skrommel's 2005 DimInactive--Move dark cover to non-primary monitor  Topic is solved

Post by Rohwedder » 13 Mar 2024, 06:07

Hallo,
try:

Code: Select all

Loop, Parse,% "XL,YU,XW,YH", CSV
	SysGet, %A_LoopField%,% 75 + A_Index
XR:= XL + XW, YD:= YU + YH ; bounding rectangle of all display monitors
Gui, +Owner +AlwaysOnTop -Disabled -SysMenu -Caption
Gui, Color, Black
Gui, Show, x%XL% y%YU% w%XW% h%YH% NA, Black
WinSet, ExStyle, ^0x20, Black
WinSet, Transparent, 255, Black
VarSetCapacity(Info, 40), NumPut(40, Info)
SetTimer, Region, 250
Region: ; ActiveMonitor = Monitor of the active window
ActiveMonitor := DllCall("MonitorFromWindow", "Ptr", WinExist("A"), "UInt", 0x2)
DllCall("GetMonitorInfo", "Ptr", ActiveMonitor, "Ptr", &Info)
ML := NumGet(Info, 20, "Int"), MR := NumGet(Info, 28, "Int") ; left/right of ActiveMonitor 
WinSet, Region, %XL%-%YU% %XR%-%YU% %XR%-%YD% %XL%-%YD% %XL%
-%YU% %ML%-%YU% %MR%-%YU% %MR%-%YD% %ML%-%YD% %ML%-%YU%, Black
IFWinActive, ahk_class Progman
	WinHide, Black ; do not darken the Progman
Else WinShow, Black
Return

samt
Posts: 62
Joined: 09 Sep 2022, 13:29

Re: Skrommel's 2005 DimInactive--Move dark cover to non-primary monitor

Post by samt » 13 Mar 2024, 15:49

Rohwedder wrote:
13 Mar 2024, 06:07
Hallo,
try:

Code: Select all

Loop, Parse,% "XL,YU,XW,YH", CSV
	SysGet, %A_LoopField%,% 75 + A_Index
XR:= XL + XW, YD:= YU + YH ; bounding rectangle of all display monitors
Gui, +Owner +AlwaysOnTop -Disabled -SysMenu -Caption
Gui, Color, Black
Gui, Show, x%XL% y%YU% w%XW% h%YH% NA, Black
WinSet, ExStyle, ^0x20, Black
WinSet, Transparent, 255, Black
VarSetCapacity(Info, 40), NumPut(40, Info)
SetTimer, Region, 250
Region: ; ActiveMonitor = Monitor of the active window
ActiveMonitor := DllCall("MonitorFromWindow", "Ptr", WinExist("A"), "UInt", 0x2)
DllCall("GetMonitorInfo", "Ptr", ActiveMonitor, "Ptr", &Info)
ML := NumGet(Info, 20, "Int"), MR := NumGet(Info, 28, "Int") ; left/right of ActiveMonitor 
WinSet, Region, %XL%-%YU% %XR%-%YU% %XR%-%YD% %XL%-%YD% %XL%
-%YU% %ML%-%YU% %MR%-%YU% %MR%-%YD% %ML%-%YD% %ML%-%YU%, Black
IFWinActive, ahk_class Progman
	WinHide, Black ; do not darken the Progman
Else WinShow, Black
Return
Cool this seems much more smoother and more refined.
There are 2 issues I've been trying to fix.
My setup is 3 monitors: a monitor on the center, right and one on the left. My center monitor is the primary display and should never be blacked-out.
I had to edit a small part of it to get it to black-out the left monitor when it's inactive. The edited part is near the bottom at Winset, Region, where I simply deleted:

Code: Select all

%XR%-%YU% %XR%-%YD%
. Now, it does black-out the monitor on the left when it's inactive, but the taskbar on my active monitor (center monitor) disappears. Not sure why that is. Taskbar should always be visible (unless using full screen app, ofcourse)
And I guess I should have said this before, but I'm also trying to get my monitor on the right to also be blacked-out when it's inactive too. So if both left and right monitors are inactive, both are blacked-out. If one of them is active, the other is blacked-out, and center monitor/primary display is never blacked out. I changed around the code in that same area near the end of the script but it doesn't go my way.

Rohwedder
Posts: 7750
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Skrommel's 2005 DimInactive--Move dark cover to non-primary monitor

Post by Rohwedder » 14 Mar 2024, 01:08

Then try:

Code: Select all

SysGet, C, Monitor, 2 ; Center Monitor 2 must always be visible
Loop, Parse,% "XL,YU,XW,YH", CSV
	SysGet, %A_LoopField%,% 75 + A_Index
XR:= XL + XW, YD:= YU + YH ; bounding rectangle of all display monitors
Gui, +Owner +AlwaysOnTop -Disabled -SysMenu -Caption
Gui, Color, Black
Gui, Show, x%XL% y%YU% w%XW% h%YH% NA, Black
WinSet, ExStyle, ^0x20, Black
WinSet, Transparent, 255, Black
VarSetCapacity(Info, 40), NumPut(40, Info)
SetTimer, Region, 250
Region: ; ActiveMonitor = Monitor of the active window
ActiveMonitor := DllCall("MonitorFromWindow", "Ptr", WinExist("A"), "UInt", 0x2)
DllCall("GetMonitorInfo", "Ptr", ActiveMonitor, "Ptr", &Info)
ML := NumGet(Info, 20, "Int"), MR := NumGet(Info, 28, "Int") ; left/right of ActiveMonitor 
CL := Min(ML, CLeft), CR := Max(MR, CRight) ; the hole must also contain the center Monitor
WinSet, Region, %XL%-%YU% %XR%-%YU% %XR%-%YD% %XL%-%YD% %XL%
-%YU% %CL%-%YU% %CR%-%YU% %CR%-%YD% %CL%-%YD% %CL%-%YU%, Black
IFWinActive, ahk_class Progman
	WinHide, Black ; do not darken the Progman
Else WinShow, Black
Return
Perhaps the position number of the center Monitor needs to be adjusted.

samt
Posts: 62
Joined: 09 Sep 2022, 13:29

Re: Skrommel's 2005 DimInactive--Move dark cover to non-primary monitor

Post by samt » 19 Mar 2024, 16:46

Rohwedder wrote:
14 Mar 2024, 01:08
Then try:

Code: Select all

SysGet, C, Monitor, 2 ; Center Monitor 2 must always be visible
Loop, Parse,% "XL,YU,XW,YH", CSV
	SysGet, %A_LoopField%,% 75 + A_Index
XR:= XL + XW, YD:= YU + YH ; bounding rectangle of all display monitors
Gui, +Owner +AlwaysOnTop -Disabled -SysMenu -Caption
Gui, Color, Black
Gui, Show, x%XL% y%YU% w%XW% h%YH% NA, Black
WinSet, ExStyle, ^0x20, Black
WinSet, Transparent, 255, Black
VarSetCapacity(Info, 40), NumPut(40, Info)
SetTimer, Region, 250
Region: ; ActiveMonitor = Monitor of the active window
ActiveMonitor := DllCall("MonitorFromWindow", "Ptr", WinExist("A"), "UInt", 0x2)
DllCall("GetMonitorInfo", "Ptr", ActiveMonitor, "Ptr", &Info)
ML := NumGet(Info, 20, "Int"), MR := NumGet(Info, 28, "Int") ; left/right of ActiveMonitor 
CL := Min(ML, CLeft), CR := Max(MR, CRight) ; the hole must also contain the center Monitor
WinSet, Region, %XL%-%YU% %XR%-%YU% %XR%-%YD% %XL%-%YD% %XL%
-%YU% %CL%-%YU% %CR%-%YU% %CR%-%YD% %CL%-%YD% %CL%-%YU%, Black
IFWinActive, ahk_class Progman
	WinHide, Black ; do not darken the Progman
Else WinShow, Black
Return
Perhaps the position number of the center Monitor needs to be adjusted.
hmm haven't been able to get it to fully work. Leaving the Sysget monitor number as 2 doesn't do anything except make the taskbar disappear when the center monitor is active, and the center monitor is actually number 2 in windows display settings. Changing it to 3 does the opposite of what I want--when the center monitor is active, that screen blackens and the other ones stay visible.
The closest thing is when I change Sysget monitor to 3, and then delete

Code: Select all

%XR%-%YU% %XR%-%YD%
near the bottom, the center monitor stays visible while the left monitor blackens, but the right monitor also stays visible when it should also blacken when center is active (or left is active), and the taskbar in the center monitor disappears for some reason again. Same as before, pretty much

Rohwedder
Posts: 7750
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Skrommel's 2005 DimInactive--Move dark cover to non-primary monitor

Post by Rohwedder » 20 Mar 2024, 07:52

I assumed that your three monitors are arranged logically horizontally, if they are not, this script cannot work!
Call Windows Spy, activate top right: Follow Mouse and check the mouse position Screen while moving the cursor across the monitors.
The boundary coordinates of all monitors should be within (XL, YU) and (XR, YD).
L, U, R, D stands for left, up, right, down.
The X coordinates of the active monitor are ML and MR L, R stands for left, right.
Add a few tooltips and you should be able to find the error.

Post Reply

Return to “Ask for Help (v1)”