flat assembler
Message board for the users of flat assembler.
  
|  Index
      > Windows > GetKeyState and Return Value | 
| Author | 
 | 
| asmhardy 17 May 2012, 07:00 Hello,
 The GetKeyState function retrieves the status of the specified virtual key. MSDN http://msdn.microsoft.com/en-us/library/windows/desktop/ms646301%28v=vs.85%29.aspx says: "If the high-order bit is 1, the key is down; otherwise, it is up ..." Why is the contents of register EAX: 0xFFFFFF80 or 0xFFFFFF81, when the SHIFT-Key is pressed? Why isn't 0x000008000? Can anybody explain to me please. Code: format PE GUI 4.0 include 'win32a.inc' ; ----------------------------------------------- section '.code' code readable executable ; ----------------------------------------------- start: invoke Sleep,100 invoke GetKeyState,VK_SHIFT cmp eax, 0 jnl start cinvoke wsprintf,buff,wsformat,eax invoke MessageBoxA,0,buff,title,0 invoke ExitProcess,0 ; ----------------------------------------------- section '.data' data readable writeable ; ----------------------------------------------- buff rb 100 title db 'Ausgabe ...',0 wsformat db "EAX -->> %08X",0 ;------------------------------------------------- section '.idata' import data readable writeable ;------------------------------------------------- library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL' import kernel32,\ ExitProcess,'ExitProcess',\ Sleep,'Sleep' import user32,\ MessageBoxA,'MessageBoxA',\ GetKeyState,'GetKeyState',\ wsprintf,'wsprintfA' Sorry, my English is not so good ... Last edited by asmhardy on 17 May 2012, 11:57; edited 1 time in total | |||
|  17 May 2012, 07:00 | 
 | 
| typedef 17 May 2012, 10:14 asmhardy wrote: 0x000008000 DWORD or QWORD  Also, note that this function returns WORD.  whose range is 0xFFFF | |||
|  17 May 2012, 10:14 | 
 | 
| sinsi 17 May 2012, 10:48 It only returns two bits of interest, the others could be anything.
 You need to test the bit with test/and/bt | |||
|  17 May 2012, 10:48 | 
 | 
| < Last Thread | Next Thread > | 
| Forum Rules: 
 | 
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.