Escribir en la consola del CS con VB

Iniciado por XP., 2 Julio 2006, 21:42 PM

0 Miembros y 1 Visitante están viendo este tema.

XP.

Hola, queria saber como puedo hacer para escribir en la consola del Counter-Strike averigue y se que la ventana se llama "valve001" probe usando los sendkeys pero siempre hay algun error, asi que queria saber si alguien me puede ayudar, consegui para escribir en la consola del Quake 3 lo adapte pero me tira errores, lo dejo aqui abajo. Muchas Gracias!

En un MODULO:

Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, _
ByVal hwnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetLastError Lib "kernel32" () As Long
Private Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, Arguments As Long) As Long
Private Const LINE_LEN = 512
Private Const GWL_WNDPROC = (-4)
Private Const WM_COMMAND = &H111
Private Const EN_CHANGE = &H300
Private Const EM_GETLINE = &HC4
Private Const EM_GETLINECOUNT = &HBA
Const FORMAT_MESSAGE_ALLOCATE_BUFFER = &H100
Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000
Public Const GAME_WINDOW = "Counter-Strike"
Dim hWndEditRead As Long, hWndEditWrite As Long
Dim thisline As Long
Dim numlines As Long
Dim szLastLine(LINE_LEN) As String
Dim bOnce As Boolean
Global o_WndProc As Long


Public Sub SubClass(hwnd As Long)
Dim buffer As String
buffer = Space(200)
SetWindowLong hwnd, GWL_WNDPROC, AddressOf WindowProc
o_WndProc = GetWindowLong(hwnd, GWL_WNDPROC)
FormatMessage FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0&, GetLastError, LANG_NEUTRAL, buffer, 200, ByVal 0&
MsgBox buffer
o_WndProc = o_WndProc
End Sub
Function WindowProc(ByVal hw As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Select Case uMsg
Case WM_COMMAND
If wParam = EN_CHANGE Then
If Not bOnce Then
hWndEditRead = lParam
hWndEditWrite = FindWindowExA(FindWindow(0, GAME_WINDOW), Null, "Edit", 0)
bOnce = True
End If
numlines = SendMessage(hWndEditRead, EM_GETLINECOUNT, 0, 0)
thisline = SendMessage(hWndEditRead, EM_GETLINE, numlines - 2, szLastLine)
Form1.Text1.Text = thisline
End If
WindowProc = CallWindowProc(o_WndProc, hw, uMsg, wParam, lParam)
End Select
End Function



EN UN FORM:

Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 5000
End Sub

Private Sub Timer1_Timer()
SubClass FindWindow("valve001", vbNullString)
End Sub


Cuando lo pruebo en el CS me pone "Acceso denegado"  :-[

NYlOn

Cambia la linea del timer por:

SubClass FindWindow(vbNullString,"valve001")


Fijate si ahi te funciona...

XP.

Cita de: NYlOn en  2 Julio 2006, 23:43 PM
Cambia la linea del timer por:

SubClass FindWindow(vbNullString,"valve001")


Fijate si ahi te funciona...

Me dice "El identificador de la ventana no es valido"