DIMMER BOX

Post your working scripts, libraries and tools
User avatar
SpeedMaster
Posts: 397
Joined: 12 Nov 2016, 16:09

DIMMER BOX

14 Jul 2020, 18:33

I know there are lots of screen dimmers and probably much better than this one but I found the idea of targeting only certain windows quite interesting. (Especially Notepad :mrgreen: 8-) )

usage:
Press Alt + F1 to dim selected windows
Press Alt + F2 to destroy all overlay boxes

Code: Select all

; =================================================================================================================================
; Name:           Dimmer box
; Description:    Dim selected windows with an overlay box
; credits:        Speedmaster, Skwire
; Topic:          https://www.autohotkey.com/boards/viewtopic.php?f=6&t=78587
; Sript version:  1.0
; AHK Version:    1.1.24.03 (A32/U32/U64)
; Tested on:      Win 7 
; shortcuts::     !F1 update all boxes or add a new one
;                 !F2 destroy all boxes

#SingleInstance force

!F1::

winid:=""
    WinGetPos, X, Y, W, H, A
WinGet, winid,, A

if instr(idlist, winid) {
    for k, v in strsplit(idlist, "_") {
        if (v) {
          WinGetPos, X, Y, W, H, % "ahk_id " . v
           if w
          Gui, dim_%k% : Show, % "x" . x . "y" . y . "w" . w . "h" . h, Overlay
          else
          Gui, dim_%k% : Destroy
       }
    }
return
}

if instr(excludelist, winid)
return


if !winid
return

dimcount++

if winid
   idlist .= winid "_"

; thx Skwire
Gui, dim_%dimcount% : +Toolwindow -Caption +Lastfound +AlwaysOnTop
Gui, dim_%dimcount% : Color, black ; Change overlay colour here.
Gui, dim_%dimcount% : Show, % "x" . x . "y" . y . "w" . w . "h" . h, Overlay
GUI_ID := WinExist()

excludelist .= gui_id

WinSet, Transparent, 100       , % "ahk_id " . GUI_ID ; Change the numerical value for opaqueness amount.
WinSet, ExStyle    , +0x00000020, % "ahk_id " . GUI_ID ; Leave this value alone
Return

!f2::
loop, % dimcount 
Gui, dim_%a_index% : Destroy

idlist:=excludelist:=dimcount:=winid:=""

return

esc::exitapp

Attachments
dimmer_box.png
dimmer_box.png (45.4 KiB) Viewed 2724 times
lblb
Posts: 150
Joined: 30 Sep 2013, 11:31

Re: DIMMER BOX

14 Jul 2020, 19:02

Nice script! Couple of suggestions that I think would make it more useful:
- anchor the overlay to the dimmed window so that they move and resize together
- destroy the overlay if the dimmed window is closed
User avatar
SpeedMaster
Posts: 397
Joined: 12 Nov 2016, 16:09

Re: DIMMER BOX

15 Jul 2020, 01:36

lblb wrote:
14 Jul 2020, 19:02
- anchor the overlay to the dimmed window so that they move and resize together
- destroy the overlay if the dimmed window is closed
if you press Alt + F1 again after resizing or closing a window the script will do that. :thumbup:
Doing this automatically would be better but I have no idea how to do it properly. :think:

Regards
lblb
Posts: 150
Joined: 30 Sep 2013, 11:31

Re: DIMMER BOX

17 Jul 2020, 04:46

Thanks for the quick reply!
User avatar
elModo7
Posts: 189
Joined: 01 Sep 2017, 02:38
GitHub: elModo7
Location: Spain
Contact:

Re: DIMMER BOX

17 Jul 2020, 11:30

Convenient for specific apps, gj!
:beer:
keanhong2
Posts: 1
Joined: 03 Apr 2020, 18:07

Re: DIMMER BOX

19 Jul 2020, 22:01

thanks for sharing ,

Return to “Scripts and Functions”

Who is online

Users browsing this forum: kriszty, Xtra and 27 guests