title: How to make the display sleep and wake
body: <p>There is a problem with the backlight of my mac. Sometimes when I turn it on the backlight does not come on. However if I manually force the screen to sleep and wake a couple of times it does light up. So I want to write an applescript to automate this process.
  I have looked at ...
  <a href="https://stackoverflow.com/questions/10598809/how-do-i-wake-from-display-sleep-in-osx-10-7-4">How do I wake from display sleep in OSX 10.7.4?</a>
  But that is not written in Applescript (or if it is I cannot figure out how to run it.</p>
  
  <p>I have tried the following </p>
  
  <pre><code>do shell script "pmset displaysleepnow"
  tell application "Google Chrome"
  activate
  end tell
  do shell script "pmset displaysleepnow"
  tell application "Google Chrome"
  quit
  end tell
  </code></pre>
  
  <p>But the screen blanks and never relights. I have also tried using caffeine as per some questions about this. I have tried using code to move the mouse and/or click the mouse programmatically.</p>
  
  <p>If I just run the displaysleepnow followed by the 'activate chrome' that works, but if the displaysleepnow is executed again nothing appears to reactivate it.</p>
  
  <p>I am using macOS 10.14.4</p>