Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Control or Shift or Alt
#1
is there a way I can have a mac or function trigger when any one of the modifier keys are pressed?
An old blog on QM coding and automation.

The Macro Hook
#2
Not easy. Need a low level keyboard hook. Or a function that repeatedly checks key toggled state.
#3
rats....and can't use the LL hooks due to the multiple keyboards.
An old blog on QM coding and automation.

The Macro Hook
#4
Or a function that repeatedly checks key toggled state. With most keys it dos not work on Vista and later, but works with lock and modifier keys. But you will not know what pressed - single Ctrl or Ctrl+key etc.
#5
If using multiple keyboards, its function receives modifier keys too. Try to add your code there. Then also can have different triggers for different keyboards.
#6
that's a great idea!

but I can't seem to get this to execute
Function FF_Keyboard1
Code:
Copy      Help
OnScreenDisplay_Rd("O" 0.2 870 -2 "Calibri" 32 0x00ffff 1|0x8000 "Ctl" 0x343434)

I've tried using
Code:
Copy      Help
g_ri.vk
but it doesn't seem to work like I was thinking. how can I set that up?
An old blog on QM coding and automation.

The Macro Hook
#7
Add your code in the keyboard detector function that receives all key events. Somewhere under case RIM_TYPEKEYBOARD.
#8
Do I have something wrong with my version of Keyboard Detector? I don't have RIM statement in there anywhere.

Function Keyboard_Detector
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam

#if (_winver>=0x501)
if(hDlg) goto messages

type RIDATA !k[4] !m[4] kt[4] mt[4] !kworking !mworking !vk !mb keyboard_id mouse_id hwnd
type RIDATAR flags k[4] m[4]
type RIHID handle kid
RIDATA+ g_ri
RIDATAR+ g_rir
ARRAY(RIHID)- ak am

if(getopt(nthreads)>1)
,act g_ri.hwnd; err
,ret

SetThreadPriority GetCurrentThread 2

if(!rget(g_rir "data" "\KD")) g_rir.flags=1

str controls = "10 4 11 6"
str c10Use lb4k c11Use lb6m

if(g_rir.flags&1) c10Use=1
if(g_rir.flags&2) c11Use=1
lb4k="FF_Keyboard1[]FF_Keyboard2[]FF_Keyboard3[]FF_Keyboard4"
lb6m="FF_Mouse1[]FF_Mouse2[]FF_Mouse3[]FF_Mouse4"

g_ri.hwnd=ShowDialog("Keyboard_Detector" &Keyboard_Detector &controls 0 17 WS_VISIBLE|DS_SETFOREGROUND)
MSG m
rep
,if(GetMessage(&m 0 0 0)<1) break
,if(m.message=WM_INPUT) RI_Input m.hwnd m.wParam m.lParam; continue
,TranslateMessage &m
,DispatchMessage &m

;BEGIN DIALOG
;0 "" 0x10C80844 0x100 0 0 261 193 "QM Keyboard & Mouse Detector"
;10 Button 0x54012003 0x4 4 2 96 12 "Use multiple keyboards"
;4 ListBox 0x54230101 0x204 4 16 84 40 "k"
;11 Button 0x54012003 0x4 4 62 94 12 "Use multiple mouses"
;6 ListBox 0x54230101 0x204 4 76 84 40 "m"
;2 Button 0x54030001 0x4 8 176 48 14 "Close"
;5 Button 0x54032000 0x4 58 176 48 14 "Exit"
;3 Static 0x54000000 0x4 100 16 158 44 "To associate a keyboard with a filter function, click the function in the list, and press spacebar or some other key on that keyboard. Repeat this for each keyboard."
;7 Static 0x54000000 0x4 100 76 158 40 "To associate a mouse with a filter function, double click the function in the list using that mouse. Repeat this for each mouse."
;8 Static 0x54000000 0x4 6 128 254 12 ""
;9 Button 0x54032000 0x0 210 176 48 14 "Help"
;12 Static 0x54000000 0x0 6 144 254 20 "Note: 'low level hook' must be unchecked in Options/Triggers. With LL hooks the detector does not work, and keyboard triggers also may stop working."
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,if(g_rir.flags&1) RI_RegisterDevices(hDlg 1 0); g_ri.kworking=1; else TO_Enable hDlg "4" 0
,if(g_rir.flags&2) RI_RegisterDevices(hDlg 1 1); g_ri.mworking=1; else TO_Enable hDlg "6" 0
,
,case WM_CLOSE if(wParam) DestroyWindow(hDlg)
,
,case WM_DESTROY
,RI_RegisterDevices hDlg 0 0 1
,RI_RegisterDevices hDlg 0 1 1
,PostQuitMessage 0
,memset &g_ri 0 sizeof(g_ri)
,
,case WM_COMMAND goto messages2
,
,case WM_TIMER
,KillTimer hDlg wParam
,_s.setwintext(id(8 hDlg))
,
ret
;messages2
sel wParam
,case IDCANCEL hid hDlg; ret
,case 5 DestroyWindow(hDlg)
,case 9 mac+ "Keyboard Detector Help"
,
,case [10,11]
,sel wParam
,,case 10
,,g_rir.flags^1
,,ak.redim
,,RI_RegisterDevices(hDlg g_rir.flags&1 0)
,,TO_Enable hDlg "4" g_rir.flags&1
,,g_ri.kworking=g_rir.flags&1
,,case 11
,,g_rir.flags^2
,,am.redim
,,RI_RegisterDevices(hDlg g_rir.flags&2 1)
,,TO_Enable hDlg "6" g_rir.flags&2
,,g_ri.mworking=g_rir.flags&2
,rset g_rir "data" "\KD"
,
,case LBN_DBLCLK<<16|6
,int i=LB_SelectedItem(lParam _s)
,if(i>=0 and i<4)
,,g_rir.m[i]=g_ri.mouse_id
,,rset g_rir "data" "\KD"
,,_s+" has been associated with this mouse"
,,_s.setwintext(id(8 hDlg))
,,SetTimer hDlg 1 3000 0

ret 1

#else
out "Keyboard Detector requires Windows XP or later."
An old blog on QM coding and automation.

The Macro Hook
#9
look in RI_Input
#10
thanks!
An old blog on QM coding and automation.

The Macro Hook


Forum Jump:


Users browsing this thread: 2 Guest(s)