大家都知道,用key_event(VK_SHIFT,0,0,0)可以实现‘按住’SHIFT键,用key_event(VK_SHIFT,0,2,0)可以实现‘释放’SHIFT键,我的问题是假设key_event(VK_SHIFT,0,0,0)之后,用那个API可以识别到SHIFT的按键是‘按住’的,即如何识别像SHIFT等键的状态?

解决方案 »

  1.   

    if GetAsyncKeyState(VK_SHIFT) then ......
      

  2.   

    更正一下:大家都知道,用keydb_event(VK_SHIFT,0,0,0)可以实现‘按住’SHIFT键,用keydb_event(VK_SHIFT,0,2,0)可以实现‘释放’SHIFT键,我的问题是假设keydb_event(VK_SHIFT,0,0,0)之后,用那个API可以识别到SHIFT的按键是‘按住’的,即如何识别像SHIFT等键的状态?
      

  3.   

    use GetKeyState
    If the function succeeds, the return value specifies the status of the given virtual key. If the high-order bit is 1, the key is down; otherwise, it is up. If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled.