Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Detecting shift with wait for key
#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)


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)