Mat Posted January 14, 2010 Posted January 14, 2010 (edited) kk, I'm trying to get a nice Console UDF going based on the initial work here, and then followed up by the work here after the raw reading method was removed from AutoIt. I have the basic function (_ConsoleReadLine) sorted now, and am moving on to some other functions that are useful when trying to make a console app. One of the first I considered was _ConsoleWait, which will mimic the standard "Press any key to continue..." by writing that text to the console and then waiting for user input. I expected using a parameter of 1 for max bytes to read in ReadFile to return as soon as 1 byte of data had been submitted, so wrote the following:Func _ConsoleWait() If Not @Compiled Then Return SetError(1, 0, 0) ; Not compiled ConsoleWrite("Press any key to continue...") Local $tBuffer = DllStructCreate("char"), $nRead Local $hFile = _WinAPI_CreateFile("CON", 2, 2) _WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), 1, $nRead) If DllStructGetData($tBuffer, 1) <> @CR Then ConsoleWrite(@CR) _WinAPI_CloseHandle($hFile) EndFunc ;==>_ConsoleWaitHowever, it only returns from the readfile function once the user has hit enter. The question is this: How would I detect any keypress?I hope this doesn't end up like my last question, which I will no doubt be bumping for the second time at 10:00...Mat Edited January 14, 2010 by Mat AutoIt Project Listing
PsaltyDS Posted January 14, 2010 Posted January 14, 2010 I hope this doesn't end up like my last question, which I will no doubt be bumping for the second time at 10:00...MatWhat about your last question? It got answered... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Mat Posted January 14, 2010 Author Posted January 14, 2010 I knew by complaining in here about it not getting answered someone would answer it! Maybe I'll just have to wait for a while and link to here when I ask my next question! Mat AutoIt Project Listing
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now