Create hotkey to adjust brightness on specific level Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
alf2314
Posts: 56
Joined: 05 Sep 2022, 13:29

Create hotkey to adjust brightness on specific level

Post by alf2314 » 24 Sep 2022, 20:54

hello, AHK.
There are several solutions to change display brightness with AHK hotkeys, for example I like this one (it is able to show default "level flyout")
but I failed to find any script that can adjust brightness on specific position, like F6 = 33%, F7 = 66%, F8 = 99%
so instead of adjusting the "step" you just press the key once and get preferred brightness level

Is it possible?

thanks


alf2314
Posts: 56
Joined: 05 Sep 2022, 13:29

Re: Create hotkey to adjust brightness on specific level

Post by alf2314 » 25 Sep 2022, 06:42

greetings, @mikeyww , I appreciate your attention to my question.
Could you please specify what exact post you r reffering to ?
Im asking because as I learnt from here the solution Im looking for is called "jump" parameter.

If my Browser works correctly, from your link Im getting this message
and this is nothing common with my question, as I may see.
I also checked every link you mentioned
and from 1 I actually find out about "jump".
but unfortunatelly none of the scripts are using this, I even have no example how to deal with jump.
All the script s from every topic I found are about making the brightness higher to 5%, 10% etc, or lower, and I cant use any of it because every script which mentions Jump has it set to FALSE, there is no example of script showing how to work with TRUE

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Create hotkey to adjust brightness on specific level

Post by mikeyww » 25 Sep 2022, 06:51

Code: Select all

changeBrightness(20)
Sleep, 500
changeBrightness(30)
Sleep, 500
changeBrightness(40)
Sleep, 500
changeBrightness(50)
Sleep, 500
changeBrightness(60)

changeBrightness(ByRef brightness, timeout := 1) {
 For property in ComObjGet("winmgmts:\\.\root\WMI").ExecQuery("SELECT * FROM WmiMonitorBrightnessMethods")
  property.WmiSetBrightness(timeout, brightness := Max(0, Min(brightness, 100)))
}

alf2314
Posts: 56
Joined: 05 Sep 2022, 13:29

Re: Create hotkey to adjust brightness on specific level

Post by alf2314 » 25 Sep 2022, 06:52

as I see from this code, the author created 3 types pf brightness, but I dont understand how to run it, what are the hotkeys for 50, for 100
why so much difficult in such simple action
boiler wrote:
05 Mar 2022, 22:25
It should. Run this script and it should change it to three brightness levels:

Code: Select all

ChangeBrightness(0)
Sleep, 2000
ChangeBrightness(100)
Sleep, 2000
ChangeBrightness(50)
return

ChangeBrightness( ByRef brightness := 50, timeout = 1 )
{
	if ( brightness >= 0 && brightness <= 100 )
	{
		For property in ComObjGet( "winmgmts:\\.\root\WMI" ).ExecQuery( "SELECT * FROM WmiMonitorBrightnessMethods" )
			property.WmiSetBrightness( timeout, brightness )	
	}
 	else if ( brightness > 100 )
 	{
 		brightness := 100
 	}
 	else if ( brightness < 0 )
 	{
 		brightness := 0
 	}
}

alf2314
Posts: 56
Joined: 05 Sep 2022, 13:29

Re: Create hotkey to adjust brightness on specific level

Post by alf2314 » 25 Sep 2022, 06:53

mikeyww wrote:
25 Sep 2022, 06:51

Code: Select all

changeBrightness(20)
Sleep, 500
changeBrightness(30)
Sleep, 500
changeBrightness(40)
Sleep, 500
changeBrightness(50)
Sleep, 500
changeBrightness(60)

changeBrightness(ByRef brightness, timeout := 1) {
 For property in ComObjGet("winmgmts:\\.\root\WMI").ExecQuery("SELECT * FROM WmiMonitorBrightnessMethods")
  property.WmiSetBrightness(timeout, brightness := Max(0, Min(brightness, 100)))
}
it looks like close to what Im looking for, but how to use it ?
Last edited by alf2314 on 25 Sep 2022, 06:54, edited 2 times in total.

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Create hotkey to adjust brightness on specific level

Post by mikeyww » 25 Sep 2022, 06:54

Have you run the script to test it? What happens when you run the script?
Last edited by mikeyww on 25 Sep 2022, 06:56, edited 2 times in total.

alf2314
Posts: 56
Joined: 05 Sep 2022, 13:29

Re: Create hotkey to adjust brightness on specific level

Post by alf2314 » 25 Sep 2022, 06:55

mikeyww wrote:
25 Sep 2022, 06:54
Have you run the script to test it? What happens when you run the script?
yes sir, it runs brightness up from 20 to 100 step by step , for about 3 seconds

to 60, Im sorry
Last edited by alf2314 on 25 Sep 2022, 06:56, edited 1 time in total.

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Create hotkey to adjust brightness on specific level  Topic is solved

Post by mikeyww » 25 Sep 2022, 06:56

So you have your answer, right?

Code: Select all

F6::changeBrightness(33)
F7::changeBrightness(66)
F8::changeBrightness(99)

changeBrightness(ByRef brightness, timeout := 1) {
 For property in ComObjGet("winmgmts:\\.\root\WMI").ExecQuery("SELECT * FROM WmiMonitorBrightnessMethods")
  property.WmiSetBrightness(timeout, brightness := Max(0, Min(brightness, 100)))
}

alf2314
Posts: 56
Joined: 05 Sep 2022, 13:29

Re: Create hotkey to adjust brightness on specific level

Post by alf2314 » 25 Sep 2022, 07:00

mikeyww wrote:
25 Sep 2022, 06:56
So you have your answer, right?

Code: Select all

F6::changeBrightness(33)
F7::changeBrightness(66)
F8::changeBrightness(99)

changeBrightness(ByRef brightness, timeout := 1) {
 For property in ComObjGet("winmgmts:\\.\root\WMI").ExecQuery("SELECT * FROM WmiMonitorBrightnessMethods")
  property.WmiSetBrightness(timeout, brightness := Max(0, Min(brightness, 100)))
}
wow
THAT
1) looks simple
2) looks nice
3) it works
4) can be converted easily into .EXE

Thakn you so much ! That is amazing !

what a brilliant code !
thanks , going to work with it. I think this is revolutionary , I cant believe no one posted any similar code before , with such simplicity and without overburden stuff, like ACDC getting info and similar.
Just straight brightness adjustment with nothing excess.

thanks, pure magic

how can anyone mot skilled (like me) get into this monster
and now compare it to ths solution here.
thats phenomenal
I so enjoy using it, it works superbly

Post Reply

Return to “Ask for Help (v1)”