Program mouse and keyboard movements to be run with input on Mac

This is a very specific question. I’m running a gaming server for my friends and I to play on (on my old iMac that I just use as an external monitor for my MacBook Pro now), and I have a firewall in place to prevent any unwanted IP addresses accessing the port. I have a whitelist with all my friends’ IP addresses so they are the only ones allowed to access the server. The problem is, their IP addresses can change without notice and then it’s a hassle for me to get them to tell me their new IP and input it into the NetBarrier firewall program. Is there some way I get a program or code something to, when one of my friends iMessages me a code word or something followed by their updated IP, make my mouse and keyboard navigate through the firewall software and add the new IP to the whitelist?

Esssentialy, I need a way to detect when I receive a text with a key word (maybe: “UPDATEDIP: ” followed by the new IP), extract the IP from that message, have the mouse perform some movements & clicks to get through the firewall software and add a new whitelisted IP, and paste in the IP that it got from the message?