From: Karl E. Peterson on
Juergen Thuemmler wrote:
> Hi Karl,
>
>> Works here, too. Now I just need to find a bit more elegant way to handle
>> that StuffBuffer routine. It's sorely in need of a GoSub, don't ya think?
>> <g>
>
> may be, if you like it ;-) But I don't believe it would better...

Heh, couldn't do it. Ended up with this:

Private Sub StuffShift(ByVal KeyCode As Integer, Optional Press As
Boolean)
' ADDED 02-Apr-2010
' Effectively a GoSub from StuffBuffer...
With m_Events(m_EvtPtr)
.wVK = KeyCode
If Not Press Then
.dwFlags = KEYEVENTF_KEYUP
End If
End With
m_EvtPtr = m_EvtPtr + 1
End Sub

> I forgot somethig regarding "{~}":

Oh oh. Is that a stinkin' AltGr char too???

> Private Sub ProcessNamedKey()
> Dim EndPtr As Long, i As Long, repeat As Long
> Dim this As String
> Dim pieces As Variant '() As String
> Dim vk As Integer
> Dim capped As Boolean, extend As Boolean, AltGr As Boolean '<<<###
>
> EndPtr = InStr(m_DatPtr + 2, m_Data, "}")
> ' No need to do anything if endgroup immediately follows beginning.
> If EndPtr > (m_DatPtr + 1) Then
> ' Extract group of characters.
> this = Mid$(m_Data, m_DatPtr + 1, EndPtr - m_DatPtr - 1)
>
> ' Break into pieces, if possible.
> pieces = Split(this, " ")
>
> ' Second element, if avail, is number of times to repeat stroke.
> If UBound(pieces) > 0 Then repeat = Val(pieces(1))
> If repeat < 1 Then repeat = 1
>
> ' Attempt to retrieve named keycode, or else retrieve standard code.
> vk = GetNamedKey(CStr(pieces(0)))
> If ByteHi(vk) = 6 Then AltGr = True '<<<###
> If vk Then
> ' Is this an extended key?
> extend = IsExtendedKey(this)
> Else
> ' Not a standard named key.
> vk = VkKeyScan(Asc(this))
> If ByteHi(vk) = 6 Then AltGr = True '<<<###
> capped = CBool(ByteHi(vk) And 1)
> vk = ByteLo(vk)
> End If
>
> ' Stuff buffer as many times as required.
> For i = 1 To repeat
> Call StuffBuffer(vk, capped, extend, AltGr) '<<<###
> Next i
>
> ' Advance data pointer to closing parenthesis.
> m_DatPtr = EndPtr
> End If
> End Sub

Is this an actual or theoretical problem one? Assuming a good reason
to do it, would this work just as well:

AltGr = CBool(ByteHi(vk) And 6)
For i = 1 To repeat
...

Just trying to understand the multiple tests there.

Thanks... Karl

--
..NET: It's About Trust!
http://vfred.mvps.org


From: Juergen Thuemmler on
Hi Karl,

> Oh oh. Is that a stinkin' AltGr char too???
Oh yes ;-)

> Is this an actual or theoretical problem one? Assuming a good reason to
> do it, would this work just as well:
>
> AltGr = CBool(ByteHi(vk) And 6)
> For i = 1 To repeat
> ...
>
> Just trying to understand the multiple tests there.

Because you use vk for different values:

If vk Then
' Is this an extended key?
extend = IsExtendedKey(this)
Else
' Not a standard named key.
vk = VkKeyScan(Asc(this)) '<<<###
If ByteHi(vk) = 6 Then AltGr = True
capped = CBool(ByteHi(vk) And 1)
vk = ByteLo(vk) '<<<###
End If

Of course, all could be solved in many other, may be better ways...

Juergen.


From: Karl E. Peterson on
Juergen Thuemmler wrote:
> Hi Karl,
>
>> Oh oh. Is that a stinkin' AltGr char too???
>
> Oh yes ;-)

Grumble...

>> Is this an actual or theoretical problem one? Assuming a good reason to do
>> it, would this work just as well:
>>
>> AltGr = CBool(ByteHi(vk) And 6)
>> For i = 1 To repeat
>> ...
>>
>> Just trying to understand the multiple tests there.
>
> Because you use vk for different values:
>
> If vk Then
> ' Is this an extended key?
> extend = IsExtendedKey(this)
> Else
> ' Not a standard named key.
> vk = VkKeyScan(Asc(this)) '<<<###
> If ByteHi(vk) = 6 Then AltGr = True
> capped = CBool(ByteHi(vk) And 1)
> vk = ByteLo(vk) '<<<###
> End If

Oh jeez, yeah, you're a lot closer to the code than I am at this point.
So, of course, that Else is stripping off the shift chars from the
actual keystroke. Makes sense to stick it in there. I don't think the
earlier call to GetNamedKey would ever generate such a sequence,
though, right?

Thanks... Karl

--
..NET: It's About Trust!
http://vfred.mvps.org


From: Clive Lumb on


"Karl E. Peterson" <karl(a)exmvps.org> a �crit dans le message de groupe de
discussion : #Q$vdpO1KHA.2028(a)TK2MSFTNGP05.phx.gbl...
> Juergen Thuemmler wrote:
>> Hi Karl,
>>
>>> Oh oh. Is that a stinkin' AltGr char too???
>>
>> Oh yes ;-)
>
> Grumble...
>
>>> Is this an actual or theoretical problem one? Assuming a good reason to
>>> do it, would this work just as well:
>>>
>>> AltGr = CBool(ByteHi(vk) And 6)
>>> For i = 1 To repeat
>>> ...
>>>
>>> Just trying to understand the multiple tests there.
>>
>> Because you use vk for different values:
>>
>> If vk Then
>> ' Is this an extended key?
>> extend = IsExtendedKey(this)
>> Else
>> ' Not a standard named key.
>> vk = VkKeyScan(Asc(this)) '<<<###
>> If ByteHi(vk) = 6 Then AltGr = True
>> capped = CBool(ByteHi(vk) And 1)
>> vk = ByteLo(vk) '<<<###
>> End If
>
> Oh jeez, yeah, you're a lot closer to the code than I am at this point.
> So, of course, that Else is stripping off the shift chars from the actual
> keystroke. Makes sense to stick it in there. I don't think the earlier
> call to GetNamedKey would ever generate such a sequence, though, right?
>
> Thanks... Karl
>
> --
> .NET: It's About Trust!
> http://vfred.mvps.org

Just FYI,
I replaced VkKeyScan by VkKeyScanEx (which requires the keyboard layout as a
parameter) and nearly everything works with no other code changes. The ~and
` are still slightly problematic though, specially if you send `[



From: Karl E. Peterson on
Clive Lumb wrote:
>
> "Karl E. Peterson" <karl(a)exmvps.org> a �crit dans le message de groupe de
> discussion : #Q$vdpO1KHA.2028(a)TK2MSFTNGP05.phx.gbl...
>> Juergen Thuemmler wrote:
>>> Hi Karl,
>>>
>>>> Oh oh. Is that a stinkin' AltGr char too???
>>>
>>> Oh yes ;-)
>>
>> Grumble...
>>
>>>> Is this an actual or theoretical problem one? Assuming a good reason to
>>>> do it, would this work just as well:
>>>>
>>>> AltGr = CBool(ByteHi(vk) And 6)
>>>> For i = 1 To repeat
>>>> ...
>>>>
>>>> Just trying to understand the multiple tests there.
>>>
>>> Because you use vk for different values:
>>>
>>> If vk Then
>>> ' Is this an extended key?
>>> extend = IsExtendedKey(this)
>>> Else
>>> ' Not a standard named key.
>>> vk = VkKeyScan(Asc(this)) '<<<###
>>> If ByteHi(vk) = 6 Then AltGr = True
>>> capped = CBool(ByteHi(vk) And 1)
>>> vk = ByteLo(vk) '<<<###
>>> End If
>>
>> Oh jeez, yeah, you're a lot closer to the code than I am at this point. So,
>> of course, that Else is stripping off the shift chars from the actual
>> keystroke. Makes sense to stick it in there. I don't think the earlier
>> call to GetNamedKey would ever generate such a sequence, though, right?
>
> Just FYI,
> I replaced VkKeyScan by VkKeyScanEx (which requires the keyboard layout as a
> parameter) and nearly everything works with no other code changes. The ~and `
> are still slightly problematic though, specially if you send `[

I wondered about that, at one point. Since I never use alt layouts, I
just didn't know how that might go. In particular, what would happen
if you were to use the default language identifier, and the user had
toggled to a different keyboard layout? So are you just calling
GetKeyboardLayout to fill that parameter? And would this avoid the all
the issues we've been talking about in this thread?

--
..NET: It's About Trust!
http://vfred.mvps.org