View Single Post
Old 02-19-2006, 12:41 AM   #3 (permalink)
JimJava
Newbie
 
JimJava's Avatar
 
Join Date: Feb 2006
Posts: 13
Default Thanks but im still in a jam :( Heres what iv got so far on the Sending part

' I added Option Strict Off becouse i need late binding. (this is my first error)
Option Strict Off
' I declared the necessary API routines:
Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As Long) As Long

Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Sub GetClient()
Dim MyClt As Object ' Variable to hold reference
' to UO.
Dim UOWasNotRunning As Boolean ' Flag for final release.

' I test to see if there is a copy of UO already running.
On Error Resume Next ' Defer error trapping.
' Getobject function called without the first argument returns a
' reference to an instance of UO.
' If UO is not running, an error occurs.
MyClt = GetObject(, "Client.Application")
If Err().Number <> 0 Then UOWasNotRunning = True
Err().Clear() ' Clear Err object in case error occurred.

' Check for UO. If UO is running,
' enter it into the Running Object table.
DetectClient()

' I set the object variable to reference the file I wanted to see.
MyClt = GetObject("C:\Program Files\EA GAMES\Ultima Online Samurai Empire\Client.exe")

' Show UO through its Application property. Then
' show the actual window containing the file using the Windows
' collection of the MyClt object reference.
MyClt.Application.Visible = True
MyClt.Parent.Windows(1).Visible = True
' Spot for manipulations here.
'
End Sub

Sub DetectClient()
' Procedure dectects a running Client and registers it.
Const WM_USER = 1024
Dim hWnd As Long
' If Client is running this API call returns its handle.
hWnd = FindWindow("Client", 0)
If hWnd = 0 Then ' 0 means Client not running.
Exit Sub
Else
' Client is running so use the SendMessage API
' function to enter it in the Running Object Table.
SendMessage(hWnd, WM_USER + 18, 0, 0)
End If
End Sub
End Sub

Private Sub CmdSend_Click()
Dim MyString, MyStr ' Dim to save internal Mem.
MyString = TxtSend.Text ' I define the string to be sent.
MyStr = Left(MyString, 1000)
MyClt = MyStr ' The destanation to print to.

MyClt.SetFocus ' Get focus so that the Enter Key can be sent.
SendKeys "{ENTER}"
End Sub

Thanks Yet again for your time and ill post my project code as i go to help others
JimJava is offline   Reply With Quote