Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
output key's pressed at beginning of script
#2
OS has 2 functions to get logical key pressed state: GetKeyState and GetAsyncKeyState. Both have different advantages and disadvantages. Also there is GetKeyboardState, gets states of all keys and works like GetKeyState. And no functions to get physical state.

QM function RealGetKeyState uses GetKeyState or GetAsyncKeyState depending on key, and also does workarounds for some problems. QM function ifk is the same but uses QM key codes instead of virtual-key codes, eg S instead of VK_SHIFT. QM function GetMod gets states of 4 modifier keys, and is used like if(GetMod&3=3) .... to check if CTRL and SHIFT is pressed .

To get state of non-modifier keys at thread startup, it's better to use GetAsyncKeyState or QM functions.
Code:
Copy      Help
out F"GetKeyState: Shift={GetKeyState(VK_SHIFT)&0x8000!=0}, K={GetKeyState('K')&0x8000!=0}" ;;problem: does not see K if pressed before starting this thread
out F"GetAsyncKeyState: Shift={GetAsyncKeyState(VK_SHIFT)&0x8000!=0}, K={GetAsyncKeyState('K')&0x8000!=0}" ;;problem: does not see any keys if the foreground window is admin and we not. Other functions at least work with modifier keys.
out F"RealGetKeyState: Shift={RealGetKeyState(VK_SHIFT)}, K={RealGetKeyState('K')}"
out F"ifk: Shift={ifk(S)}, K={ifk(k)}"


Messages In This Thread
RE: output key's pressed at beginning of script - by Gintaras - 03-06-2020, 09:21 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)