Announcement

Collapse
No announcement yet.

Simple keystroke macro.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple keystroke macro.

    I just pinched this one from one of my MASM apps. It is designed to be used in a key processing function from a WM_KEYUP message or similar. I use it in the message loop for hotkey combinations.

    Code:
    #IF 0  ' ***********************************************
    
            macro to test if a virtual key is pressed
            use the following ASM instructions to respond
    
          ' either
            CmpKey(%VK_SHIFT)
            ! je label          ' if VK_SHIFT is pressed
    
          ' or
            CmpKey(%VK_SHIFT)
            ! jne label         ' if VK_SHIFT is not pressed
    
          ' .......
          label:
    
    #ENDIF ' ***********************************************
    
        MACRO CmpKey(vk_key)
          GetAsyncKeyState vk_key
          ! and eax, &B00000000000000001000000000000000
          ! rol eax, 17
          ! cmp eax, 1
        END MACRO
    
    ' ******************************************************
    It can be done with a couple of less instructions but at the price of inverting the logic for the following conditional jump.
    hutch at movsd dot com
    The MASM Forum

    www.masm32.com
Working...
X