The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: dymyker46 on March 23, 2009, 09:03:15 AM

Title: how to make a simple keypress in asm?
Post by: dymyker46 on March 23, 2009, 09:03:15 AM
how to make a simple keypress in asm?

if i have a button "Y" and acts as similar as sendkeys with time delays...when i press the button it will send a "Y"
how to write it in asm?

thanks...
Title: Re: how to make a simple keypress in asm?
Post by: Neil on March 23, 2009, 09:23:14 AM
It looks as if you are trying to lock the keyboard, you need to give a bit more information on what you are trying to do.
Have you written any code?
Title: Re: how to make a simple keypress in asm?
Post by: Vortex on March 23, 2009, 08:57:38 PM
keybd_event Function (http://msdn.microsoft.com/en-us/library/ms646304(VS.85).aspx)
Title: Re: how to make a simple keypress in asm?
Post by: dymyker46 on March 24, 2009, 03:55:36 AM
i am thankfull that somebody reply on my thread...

honesty... im still study right now asm... in online tutorials.. and still gathering information..

pertaining to my question... i tried "keybd_event Function" but still it doesnt work...

i am making a program from asm to send a key throu press button event... similiar to OSK.exe but i need to
customize it for may conformity...

thanks again...
Title: Re: how to make a simple keypress in asm?
Post by: Tedd on March 24, 2009, 12:34:19 PM
You'll have to show us your code so we can help you with that - otherwise we don't know why it doesn't work :wink
Title: Re: how to make a simple keypress in asm?
Post by: dymyker46 on March 25, 2009, 10:25:09 PM
thanks for the reply Tedd.

im still a beginner, actually i dont know how to make one except hello world.. im still study...

on other hand, is there away to make it readable asm files...?? because i only know VB programming...

thanks
Title: Re: how to make a simple keypress in asm?
Post by: dsouza123 on March 25, 2009, 11:10:27 PM
Maybe it is a program like the On-screen keyboard in Win XP ?

When used along with a text editor, set the focus to the editor,
then clicking on the screen keys will send keys to the editor.
Title: Re: how to make a simple keypress in asm?
Post by: dymyker46 on March 27, 2009, 01:55:43 AM
Quote from: dsouza123 on March 25, 2009, 11:10:27 PM
Maybe it is a program like the On-screen keyboard in Win XP ?


yes dsouza, kindah... still studying asm right now... low progress...  :(
Title: Re: how to make a simple keypress in asm?
Post by: ToutEnMasm on March 27, 2009, 07:51:11 AM

Prefered method is using an ACCELERATORS table

Further steps are needed

in the rc file

Quote
      // Accelerators table   54 et 55 are numbers of command
      // ctrl+space shift+insert
      SDIDEMO ACCELERATORS DISCARDABLE
      BEGIN
      VK_SPACE,54, VIRTKEY, CONTROL, NOINVERT
      VK_INSERT,55,VIRTKEY, SHIFT, NOINVERT
      END

at the beginning of the source code,you need to load this resource
Quote
      invoke LoadAccelerators,hInstance,SADR("SDIDEMO")
      mov Haccel,eax
              ;in the WM_COMMAND message
      .elseif eax == 54
      ;do something

Finally,you must insert a piece of code in the messages loop

Quote
      @@:
      INVOKE GetMessage, addr msg,0, 0, 0
      .if eax != 0 && eax != INVALID_HANDLE_VALUE ;WM_QUIT ou crash
      invoke TranslateAccelerator,hWnd,Haccel, ADDR msg;keyboard events en WM_COMMAND
      INVOKE TranslateMessage, addr msg ;get the message
      INVOKE DispatchMessageA , addr msg ;send les messages aux fenĂȘtres
      jmp @B
      .endif

You must modify this pieces of code with your own name of variables ,see winhelp or better the SDK for this