Map "fn" + "home" to screen brightness using AutoHotKey?

3

1

Could someone please show me what script code I would need to map my laptop "fn" key + "home" to lower the screen brightness (and subsequently "fn" + end to increase).

I know I can reach the screen brightness using this control panel link:

Control Panel\Hardware and Sound\Power Options

but I don't know how I could get the "screen brightness" scrollbar to move horizontally each time I press ?

mezamorphic

Posted 2013-09-28T22:56:58.000

Reputation: 219

Answers

4

Autohotkey offers a great possibility to find the "number" of the key:

If your keyboard or mouse has a key not listed above, you might still be able to make it a hotkey by using the following steps (requires Windows XP/2000/NT or later):

  1. Ensure that at least one script is running that is using the keyboard hook. You can tell if a script has the keyboard hook by opening its main window and selecting "View->Key history" from the menu bar.
  2. Double-click that script's tray icon to open its main window.
  3. Press one of the "mystery keys" on your keyboard.
  4. Select the menu item "View->Key history"
  5. Scroll down to the bottom of the page. Somewhere near the bottom are the key-down and key-up events for your key. NOTE: Some keys do not generate events and thus will not be visible here. If this is the case, you cannot directly make that particular key a hotkey because your keyboard driver or hardware handles it at a level too low for AutoHotkey to access. For possible solutions, see further below.
  6. If your key is detectible, make a note of the 3-digit hexadecimal value in the second column of the list (e.g. 159).
  7. To define this key as a hotkey, follow this example:

    SC159:: ; Replace 159 with your key's value.
    MsgBox, %A_ThisHotKey% was pressed.
    return

So it's very easy to find the numbers of your keys and script a shortcut to increase the brightness.

Christian

Posted 2013-09-28T22:56:58.000

Reputation: 6 571

4Except that it almost certainly won’t work because in pretty much every system made in the past decade or two, the Fn key is a special case handled internally in the keyboard controller hardware and does not go through software. Therefore, it cannot be intercepted or remapped. – Synetech – 2014-07-21T22:11:50.210

3@c0Ddev i have tried this and I see various combinations of fn+key that work but others like brightness don't do show up there. – Herman Toothrot – 2014-09-07T11:05:34.613

Not possible for me. That trick worked: VOLUME_DOWN::F11 F11::VOLUME_DOWN

VOLUME_UP::F12 F12::VOLUME_UP

MEDIA_PLAY_PAUSE::F9 F9::MEDIA_PLAY_PAUSE Source: https://gist.github.com/tehshane/8765405

– JinSnow – 2015-01-12T07:55:16.053

This could be useful for some (works for voulme up and down, but couldn't make it works for brightness) INS & F11::Send {vkAEsc12E} INS & F12::Send {vkAFsc130}. This causes Numpad0 to lose its original/native function when it is pressed by itself. To avoid this, a script may configure Numpad0 to perform a new action such as one of the following. Thus you can add then: INS::Send {INS} – JinSnow – 2015-01-12T08:22:28.663

if there's some special feature printed on the Home key (i.e. same color with Fn key) then Fn+Home will work, but it's capturing the key combo and send the special key's scan code and not Fn key's scan code plus Home scan code. You can't capture Fn alone – phuclv – 2018-07-04T09:40:49.600

3

Fn

key problem

You will not likely be able to use Fn+Home because the Fn is usually a special key that is handled internally by the keyboard controller. Because it is handled in hardware and never goes through software (i.e., the OS), it cannot be intercepted or remapped. You’ll have to pick another hotkey combo (try the ⊞ Win key or something).

SmartBright

If you are willing to pick another hotkey, then there are ways to provide easier access to the screen brightness. One option is the SmartBright script on the AutoHotkey forums. It lets you adjust the brightness of the screen with the mouse by creating a click-through overlay. Because of the way it works, it does not actually affect the backlight that you see in the Control Panel’s Power Options. This could be a problem or a benefit depending on your situation. In fact, because it works independently of the main brightness control, you can use it in conjunction with the main control to further reduce the brightness beyond what is available with the backlight control by itself (some people complain that the minimum brightness is still too bright).

nircmd

Another option is what I have been using for the past several years. It is just two lines of AutoHotkey code that set up a hotkey to call out to Nirsoft’s nircmd to allow me to adjust the screen backlight:

; Screen brightness
; Ctrl+Alt+Shift + PgUp/PgDown to adjust screen brightness
^!+PgUp::Run nircmd.exe changebrightness +10
^!+PgDn::Run nircmd.exe changebrightness -10

Make sure that nircmd.exe is in the same directory as the script and it works perfectly. The only problem is that if you run it under a user account, it won’t work while programs running under the administrator account are active (e.g., the log in screen). That’s fixable, but rarely necessary.

Synetech

Posted 2013-09-28T22:56:58.000

Reputation: 63 242

is it possible to apply smartbright to a keyboard shortcut? – Herman Toothrot – 2014-09-07T11:06:23.730

setbrightness 0 doesn't turn my laptop's screen off, like on a Macbook. – Shayan – 2019-04-17T07:31:14.443