flat assembler
Message board for the users of flat assembler.
Index
> Main > kbhit((())) AKA INKEY$$$ |
Author |
|
DOS386 08 Jul 2011, 07:30
. .
. . ( if you got a bad link : TESTCMD package ) . . . . Just in case someone cares about ASM too ( see t=5309 "Reading keypresses with C" ) I brewed an example: Download now 90'282 Byte's Shots: Works well with HX , ME , XP and Wi$ta Code: ; SSKBHIT ; In : - EDI : ZERO is "LH" , non-ZERO is "EH" ; Trashes : - EAX ECX EDX ; Out : - AL : Scancode 0 to 253, other event 254, no event 255 ; - AH : Special key and LED bits (valid for AL<254, else ZERO) ; Needs 52 Byte's on stack : ; 4 (EBX) + 4 (check) + 20 (RCI buffer) + 24 (RCI params) ; Will in any case eat away all events, so to initialize, ; just call this too and ignore the result ; We will simply do "ReadConsoleInput" as long as there is something ; available to read previously checked by "GetNumberOfConsoleInputEvents", ; because "ReadConsoleInput" hangs if no events available ; Keyboard event is 1, other possible events include rat and focus. ; EventType 16 | Must be = 1 | (+ ZERO) ; BuggerAll 16 ??? ; bKeyDown 32 | Only 1 bit is useful ??? ; wRepeatCount 16 ??? ; wVirtualKeyCode 16 ??? ; wVirtualScanCode 16 | <<-- HERE | (+ 12 Byte's) ; AsciiChar 16 ??? ; dwControlKeyState 32 | Only 5 or 8 or 9 bits useful | (+ 16 Byte's) ; -------------------- ; Total 5 UINT32's = 20 Byte's = 160 Bits ; RIGHT_ALT_PUSHED $0001 ; LEFT_ALT_PUSHED $0002 ; RIGHT_CTRL_PUSHED $0004 ; LEFT_CTRL_PUSHED $0008 ; SHIFT_PUSHED $0010 ; NUMLOCK_ON $0020 ; SCROLLLOCK_ON $0040 ; CAPSLOCK_ON $0080 ; ENHANCED_KEY $0100 ; Scancodes : ; $2A SHIFT left ; $36 SHIFT right ; $1D CONTROL both !!! ; $38 ALT both !!! ; HX : ; - RIGHT_ALT 1 also sets LEFT_CONTROL 8 giving 9 !!! ; - "Printscreen" is taken but strange ; - "Pause Break" is taken but strange ; - "Power" OK ; - Rat completely ignored ; ME : ; - "Printscreen" is taken but strange ; - Left and right rat button taken, movements too, wheel ignored ; XP : ; - "Printscreen" is ignored ; - "Power" is taken but very evil ; - Left rat button, wheel and movements ignored ; - Right rat button taken but very strange ; Wi$ta : ; - Left rat button, wheel and movements ignored ; - Right rat button taken but less strange sskbhit: push ebx pushd 111 ; Check value UINT32 111 sub esp, 20 ; Buffer movntq ebx, 0 dec bl ; MOVNTQ EBX,255 | Get AL=255 and AH=ZERO pushd $FFFF'FFF6 ; "-10" means "stdin" call dword [GetStdHandle] ; $FFFF'FFFF is invalid (if no console ?) inc eax ; CMPNTQ EAX, $FFFF'FFFF jz short after_rd_loop ; Console got shot by some gun geek ??? dec eax ; Is ZERO valid or not ??? event_read_loop: push eax ; Hendaye backup (NOT for the call) push eax ; CRAP (NOT "directly" for the call) push esp ; Out variable address (!) (for the call) push eax ; Hendaye for call call dword [GNOCIE] ; Uses 2 arguments pope ecx ; Amount of events pope eax ; Hendaye restore | Now stack fine (-2 cmpntq ecx, 0 je short after_rd_loop ; No more events, exit the loop mov ecx, esp ; Backup address before PUSH'ing !!! push eax ; Hendaye backup (NOT for the call) push eax ; CRAP (NOT "directly" for the call) push esp ; Out var address (!) (for the call) pushd 1 ; Amount of records (!) to read push ecx ; Buffer (20 Byte's hopefully) push eax ; Hendaye for call call dword [ReadConsoleInput] ; Uses 4 arguments Yeah Another one: http://board.flatassembler.net/topic.php?t=1953 Last edited by DOS386 on 10 Apr 2013, 13:34; edited 5 times in total |
|||
08 Jul 2011, 07:30 |
|
idle 08 Jul 2011, 08:09
zipped tar - why?
did uoy expect a one to ask |
|||
08 Jul 2011, 08:09 |
|
vid 02 Aug 2011, 13:25
Doesn't work for PrintScreen or Pause
Quote: define pope pop This never gets old |
|||
02 Aug 2011, 13:25 |
|
DOS386 02 Aug 2011, 13:26
vid wrote: Doesn't work for PrintScreen or Pause RTFS (or tell me what OS you tested). |
|||
02 Aug 2011, 13:26 |
|
vid 02 Aug 2011, 13:31
WinXP 32-bit
|
|||
02 Aug 2011, 13:31 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.