Dimming Screen without losing focus Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Guest

Dimming Screen without losing focus  Topic is solved

22 Aug 2017, 03:15

Code: Select all

if GetKeyState("CapsLock", "T")
{
    scW:=A_ScreenWidth-20
    scH:=A_ScreenHeight-20
    Gui, color, 000000, Light Blocking GUI
    Gui, -Caption +AlwaysOnTop +E0x08000000 +owner
    Gui, show, x10 y10 w%scW% h%scH%, Light Blocking GUI
    WinSet, Transparent, 0, Light Blocking GUI
    SetCapsLockState, off
}
else
{
    scW:=A_ScreenWidth-20
    scH:=A_ScreenHeight-20
    Gui, color, 000000, Light Blocking GUI
    Gui, -Caption +AlwaysOnTop +E0x20 +owner
    Gui, show, x10 y10 w%scW% h%scH%, Light Blocking GUI
    WinSet, Transparent, 100, Light Blocking GUI
    SetCapsLockState, on
}
return
Hi, new to autohotkey - fantastic tool.

I've assembled the above code to dim the screen when I press the CAPS LOCK button - and brighten it again on the second press. However, pressing CAPSLOCK causes Windows to lose the focus of the window I'm working on. I've tried adding the No Activation option to the Gui command but to no effect.

Needless to say this code is to be used as a capslock indicator. I've tried tool tips and progress bars, but I need something big and obvious and the progress bar for one doesnt allow click through which makes it very annoying if its in the wrong place on the screen.

Any ideas?

Thanks for any help.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Dimming Screen without losing focus

22 Aug 2017, 03:31

Class Monitor (Brightness, ColorTemperature)

Follow the GitHub link to see a Hotkey example
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Dimming Screen without losing focus

22 Aug 2017, 04:04

Did you add NoActivate to the Gui, Show? I did not have that feature before, and hadn't realized that my own screen dimming GUI was losing focus on the target app. So I added it, and it now works to keep focus on the app in use before changing the dimming. This is my code:

Code: Select all

+F2::
intensity+=25
If intensity>225
   intensity:=225 ; I didn't set this to 255 because it would be completely opaque. Change the 225s to a lower value if that is too dark
GoSub Overlay
return

+F3::
intensity-=25
if intensity<0
  intensity:=0
GoSub Overlay
return

Overlay:
Gui, Destroy
If intensity=0
   return
Gui, 1: Default
Gui, Color, 0x000000 ; Color to black
Gui, +LastFound +AlwaysOnTop -Caption +E0x20 ; Click through GUI always on top.
WinSet, Transparent, %Intensity% ; Set intensity first based on the time of dday
Gui, Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight% NoActivate, Overlay ; Cover entire screen
return
Guest

Re: Dimming Screen without losing focus

24 Aug 2017, 03:08

Thanks for the reply - sorted by problem out. This is my new code:

Code: Select all

;; Caps Lock indicator
~*CapsLock::
if GetKeyState("CapsLock", "T")
{
    scW:=A_ScreenWidth-10
    scH:=A_ScreenHeight-10

    Gui, Destroy
    Gui, 1: Default
    Gui, Color, 0x000000 ; Color to black
    Gui, +LastFound +AlwaysOnTop -Caption +E0x20
    WinSet, Transparent, 90
    Gui, Show, x5 y5 w%scW% h%scH% NoActivate, Overlay
    SetCapsLockState, off
}
else
{
    Gui, Destroy
    SetCapsLockState, on
}
return
Not sure why the first reply was marked with a green tick - was completely unhelpful.
Net_Wars
Posts: 51
Joined: 10 Oct 2018, 11:11

Re: Dimming Screen without losing focus

10 Oct 2018, 12:50

Hey Guys,
I'm new in AHK scripting. I was trying many ways to do this, also comparing my code and Yours and it doesn't work. I can't find how to do this. Can You tell me how not to lose focus on latest active window?
This is my code:

Code: Select all

#SingleInstance,Ignore
runspeed=0
editspeed=0

Beg:
Gui, New,, Gui1
Gui, Font, CWhite
Gui, Add, Picture, x0 y0 w65, C:\Users\Acer\Desktop\Pulpit - nowy\Skrypty\background.png
Gui, Add, Progress, x27 y20 w11 h79 Range0-100 c8C8C8C Background6A6A6A vMyProgress Vertical,%editspeed%
Gui, Add, Text, x24 y110 w17 h23 veditspeed geditchange BackgroundTrans Center,%editspeed%
;Gui, Color, 1D1D1D
Gui, -Caption +AlwaysOnTop +0x8000000 +owner
Gui, Show, x50 y60 w65 h139
return

LWin & q::
GuiControl,, MyProgress, +-10
editspeed+=10
Gosub,dim
return
LWin & e::
GuiControl,, MyProgress, +10
editspeed-=10
Gosub,dim
return

changespeed:
Gui, Submit, NoHide
GuiControl,, editspeed, %runspeed%
return

editchange:
Gui, Submit, NoHide
GuiControl,, runspeed, %editspeed%
return

dim:
Gui, New,, Gui2
if editspeed < 0
editspeed = 0
if editspeed > 100
editspeed = 100
Gui, Destroy
Gui, Color, 000000
Gui, -Caption +AlwaysOnTop +E0x20 +0x8000000 +owner
Gui, Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight% NoActivate, Light Blocking GUI
WinSet, Transparent, %editspeed%, Light Blocking GUI
;SetTimer, hide, 2400
Gosub,beg
return

;wyłączenie awaryjne
^F2::
ToolTip, Skrypt wyłączony
Sleep, 750
ExitApp
return
Thanks in advance for help.
Hi,
I was trying make this on my own but I'm good only in basics not good even in basics. :facepalm:

Sorry for my bad English. If something is unclear I will try better next time. :headwall:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ht55cd3 and 245 guests