flat assembler
Message board for the users of flat assembler.

Index > Windows > Fasm 1.73 64 bit GetAsyncKeyState not work.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1817
Roman 23 Nov 2019, 14:20
Code:
     invoke GetAsyncKeyState,'1'

     and eax,0x8000
     test eax,eax
     je NotPressed

     invoke MessageBox,0, 'Key pressed',0,0

NotPressed:
    


I press key '1' but not print message.
This code work in 32 bit.
Post 23 Nov 2019, 14:20
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 23 Nov 2019, 14:33
The problem here is that the variants of "invoke" macro that allow embedded string arguments would pass a pointer to a string instead of character code to GetAsyncKeyState. So, for example, your snippet would work correctly with "win32a.inc" but not with "win32ax.inc". In 64-bit case even the basic "win64a.inc" already supports embedded strings.

To make this unambiguous, simply enforce numeric treatment of the argument like this:
Code:
     invoke GetAsyncKeyState,+'1'    
Post 23 Nov 2019, 14:33
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1817
Roman 23 Nov 2019, 14:40
Thanks !
Its magic Smile
Post 23 Nov 2019, 14:40
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.