TranslateMessage without a control handle

Posts 1–2 of 2 · Page 1 of 1
TranslateMessage without a control handle
Having a problem with TranslateMessage, I can't figure out how to use it to send it to a window that doesn't have controls (the option bars on the top) on it, like a game. The below stuff is used to send keys to Notepad, which of course does have controls on it. How do I make this work for a game?

Code:
  Dim hwnd As Integer = FindWindow(vbNullString, findPartialTitle("EverQuest II").ToString) '/// assuming you have notepad open.
  Dim x As Integer = FindWindowEx(hwnd, 0, "Edit", vbNullString)
Notice the second Dim, FindWindowEx. I want to get rid of that, as EverQuest II doesn't have an "Edit" control, or any control for that matter.

It's used like this:

Code:
    Public Structure MSG
  Public hwnd As Integer
  Public message As Integer
  Public wParam As Integer
  Public lParam As Integer
  Public time As Integer
  Public pt As Integer
    End Structure

  Dim myMsg As MSG = New MSG

  If Not x = 0 Then
    myMsg.hwnd = x
    myMsg.message = WM_KEYDOWN
    myMsg.wParam = key
    myMsg.lParam = 0
    Dim ret As Integer
    ret = TranslateMessage(myMsg)
    Debug.WriteLine("TranslateMessage " & ret.ToString)
  End If
Notice the "myMsg.hwnd = x" line. I tried changing that to "myMsg.hwnd = hwnd" and removing the "If x not 0" check but no dice.
You use SendMessage to do something like that, not TranslateMessage.

If it doesn't have an edit control, use SendInput or keybd_event.
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?