Execute a command in a PC

Hello there!

Right now I have a small personal project that I have looked for a thousand ways to complete and I have not been able to, I always get stuck in the programming part of Arduino.

My plan is the following, and I humbly ask for your help.

I want to be able to program an Arduino to perform a single action after receiving an input signal. Either from an open or closed circuit with the same pins of the Arduino Nano. (I know that part can be done, similar to a PLC, since I have done it) what I am missing is that when receiving that signal the Arduino activates a key or function in windows, which activates or triggers a task previously set with another program.

Example:
1-The power goes out in the house.
2-Through a NO (normally open) or NC (normally closed) circuit using the same Arduino with a relay, the input signal that warns of the power failure is sent.
3-The Arduino executes as output signal a function or command in the PC, for example "press F6".
4-That the action is repeated when the power returns to the house, like when the input signal is interrupted or returns to its primary state of rest.

The Arduino Leonardo (or other board with the ATmega32u4 processor) can act as a USB keyboard that could send a key to the PC. The code on the PC is beyond the scope of this Arduino forum.

See here.

It's not easy but it's been talked about before. Check out this thread:
Make Arduino execute commands on computer? - Software / Interfacing - Arduino Forum

What programming languages do you know?
Python perhaps?

This is a very simple serial receive method for python:
Arduino Python Communication Via USB : 4 Steps - Instructables

You can combine that with this method of executing commands:
Execute External Programs, the Python Ways. | Algorithms, Blockchain and Cloud (helloacm.com)

Then use any Arduino to execute command line arguments or launch programs.
Here you can get help with the Arduino, if you need help with the python I recommend python-forum.io

Thank you both for the ideas and support, now I came up with a simple way to do it base on my knowledge, as simple as use an already created code for a simple keyboard using an Arduino with the ATmega32u4 processor, and instead of using keys, replacing them with a relay circuit that opens and closes depending on the situation. Thanks again.

Cool. Please post your schematic and code here so other users can benefit too.

Happy Programming!

Will do as soon as I complete them