Using API to press a key
BlitzMax Forums/BlitzMax Programming/Using API to press a key
| ||
I'm looking for something to programmically press a keystroke. I have not been able to find anything on Google (yet). Can anyone help me? |
| ||
What are you trying to fool? BlitzMax or the OS? I think the correct term ( or *one* correct term, anyway ) is synthetic keyboard events, but I'm not sure if it's even possible at the OS level. |
| ||
I'm not trying to fool anything, I'm trying to create a macro system, you can record keyboard and mouse events, then play them back, I just want to be able to do something like this, only for the keyboard. |
| ||
I have a code example in the archives that clicks the mouse using Windows' SendInput function. You could modify this to insert keyboard events. Do a search for MSDN + Sendinput on google. |
| ||
Alternatively try a search for "AutoIT" on these forums. It may be of use I'm told. |
| ||
While searching for what nomen luni told me to, I found this. Now I just need to get all the variables for the keys. I dunno where y'all come up with all these api variables, but I'd sure like to get them for this. |
| ||
Found the variables, source |
| ||
I'm getting this error: Compile Error: Missing type specifier on the dwFlags variable for keybd_event function. I searched MSDN to find the type for this and it is a "DWORD", however I noticed that DWORD is not a valid variable type in Max. Does anyone know what the Max equivalent to a DWORD is? |
| ||
DWord is a double word=2*16 bits, which is a an unsigned long in Blitz I think (or a long will do). Would you consider sticking your function in the code archives when it's done? Could be useful for me! : ) |
| ||
Here is the completed version, please post bugs and improvements. Virtual Keys |
| ||
OK thanks Plash! |
| ||
No problem. |