Maybe this might help? https://www.caffeine-app.net
#!/usr/bin/swift
import Foundation
import AppKit
let source = CGEventSource(stateID: CGEventSourceStateID.hidSystemState)
CGEvent(keyboardEventSource: source, virtualKey: 0x37, keyDown: true)?.post(tap: .cghidEventTap)
CGEvent(keyboardEventSource: source, virtualKey: 0x37, keyDown: false)?.post(tap: .cghidEventTap)
This simulates one press/depress of the command key (0x37). The rest of the key codes can be found in Events.h in the location of your MacOS SDK library (deep in Xcode usually).Add it to a cron job or whatever.