IssisX
24th July 2003, 07:55
Hm, well I have been working on this for a bit. I can't seem to get it to work. So, I came here. I'm trying to send commands directly to a game console (Mohaa). I have the working c++ code to do it. So I ported it into vB. I just dont know what's wrong with it. If anyone can help, it would be great. Heres the code:
' in my form
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Sub Console(ByVal cgCmd As String)
Dim MohCons As Long
Me.AutoRedraw = True
MohCons = FindWindow(vbNullString, "Mohaa Console")
EnumChildWindows MohCons, AddressOf EnumChildSendCommandProc, ByVal 0&
End Sub
' my button
Private Sub Command1_Click()
Console "set name IssisX"
End Sub
' in my module
' my constants
Public Const GWL_EXSTYLE = (-20)
Public Const WM_CHAR = &H102
Public Const WM_SETTEXT = &HC
Public Const ES_READONLY = &H800&
' my declarations and functions
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Function EnumChildSendCommandProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim lpClassName As String
Dim L As Long
lpClassName = Space$(1024)
L = GetClassName(hwnd, lpClassName, 1024)
If (LCase$(ClassName) <> "edit") Or ((GetWindowLong(hwnd, GWL_STYLE) And ES_READONLY) = ES_READONLY) Then
EnumChildSendCommandProc = True
Exit Function
End If
Form1.Print Hex$(lParam)
'continue enumeration:
EnumChildProc = 1
End Function
I have attatched the working c++ code if anyone would like to try from scratch. Thank ya
' in my form
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Sub Console(ByVal cgCmd As String)
Dim MohCons As Long
Me.AutoRedraw = True
MohCons = FindWindow(vbNullString, "Mohaa Console")
EnumChildWindows MohCons, AddressOf EnumChildSendCommandProc, ByVal 0&
End Sub
' my button
Private Sub Command1_Click()
Console "set name IssisX"
End Sub
' in my module
' my constants
Public Const GWL_EXSTYLE = (-20)
Public Const WM_CHAR = &H102
Public Const WM_SETTEXT = &HC
Public Const ES_READONLY = &H800&
' my declarations and functions
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Function EnumChildSendCommandProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim lpClassName As String
Dim L As Long
lpClassName = Space$(1024)
L = GetClassName(hwnd, lpClassName, 1024)
If (LCase$(ClassName) <> "edit") Or ((GetWindowLong(hwnd, GWL_STYLE) And ES_READONLY) = ES_READONLY) Then
EnumChildSendCommandProc = True
Exit Function
End If
Form1.Print Hex$(lParam)
'continue enumeration:
EnumChildProc = 1
End Function
I have attatched the working c++ code if anyone would like to try from scratch. Thank ya