AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to adjust display brightness? (I'm sure it's possible)
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
dvda2k



Joined: 19 Apr 2007
Posts: 45

PostPosted: Wed Mar 25, 2009 4:03 am    Post subject: How to adjust display brightness? (I'm sure it's possible) Reply with quote

In Vista and Win 7, you can press Win + X to use Windows Mobility Center to adjust your LCD backlight. Windows Mobility Center talks to your graphics driver.

I searched MSDN and found some articles talking about "Backlight Control Interface". But I just don't know how to implement this code into Autohotkey.

Can anyone help? The MSDN link is here:
http://msdn.microsoft.com/en-us/library/aa372656(VS.85).aspx
Back to top
View user's profile Send private message
BoBo³
Guest





PostPosted: Wed Mar 25, 2009 8:12 am    Post subject: Reply with quote

[OT]
OK. We often see 'half-converted' URLs used within the forum, like the following one (taken from above):
http://msdn.microsoft.com/en-us/library/aa372656(VS.85).aspx

The reason is the use of special characters, here ---> ( ), which won't be translated by the forum software phpBB. A quick one to help yourself is to drop the link into Google and search for it. You can extract the (now) converted special characters afterwards from the (converted) link which is shown at the address bar.
http://msdn.microsoft.com/en-us/library/aa372656%28VS.85%29.aspx
[/OT]
Back to top
BoBo³
Guest





PostPosted: Wed Mar 25, 2009 8:17 am    Post subject: Reply with quote

OR ...
feel free to have a try to translate the string/URL with Autohotkey. Cool
Quote:
HTML, String: Converts String into its HTML equivalent by translating characters whose ASCII values are above 127 to their HTML names (e.g. £ becomes &pound;). In addition, the four characters "&<> are translated to &quot;&amp;&lt;&gt;. Finally, each linefeed (`n) is translated to <br>`n (i.e. <br> followed by a linefeed).
Back to top
dvda2k



Joined: 19 Apr 2007
Posts: 45

PostPosted: Wed Mar 25, 2009 9:30 am    Post subject: Reply with quote

BoBo³, thanks for your reply. Fortunately the MSDN website has some error-proof feature, the broken URL still gets you to the right place.

Do you have any comment on my question itself?
Back to top
View user's profile Send private message
..:: Free Radical ::..



Joined: 20 Sep 2006
Posts: 72

PostPosted: Fri Sep 25, 2009 10:05 pm    Post subject: Reply with quote

I humbly second that request for IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS
Back to top
View user's profile Send private message
..:: Free Radical ::..



Joined: 20 Sep 2006
Posts: 72

PostPosted: Sat Sep 26, 2009 11:52 am    Post subject: Reply with quote

Code:

hLCD = CreateFile( "\\.\LCD" , #GENERIC_READ | #GENERIC_WRITE , #FILE_SHARE_READ | #FILE_SHARE_WRITE , #Null , #OPEN_EXISTING , #Null , #Null )

DeviceIoControl( hLCD , #IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS , #Null , #Null , MDB  , SizeOf ( MDB  ) , @ lReturnedBytes , #Null )

DeviceIoControl( hLCD , #IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS , SDB , SizeOf ( tDisplayBrightness ) , #Null , #Null , @ returnedBytes , #Null)


Can someone help me write the appropriate dllcall?
Code:

hLCD := DllCall("CreateFile", "str", "\\.\LCD", "Uint", 0, "Uint", 3, "Uint", 0, "Uint", 3, "Uint", 0, "Uint", 0)
SUPPORTED_BRIGHTNESS := DllCall("DeviceIoControl", "Uint", hLCD, "Uint", 0x125, "Uint", 0, "Uint", 0, "str", 0, "str", 256, "Uint", 0, "Uint", 0)
Back to top
View user's profile Send private message
temp01



Joined: 09 Jul 2009
Posts: 120

PostPosted: Sat Sep 26, 2009 12:45 pm    Post subject: Reply with quote

Does this work (I don't have an LCD monitor to test)? If not, what does the msgbox show?
Code:
hLCD := DllCall("CreateFile"
   , Str, "\\.\LCD"
   , UInt, 0x80000000 | 0x40000000  ; GENERIC_READ | GENERIC_WRITE
   , UInt, 0x1 | 0x2  ; FILE_SHARE_READ | FILE_SHARE_WRITE
   , UInt, 0
   , UInt, 0x3  ; OPEN_EXISTING
   , UInt, 0, UInt, 0)
if hLCD <> -1
{
   FILE_DEVICE_VIDEO := 0x00000023, METHOD_BUFFERED := 0, FILE_ANY_ACCESS := 0
   VarSetCapacity(DISPLAY_BRIGHTNESS, 3, 0)
      NumPut(0x03, DISPLAY_BRIGHTNESS, 0, "UChar")   ; 0x01 = Set AC, 0x02 = Set DC, 0x03 = Set both
      NumPut(50, DISPLAY_BRIGHTNESS, 1, "UChar")      ; The AC brightness level
      NumPut(50, DISPLAY_BRIGHTNESS, 2, "UChar")      ; The DC brightness level
   Msgbox % ""
   . DllCall("DeviceIoControl"
      , UInt, hLCD
      , UInt, (FILE_DEVICE_VIDEO<<16 | 0x127<<2 | METHOD_BUFFERED<<14 | FILE_ANY_ACCESS) ; IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS
      , UInt, &DISPLAY_BRIGHTNESS, UInt, 3
      , UInt, 0, UInt, 0
      , UIntP, dwBytesReturned  ; Unused.
      , UInt, 0) "`nErrorLevel:`t`t" ErrorLevel "`nLastError:`t`t" A_LastError
   DllCall("CloseHandle", UInt, hLCD)
}

(based on this code (remarks))


Last edited by temp01 on Sat Sep 26, 2009 1:25 pm; edited 1 time in total
Back to top
View user's profile Send private message
..:: Free Radical ::..



Joined: 20 Sep 2006
Posts: 72

PostPosted: Sat Sep 26, 2009 1:16 pm    Post subject: Reply with quote

Doesn't work Sad
I am on a desktop LCD (AC power). Don't have a laptop.

Msgbox Output:

Code:

1
Errorlevel :  0
Last Error:  0
Back to top
View user's profile Send private message
temp01



Joined: 09 Jul 2009
Posts: 120

PostPosted: Sat Sep 26, 2009 1:27 pm    Post subject: Reply with quote

Try the code again (fixed NumPut offsets).
Back to top
View user's profile Send private message
..:: Free Radical ::..



Joined: 20 Sep 2006
Posts: 72

PostPosted: Sat Sep 26, 2009 1:35 pm    Post subject: Reply with quote

Same output and no effect. Perhaps my LCD doesn't support backlight control.

Can anyone else test this too?
Back to top
View user's profile Send private message
FreeRadical
Guest





PostPosted: Sat Sep 26, 2009 4:49 pm    Post subject: Reply with quote

Thanks for al the help temp0 Smile. I hope we figure this out someday.
Back to top
pajenn



Joined: 07 Feb 2009
Posts: 384

PostPosted: Sat Sep 26, 2009 9:21 pm    Post subject: Reply with quote

Quote:
1
Errorlevel : 0
Last Error: 0


Same here. I can adjust my laptop LCD brightness with fn+f9/f10, but AHK cannot detect the 'fn' key (no sc/vk code) so I cannot remap it -- I'd prefer to use the mouse scroll wheel...
_________________
Hardware: 1.8 GHz laptop with 4 GB ram, Windows XP/SP3
Software: Prevx, Privatefirewall, KeyScrambler.
Back to top
View user's profile Send private message
temp01



Joined: 09 Jul 2009
Posts: 120

PostPosted: Sat Sep 26, 2009 11:00 pm    Post subject: Reply with quote

I think what you want is SetMonitorBrightness not IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS
Back to top
View user's profile Send private message
8



Joined: 06 Sep 2010
Posts: 1

PostPosted: Mon Sep 06, 2010 6:15 pm    Post subject: Reply with quote

Any ideas how to call DxgkDdiSetBrightness from AutoHotkey? (more info here)
IOCTL is deprecated in Vista/7 and mostly doesn't work anyway, but this method should be the same which is used in the mobility center.
Thanks.
Back to top
View user's profile Send private message
rcll



Joined: 20 Oct 2010
Posts: 4

PostPosted: Wed Oct 20, 2010 2:56 pm    Post subject: Reply with quote

Sorry to post in this old thread but I'm also looking for this solution.

The Fn keys on my laptop are signaled at BIOS level or something and seem impossible to remap using the HID DLL method to identify the keys.

Windows Mobility Center has a GUI brightness slider that corresponds to the same function, brightness up/brightness down. Can this be mapped to a hotkey?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group