flat assembler
Message board for the users of flat assembler.
Index
> Windows > help please |
Author |
|
revolution 10 Apr 2009, 12:36
Try this:
Code: string2 DB "console-",13,10 ... invoke WriteConsole,[outhandle],string2,10,numwritten,0 When you read characters from the input buffer it is up to your code to test for whatever exit conditions you need. |
|||
10 Apr 2009, 12:36 |
|
Dreamz 10 Apr 2009, 12:40
thank you sooooooo much!
|
|||
10 Apr 2009, 12:40 |
|
asmcoder 10 Apr 2009, 12:48
[content deleted]
Last edited by asmcoder on 14 Aug 2009, 14:52; edited 1 time in total |
|||
10 Apr 2009, 12:48 |
|
Dreamz 10 Apr 2009, 16:51
kk, thanks
o and how do you exactly, say if press "b" then it closes, how would you do that? thanks |
|||
10 Apr 2009, 16:51 |
|
asmcoder 10 Apr 2009, 17:16
[content deleted]
Last edited by asmcoder on 14 Aug 2009, 14:52; edited 1 time in total |
|||
10 Apr 2009, 17:16 |
|
Dreamz 10 Apr 2009, 21:53
sry to bother you again but could you giv a short code example?
|
|||
10 Apr 2009, 21:53 |
|
bitshifter 10 Apr 2009, 22:49
Code: format PE console entry start include 'c:/program files/fasmw16738/include/win32ax.inc' section '.data' data readable writeable g_prompt db 'Input some characters, b <enter> to quit.',0x0D,0x0A g_prompt.length = $ - g_prompt g_written rd 1 g_read rd 1 g_stdin rd 1 g_stdout rd 1 g_input rb 1 section '.code' code readable executable start: invoke AllocConsole invoke GetStdHandle,STD_INPUT_HANDLE mov [g_stdin],eax invoke GetStdHandle,STD_OUTPUT_HANDLE mov [g_stdout],eax invoke WriteConsole,[g_stdout],g_prompt,g_prompt.length,g_written,NULL mloop: invoke ReadConsole,[g_stdin],g_input,1,g_read,NULL cmp [g_input],'b' jne mloop quit: invoke FreeConsole invoke ExitProcess,0x00 section '.idata' import data readable library kernel32,'kernel32.dll' include 'c:/program files/fasmw16738/include/api/kernel32.inc' _________________ Coding a 3D game engine with fasm is like trying to eat an elephant, you just have to keep focused and take it one 'byte' at a time. Last edited by bitshifter on 10 Apr 2009, 23:36; edited 1 time in total |
|||
10 Apr 2009, 22:49 |
|
bitshifter 10 Apr 2009, 22:55
asmcoder wrote: when you press b, system send WM_KEYDOWN to application window on wich u have focus. This is true for a normal windows app with a message pump and handling procedure, but with console app windows hides this from us. So Dreamz, you can ignore this, since it does not apply to your app. _________________ Coding a 3D game engine with fasm is like trying to eat an elephant, you just have to keep focused and take it one 'byte' at a time. |
|||
10 Apr 2009, 22:55 |
|
Picnic 11 Apr 2009, 00:40
Code: .data hIn dd ? EventCount dd ? NumRead dd ? EventBuffer db 16 dup 0 .code main: invoke GetStdHandle, STD_INPUT_HANDLE ; error? mov [hIn], eax @@: invoke Sleep, 1 invoke GetNumberOfConsoleInputEvents, [hIn], EventCount test eax, eax je @B invoke ReadConsoleInput, [hIn], EventBuffer, 1, NumRead ; error? cmp word [EventBuffer], 1 ; is a keyboard event ? jne @B cmp byte [EventBuffer+4], 1 ; is a keypress ? jne @B ; [EventBuffer+14] = ASCII character or zero (no ASCII key pressed) ; [EventBuffer+12] = control keys You can find small examples about console event handling here Dreamz, in C language but helpful. |
|||
11 Apr 2009, 00:40 |
|
Dreamz 11 Apr 2009, 12:54
thanks!
|
|||
11 Apr 2009, 12:54 |
|
Dreamz 11 Apr 2009, 15:20
sry for dble post, but thanks soo much again, this forum is soooo helpful and welcoming, so much better than all the others i hav visited
|
|||
11 Apr 2009, 15:20 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.