Sign in to follow this  
Followers 0
Mat

_WinApi_ReadFile

3 posts in this topic

#1 ·  Posted (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   ;==>_ConsoleWait

However, 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 by Mat

Share this post


Link to post
Share on other sites



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

What about your last question? It got answered...

:D


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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0