App to toggle automatic brighness adjustment?
If I wanted to have a Menu bar app that could toggle the check box for Automatically adjust brightness on the Display tab of Displays in System Preferences, this is how I do it...

Using modified code from this answer for the wrapper and adding in the additional code to achieve the desired functionality and goal, here is the example AppleScript code:

-- # Acknowledgment: Some of the code used herein is modified code from the following answer:
-- # https://apple.stackexchange.com/questions/293307/applescript-run-from-menu-bar/293392#293392

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property aStatusItem : missing value

on run
    init() of me
end run

on init()
    set aList to {"Toggle - Automatically Adjust Brightness", "", "Quit"}
    set aStatusItem to current application's NSStatusBar's systemStatusBar()'s statusItemWithLength:(current application's NSVariableStatusItemLength)
    aStatusItem's setTitle:"☀️"
    aStatusItem's setHighlightMode:true
    aStatusItem's setMenu:(createMenu(aList) of me)
end init

on createMenu(aList)
    set aMenu to current application's NSMenu's alloc()'s init()
    repeat with i in aList
        set j to contents of i
        if j is not equal to "" then
            set aMenuItem to (current application's NSMenuItem's alloc()'s initWithTitle:j action:"actionHandler:" keyEquivalent:"")
        else
            set aMenuItem to (current application's NSMenuItem's separatorItem())
        end if
        (aMenuItem's setTarget:me)
        (aMenu's addItem:aMenuItem)
    end repeat
    return aMenu
end createMenu

on actionHandler:sender
    set aTitle to title of sender as string
    if aTitle is not equal to "Quit" then
        my clickAutomaticallyAdjustBrightness()
    else
        current application's NSStatusBar's systemStatusBar()'s removeStatusItem:aStatusItem
        tell current application to quit
    end if
end actionHandler:

on clickAutomaticallyAdjustBrightness()
    if running of application "System Preferences" then
        quit application "System Preferences"
        delay 1
    end if
    tell application "System Preferences"
        reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
        delay 1
        tell application "System Events"
            tell group 1 of tab group 1 of window 1 of application process "System Preferences"
                click checkbox "Automatically adjust brightness"
                set isChecked to (value of checkbox "Automatically adjust brightness") as boolean
            end tell
        end tell
        quit
    end tell
    if isChecked then
        display dialog "      Automatically adjust brightness is checked." buttons {"OK"} default button 1 ¬
            with title "Toggle - Automatically Adjust Brightness" giving up after 5
    else
        display dialog "   Automatically adjust brightness is not checked." buttons {"OK"} default button 1 ¬
            with title "Toggle - Automatically Adjust Brightness" giving up after 5
    end if
end clickAutomaticallyAdjustBrightness



Note that the value of the delay command(s) may need to be adjusted for your system, and or additional delay commands may or may not be needed. Adjust values of and or add/remove the delay commands as appropriate. 


Copy and paste the example AppleScript code shown above into a new document in Script Editor, saving it as an application, e.g. Toggle - Automatically Adjust Brightness and check the [√] Stay open after run handler check box while saving it.

Then in Terminal, run the following command to hide the Dock Tile on the Dock for the e.g. Toggle - Automatically Adjust Brightness application:

defaults write '/Applications/Toggle - Automatically Adjust Brightness.app/Contents/Info.plist' LSUIElement -bool yes


Now add the e.g. Toggle - Automatically Adjust Brightness application to:

System Preferences > Security &amp; Privacy > Privacy > Accessibility

While checking its check box.

Now the e.g. Toggle - Automatically Adjust Brightness application is ready to run and all that will appear is a yellow icon of the sun on the Menu bar and no Dock Tile on the Dock.









The e.g. Toggle - Automatically Adjust Brightness application will toggle checking and unchecking the check box for Automatically adjust brightness on the Display tab of Displays in System Preferences and display a dialog box afterwards.

The display dialog commands could be replaced with display notification commands if you prefer that instead.

Also note that this method does not work with all version of OS X/macOS however it should work with at least 10.11 and newer.



Note: The example AppleScript code is just that and does not employ any error handling and is meant only to show one of many ways to accomplish a task. The onus is always upon the User to add/use appropriate error handling as needed/wanted.