Originally Posted by Mercury048
You do not need to send the ALT key "constantly".
The way keyboards work (simplified version) is that the OS sees a scancode for the "keydown" event (when the user presses a key). This scancode is repeated at a constant rate as long as the key is held down, but this is not necessary to make the OS think the key is down. When the user releases the key the OS sees a "keyup" scancode for that key and only then does it consider they key to be released.
So what you want to do is send an ALT keydown scancode (this can be done via SendInput or the - deprecated, but simpler - keybd_event functions in the Win32 API) to make the OS (and hence your program) think the ALT key is down. Then just send the keyup scancode when you're done.
Caveats:
If you actually press the real ALT key on the keyboard it will generate a keydown and keyup scancode so the ALT will be released.
If the program in question does something really weird with the keyboard (e.g. tracks the state of the ALT key independently of the OS) then the above may not work as expected.
ETA: Yes, this can be done in plain C.