Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Detecting shift with wait for key
#1
Code:
Copy      Help
[code]rep
,int input=wait(0 KF)
,out GetMod
,out GetAsyncKeyState(VK_LSHIFT)
,out GetKeyState(VK_LSHIFT)
,out RealGetKeyState(VK_LSHIFT)
,if (input = 119) ;; end on f8
,,break
,key (input)
[/code]

How can I detect if shift is down when the key is imputted.
#2
ifk((VK_SHIFT))


soemthing like that you will need to use
#3
see also
Registering hot keys, waiting for hotkeys
#4
I am trying to remap 4 keys to behave as another key(Ex. Push <w> screen types "e"). What is ouputted can be any key, and when using RegisterHotkey if a programmed key's value is another programmed key, the first programmed key triggers the third (Ex push <w>, triggers <e> push, does not output "e").
#5
To remap keys can be used keyboard triggers, unless you want to remap many keys.

-----------
wait() does not have an option to wait for several keys eg Shift+F8.
Your code does not work because when Shift is pressed it presses/releases (key (input)) Shift and therefore it is not pressed when F8 arrives.

-----------
To have full control, use keyboard hook.
Function remap_keyboard_LL_hook
Code:
Copy      Help
function nCode wParam KBDLLHOOKSTRUCT&h

if(getopt(nargs)=0)
,if(getopt(nthreads)>1) ret
,int- t_keyhook
,t_keyhook=SetWindowsHookEx(WH_KEYBOARD_LL &remap_keyboard_LL_hook _hinst 0)
,MessageLoop
,ret

;---- this code runs on each key down and up event -----

;;debug
;FormatKeyString h.vkCode 0 &_s
;out "%s %s%s" _s iif(h.flags&LLKHF_UP "up" "down") iif(h.flags&LLKHF_INJECTED ", injected" "")

if(h.flags&LLKHF_INJECTED=0)
,
,;remaps:
,;A to B,
,;B to C
,;F8 to right arrow
,
,int r
,sel h.vkCode
,,case 'A' r='B'
,,case 'B' r='C'
,,case VK_F8 r=VK_RIGHT
,,;...
,,
,if(r)
,,if(h.flags&LLKHF_UP=0) key (r)
,,ret 1
,,

ret CallNextHookEx(t_keyhook nCode wParam &h)


Forum Jump:


Users browsing this thread: 1 Guest(s)