Consoles - Newbie Alert
BlitzPlus Forums/BlitzPlus Beginners Area/Consoles - Newbie Alert
| ||
Hi, I am making a blitz compression program that I would like to run from the command line and so I want to use it in a console. However I get to a stage where it finishes compressing the file and it displays a compression report. From here I want the program to end once the user has acknowledges the completion by pressing any key. However, the WaitKey() command won't work in a console window. I have tried to get around it by drawing a small graphics window which waits for the "WaitKey()" event but it only works if that window is in focus so you have to click onto it from the console window. I would like to use a console window because I can write data to the screen and retreive user input using the "Input$()" command. Have you got any ideas as to how I could get the program to halt until any key is pressed? I could do it with an enter key by doing a Input$("") command but I would prefer it without doing this as people can therefore type things onto the screen. Any help is greatly appreciated Seb |
| ||
You might try this in your event handler loop:;main loop to handle events Repeat enterkey = GetAsyncKeyState($0D) ;if enter key just pressed then LSB of enterkey is set seperatorkey = GetAsyncKeyState($6C) ;if numpad enter key just pressed then LSB of seperatorkey is set tabkey = GetAsyncKeyState(9) ;if tab key just pressed then LSB of tabkey is set If (tabkey Or enterkey Or seperatorkey) And 1 Then DoSomething() ;checks keys least sig. bit=1 event = WaitEvent() If event = $401 ;gadget action ;etc... which requires this declaration: .lib "user32.dll" GetAsyncKeyState%(virtualkeycode%):"GetAsyncKeyState" |
| ||
Interesting ^_^ .. I never went into the depths of those userlibs. All the time I had lousy key events that lost focus. But afaics it works with ascii codes (13 for [enter], 65 for [A] etc.).. how do I read out things like cursors, F-keys, pageUp/Dn, ins, del, home, alt/shift/ctrl combinations etc. etc.? |
| ||
Found the cursors and stuff, but I can't seem to make a clean function that works like KeyHit and KeyDown.. meaning that I wish to know which key is *hit*, and which combikey(s) is/are *down*.. Anyone a suggestion? |
| ||
fixed ^_^ 'ave phun |