The following has been tested under macOS Sierra 10.12.5 and macOS High Sierra 10.13.3, and works without any issue on my system.
Using the example AppleScript code, from my original answer, saved as an AppleScript application named Flip Display 180° and added to System Preferences > Security & Privacy > Privacy > Accessibility, so as to allow it to process the code, I then used an Automator service workflow, also named Flip Display 180°, to open the AppleScript application of the same name, while assigning the following keyboard shortcut: ⇧⌃⌘R
Note that the keyboard shortcut ⇧⌃⌘F, which worked under OS X 10.8.5, conflicted with a system default keyboard shortcut under macOS 10.12.5, macOS 10.13.3 and why I changed it. You may have to use a different keyboard shortcut and as usual you have to choose one that isn't already assigned in any application that has focus when pressed to activate this Automator service workflow.
I also ran the following command, in Terminal, so as not to show the Dock Tile for the AppleScript application on the Dock:
defaults write '/Applications/Flip Display 180°.app/Contents/Info.plist' LSUIElement -bool yes
That said, if the UI for Displays in System Preferences in macOS High Sierra on your system different for some undisclosed reason then the example AppleScript code will need to be modified to accommodate the the differences between what works on my system and yours. If it does need to be modified, I'd imagine it wouldn't be that hard to figure out.
The following images show the relevant details:
System Preferences > Displays > Display, as shown on my system:
AppleScript application, named Flip Display 180°:
Automator service workflow, also named Flip Display 180°:
open -a 'Flip Display 180°'
System Preferences > Security & Privacy > Privacy > Accessibility:
System Preferences > Keyboard > Shortcuts > Services > General > Flip Display 180°
For the time being I'm leaving my original answer at the bottom portion of this answer as it does work as stated under OS X 10.8.6 and may be beneficial for other users.
I know you are using macOS High Sierra and maybe you can use what works for me under OS X 10.8.6.
The following example AppleScript code used in a Run AppleScript action in an Automator service workflow flips the Display 180° when I press: ⇧⌃⌘F
if running of application "System Preferences" then
quit application "System Preferences"
tell application "System Preferences"
reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
tell application "System Events"
tell pop up button "Rotation:" of tab group 1 of window 1 of application process "System Preferences"
if (value) contains "Standard" then
click menu item "180°" of menu 1
click menu item "Standard" of menu 1
set wasClicked to false
repeat until wasClicked
tell application "System Events"
click button "Confirm" of sheet 1 of window 1 of application process "System Preferences"
set wasClicked to true
- Note that the value of the
delay commands 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.
Note: The example AppleScript code is just that and does not employ any other error handling then what's shown 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.
Automator service workflow: