Can I use getch from msvcrt.dll?
Blitz3D Forums/Blitz3D Beginners Area/Can I use getch from msvcrt.dll?
| ||
Hi, I want to use getch + kbhit from msvcrt.dll, but for some reason I only get 0, so probably I'm doing something really wrong. Any ideas?While Not KeyHit (1) Delay (100) ;result=CallDLL( "msvcrt.dll","kbhit") ;result was always 0, tried too with "_kbhit" result=CallDLL( "msvcrt.dll","getch") DebugLog result Wend Thanks. |
| ||
why dont you use waitkey() ? |
| ||
Anyway, you need a .decls file in order to use a dll. Take a look at This! |
| ||
Hi, thanks for your reply. Waitkey will work for kbhit, just wanted to try that dll thing. As for getch, I want to use it as it doesn't pauses the loop and I don't know which key the user will press, but I need to know afterwards. I wrote following .decls: .lib "msvcrt.dll" getch#():"_getch" and for code: While Not KeyHit (1) WaitKey() result=getch() DebugLog result Wend but still not returning valid value (geting -2147483648) . Is there something else I am missing? Thanks |
| ||
It could be the conversion from float to integer ? Maybe you could try getch%():"_getch" instead in the .decls |
| ||
You can use something like this to get which key is pressed.pressedKey = GetKey() |
| ||
Hi, thank you both. I went the GetKey route. My only concern is that i wasn�t able to use the .decls file. Indeed getch shall return ints, buts for some reason jsut getting -1 now. anyhow Getkey() shall do the trick. Thanks again. |