AutoHotkey Community

It is currently May 26th, 2012, 4:23 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: March 25th, 2009, 5:03 am 
Offline

Joined: April 19th, 2007, 8:05 am
Posts: 48
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 25th, 2009, 9:12 am 
[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 ... 85%29.aspx
[/OT]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 25th, 2009, 9:17 am 
OR ...
feel free to have a try to translate the string/URL with Autohotkey. 8)
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).


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 25th, 2009, 10:30 am 
Offline

Joined: April 19th, 2007, 8:05 am
Posts: 48
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 25th, 2009, 11:05 pm 
Offline

Joined: September 20th, 2006, 2:05 pm
Posts: 73
I humbly second that request for IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2009, 12:52 pm 
Offline

Joined: September 20th, 2006, 2:05 pm
Posts: 73
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)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2009, 1:45 pm 
Offline

Joined: July 9th, 2009, 9:25 pm
Posts: 120
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 September 26th, 2009, 2:25 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2009, 2:16 pm 
Offline

Joined: September 20th, 2006, 2:05 pm
Posts: 73
Doesn't work :(
I am on a desktop LCD (AC power). Don't have a laptop.

Msgbox Output:

Code:
1
Errorlevel :  0
Last Error:  0


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2009, 2:27 pm 
Offline

Joined: July 9th, 2009, 9:25 pm
Posts: 120
Try the code again (fixed NumPut offsets).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2009, 2:35 pm 
Offline

Joined: September 20th, 2006, 2:05 pm
Posts: 73
Same output and no effect. Perhaps my LCD doesn't support backlight control.

Can anyone else test this too?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2009, 5:49 pm 
Thanks for al the help temp0 :). I hope we figure this out someday.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2009, 10:21 pm 
Offline

Joined: February 7th, 2009, 11:28 pm
Posts: 384
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 27th, 2009, 12:00 am 
Offline

Joined: July 9th, 2009, 9:25 pm
Posts: 120
I think what you want is SetMonitorBrightness not IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2010, 7:15 pm 
Offline

Joined: September 6th, 2010, 7:11 pm
Posts: 1
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2010, 3:56 pm 
Offline

Joined: October 20th, 2010, 11:48 am
Posts: 4
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?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Cerberus, poserpro, SKAN, tterB and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group