How do I make my Arduino do a specific action when the computer is locked/unlocked?
Read a value through serial (what exactly is entirely up to you) to do the same job the button does now.
Use Serial.read() to get that data, and Serial.available() to know if there is any data to read.
How you generate that value on the PC to send through serial we cannot help you with, as that is outside the scope of this site.