Ok, here I go again... I built an application that runs on top of a game that I play. I use a keyboard hook to intercept certain keys and pass them through my app. The problem I am haveing is that the commands are getting passed through my application, but is there a way to stop the keys from then being sent to the game as well.
For example I want to intercept Ctrl + T which in my application does something, but in the game, it opens a window. What I want to happen is it to fire the event in my app and then not send that combination to the game and open the window.
I hope I was clear with my question and I thank you in advance for any help
This is the function I am currently using, which works, but the keys still get sent to the game
VB Code:
Public Function IsHooked(ByRef Hookstruct As KBDLLHOOKSTRUCT) As Boolean ' CTL Keys Dim key As Integer Dim mcr As Integer Dim VK_KEY As Integer For i As Integer = 0 To setKeys.GetUpperBound(0) key = setKeys(i).subKey 'The subkey (1=Ctrl,2=Alt,0=none) mcr = setKeys(i).mcr 'The macro index to be fired VK_KEY = setKeys(i).key 'The key value If key = 1 Then 'Subkey is Control If (Hookstruct.vkCode = VK_KEY) And CBool(GetAsyncKeyState(VK_CONTROL) And &H8000) _ And CBool(Hookstruct.flags And LLKHF_UP) Then Call mcrFire(mcr) Return True ElseIf (Hookstruct.vkCode = VK_KEY) And CBool(GetAsyncKeyState(VK_CONTROL) And &H8000) Then 'Do nothing End If ElseIf key = 2 Then 'Subkey is Alt If (Hookstruct.vkCode = VK_KEY) And CBool(Hookstruct.flags And LLKHF_ALTDOWN) _ And CBool(Hookstruct.flags And LLKHF_UP) Then Call mcrFire(mcr) Return True ElseIf (Hookstruct.vkCode = VK_KEY) And CBool(Hookstruct.flags And LLKHF_ALTDOWN) Then 'Do nothing End If Else 'No Subkey If (Hookstruct.vkCode = VK_KEY) And CBool(Hookstruct.flags And LLKHF_UP) Then Call mcrFire(mcr) Return True ElseIf (Hookstruct.vkCode = VK_KEY) Then 'Do nothing End If End If Next i 'Page up and down for switching macro sets If (Hookstruct.vkCode = VK_NEXT) And CBool(Hookstruct.flags And LLKHF_UP) Then MacroSets(1) Return True ElseIf (Hookstruct.vkCode = VK_NEXT) Then Return True End If If (Hookstruct.vkCode = VK_PRIOR) And CBool(Hookstruct.flags And LLKHF_UP) Then MacroSets(-1) Return True ElseIf (Hookstruct.vkCode = VK_PRIOR) Then Return True End If Return False End Function






Reply With Quote