Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Is there a way to send commands from a vb program to

an other application that is running.

I'm running a game server and i want to send commands from a program i'm making in vb.net to the server.

 

http://ontani.no-ip.com/server_sof.jpg

this is the server window. Just an other windows application.

 

Someone told me that i could use DDE [Dynamic Data Exchange]

But i don't understand that really

 

Can Someone help me with this one?

 

Greetz From Ontani

  • Administrators
Posted

DDE isn't supported under .Net (as far as I'm aware - but that is a good thing IMHO :))

You may want to look at the ideas in these threads and see if they help any.

http://www.xtremedotnettalk.com/showthread.php?t=78598

http://www.xtremedotnettalk.com/showthread.php?t=83630

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

    Private Declare Ansi Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
   Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
   Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32
   Private Const WM_SETTEXT As Integer = &HC

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim hwnd As Integer = FindWindow(vbNullString, "Soldier of Fortune 2 Test Console") '/// assuming you have notepad open.
       Dim x As Integer = FindWindowEx(hwnd, 0, "Edit", vbNullString)
       Dim strText As String = "TESTING VB PROGRAM"
       If Not x = 0 Then
           SendMessage(x, WM_SETTEXT, 256, strText)
       End If
   End Sub

 

This works, i get the text TESTING VB PROGRAM in the server window now it just needs to be entered how do i do that?

 

Greetz

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...