My query is very similar to: Can a Mac be programmed to simulate pressing a key at a certain rate via software? whereby need to have script, so the Macbook won't lock automatically (caffienate -t is not working due to policy). The keystroke also needs to be a safe key (like SCROLL LOCK2 or very passive key) which doesn't do any harm.
Do you know how to replace the keystroke of SCROLL LOCK2 or "fn" key via command
# below one just inserts "fn" characters, which is dangerous
echo "set i to 0
repeat while i < 15
set i to i + 1
delay 5
# Trying out fn key, but not sure what is the keystroke value of it?
tell application \"System Events\" to keystroke \"fn\"
end repeat" | osascript

X, & you think in order to achieveXyou must doY. However you don't know how to doY, so you ask how to do that… when in fact what you needed to do wasX. – Tetsujin Jun 07 '21 at 12:33Yof the XY problem. – Tetsujin Jun 07 '21 at 12:43