I can't seem to send a specific LEFT or RIGHT Ctrl or Alt, or is it that I can't read it out... ?
I made a little test sub: (delete the gray part in Declare if you don't have a 64bit Excel)
output:
The R should be L !!!
Also I can't seem to send only the Alt-R without also pressing Ctrl-L !?
HELP ME, thanks
I made a little test sub: (delete the gray part in Declare if you don't have a 64bit Excel)
Code:
[FONT=courier new]Private Declare [COLOR=#A9A9A9]PtrSafe [/COLOR]Sub keybd_event Lib "user32" (ByVal bVk As Byte _
,ByVal bScan As Byte _
,ByVal [COLOR=#000000]dwFlags [/COLOR]As Long _
,ByVal dwExtraInfo As Long[COLOR=#a9a9a9]Ptr[/COLOR])
[/FONT][FONT=courier new]Sub sTest_keybd_event()
[/FONT][FONT=courier new] Debug.Print "[/FONT][FONT=courier new]----------------------------[/FONT][FONT=courier new]-----[/FONT][FONT=courier new]"[/FONT]
[FONT=courier new] For i = 0 To 8[/FONT]
[FONT=courier new] vKey = Array(16, 17, 18, 160, 161, 162, 163, 164, 165)(i)[/FONT]
[FONT=courier new] vName = Split("Shift , Ctrl , Alt ,ShiftL,ShiftR, CtrlL, CtrlR, AltL, AltR", ",")(i)[/FONT]
[COLOR=#008080][FONT=courier new]' vMap = MapVirtualKey(vKey, 0)[/FONT][/COLOR][COLOR=#ff0000][FONT=courier new] '''no difference then just using 0, so why use MapVirtualKey?[/FONT][/COLOR]
[FONT=courier new] vMap = 0[/FONT][FONT=courier new]
[/FONT]
[COLOR=#008080][FONT=courier new] '''vUpDown: bit1=ExtKey, bit2=KeyUp[/FONT][/COLOR]
[FONT=courier new] vUp = 1: vDown = 3 [COLOR=#ff0000]'''all Left keys are read as Right!?[/COLOR][/FONT]
[COLOR=#008080][FONT=courier new]' vUp = 0: vDown = 2[/FONT][/COLOR][COLOR=#ff0000][FONT=courier new] '''all Right keys are read as Left, except for Shift!?[/FONT][/COLOR][FONT=courier new]
[/FONT]
[FONT=courier new] keybd_event [/FONT][FONT=courier new]vKey, vMap, vUp, 0[/FONT]
[FONT=courier new] DoEvents[/FONT]
[FONT=courier new] Debug.Print (vName & " " & vMap & " " & vDown & " ");[/FONT]
[FONT=courier new] vShift = IIf(CBool(GetKeyState(16) And -128), "Shift-", "") _
& IIf(CBool(GetKeyState(160) And -128), "L", "") _
& IIf(CBool(GetKeyState(161) And -128), "R", "")[/FONT]
[FONT=courier new] vCtrl = IIf(CBool(GetKeyState(17) And -128), "Ctrl-", "") _
& IIf(CBool(GetKeyState(162) And -128), "L", "") _
& IIf(CBool(GetKeyState(163) And -128), "R", "")[/FONT]
[FONT=courier new] vAlt = IIf(CBool(GetKeyState(18) And -128), "Alt-", "") _
& IIf(CBool(GetKeyState(164) And -128), "L", "") _
& IIf(CBool(GetKeyState(165) And -128), "R", "")[/FONT]
[FONT=courier new] Debug.Print Left(vShift & Space(9), 9) & Left(vCtrl & Space(8), 8) & vAlt[/FONT]
[FONT=courier new] keybd_event [/FONT][FONT=courier new]vKey, vMap, vDown, 0[/FONT]
[FONT=courier new] DoEvents[/FONT]
[FONT=courier new] Next[/FONT]
[FONT=courier new]End Sub[/FONT]
output:
Code:
[FONT=courier new]----------------------------[/FONT][FONT=courier new]-----[/FONT][FONT=courier new]
[/FONT][FONT=courier new]Shift 0 3 Shift-R [/FONT]
[FONT=courier new] Ctrl 0 3 Ctrl-R [/FONT]
[FONT=courier new] Alt 0 3 [I][COLOR=#ff0000]Ctrl-L[/COLOR][/I] Alt-R[/FONT]
[FONT=courier new]ShiftL 0 3 Shift-[B][COLOR=#ff0000]R[/COLOR][/B] [/FONT]
[FONT=courier new]ShiftR 0 3 Shift-R [/FONT]
[FONT=courier new] CtrlL 0 3 Ctrl-[B][COLOR=#ff0000]R[/COLOR][/B] [/FONT]
[FONT=courier new] CtrlR 0 3 Ctrl-R [/FONT]
[FONT=courier new] AltL 0 3 Alt-[COLOR=#ff0000][B]R[/B][/COLOR][/FONT]
[FONT=courier new] AltR 0 3 [I][COLOR=#ff0000]Ctrl-L[/COLOR][/I] Alt-R[/FONT]
The R should be L !!!
Also I can't seem to send only the Alt-R without also pressing Ctrl-L !?
HELP ME, thanks