Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: shadowz on May 04, 2003, 03:46 AM

Title: Sending a key (i.e. Enter)
Post by: shadowz on May 04, 2003, 03:46 AM
How do you make it send a key through the Chat in Visual Basic 6?

Example:

AddChat vbYellow, "Connecting to Battle.net"
ws.SendData Chr(3) & Chr(4) & strUsername & vbCrLf & strPassword & vbCrLf
ws.SendData "/w Masterzs" & strUsername & "" & "is logged in"

and make it send that automatically without showing, like NBBot did
Title: Re:Sending a key (i.e. Enter)
Post by: l)ragon on May 04, 2003, 04:16 AM
have a look at keypress rout. on the text box or what ever it is you are useing to send the text.

textbox_KeyPress(KeyAscii As Integer)
Title: Re:Sending a key (i.e. Enter)
Post by: shadowz on May 04, 2003, 04:35 AM
Here are some coding

Private Sub txtSend_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If ws.State = 7 Then
ws.SendData txtSend.Text & vbCrLf

AddChat vbCyan, txtSend.Text
txtSend.Text = ""

Else

AddChat vbRed, "You Are Disconnected From Battle.net"
txtSend.Text = ""
End If
End If
End Sub

AND

Private Sub ws_Connect()
Dim strUsername As String
Dim strPassword As String

strUsername = frmConfig.txtUsername.Text
strPassword = frmConfig.txtPassword.Text

AddChat vbYellow, "Connecting to Battle.net"
ws.SendData Chr(3) & Chr(4) & strUsername & vbCrLf & strPassword & vbCrLf
ws.SendData "/w Masterzs" & strUsername & "" & "is logged in"
End Sub



So with that, how would I go about doing it?

[Kp edit: added code tags.  Please use them when pasting long segments of code, particularly if you want people to analyze the code.]
Title: Re:Sending a key (i.e. Enter)
Post by: l)ragon on May 04, 2003, 04:46 AM
you also might want to look into the winsock events sending data befor you know your connected for sure, could posibly cause a problem down the road.
Title: Re:Sending a key (i.e. Enter)
Post by: dxoigmn on May 04, 2003, 05:26 AM
Quote from: shadowz on May 04, 2003, 04:35 AM
If KeyAscii = 13 Then
If ws.State = 7 Then

vbKeyReturn
sckConnected
Title: Re:Sending a key (i.e. Enter)
Post by: shadowz on May 04, 2003, 05:32 AM
Didn't work
Title: Re:Sending a key (i.e. Enter)
Post by: tA-Kane on May 04, 2003, 04:16 PM
Quote from: shadowz on May 04, 2003, 04:35 AMHere are some coding
Shadows, I would appreciate it if you would use the integrated code tags.
[ code ]Remove spaces for the tags to work.[ /code ]
Title: Re:Sending a key (i.e. Enter)
Post by: SubLiminaL_WolF on May 05, 2003, 09:16 PM
i dont think that is right to put in a backdoor in ur bot  ::) :o :'(
Title: Re:Sending a key (i.e. Enter)
Post by: Crypticflare on May 05, 2003, 10:15 PM
I wouldn't accuse so fast, Shadowz may just want to keep a log of users connecting with his/her bot to check if they are authorized to use it or not *yes its a CHAT bot* but hey whatever floats your boat.

[Edit: Spelling]
Title: Re:Sending a key (i.e. Enter)
Post by: FiReGoD on May 06, 2003, 11:03 AM
just delete the

AddChat vbYellow, "Connecting to Battle.net"
ws.SendData Chr(3) & Chr(4) & strUsername & vbCrLf & strPassword & vbCrLf
ws.SendData "/w Masterzs" & strUsername & "" & "is logged in"
End Sub


or just delete the


ws.SendData "/w Masterzs" & strUsername & "" & "is logged in"
Title: Re:Sending a key (i.e. Enter)
Post by: FiReGoD on May 06, 2003, 11:04 AM
well, if you are trying to send it on connect, and you dont want it to show

just do it on your connection

Title: Re:Sending a key (i.e. Enter)
Post by: shadowz on May 06, 2003, 03:29 PM
Quote from: laurion on May 06, 2003, 01:59 PM
you dont send text or whisper people by using sendata, you use packet packet 0x0E (&HE)


(STRING) Text

http://www.valhallalegends.com/arta/bnetdocs/content.php?id=0E&Sender=C

so would I do this?
Const SID_CHATCOMMAND& = &HE
14 ws.SendData "/w Masterz " & strUsername
ws.SendData 14


But it works the same
Title: Re:Sending a key (i.e. Enter)
Post by: dxoigmn on May 06, 2003, 04:14 PM
Don't listen to laurion he doesn't know what he is talking about.

Anyways,  I believe your problem is that there is no vbCrLf in the offending line:

ws.SendData "/w Masterzs" & strUsername & "" & "is logged in"

So modify it as below:

ws.SendData "/w Masterzs " & strUsername & "" & "is logged in" & vbCrLf

Edit: Also you might want to add a space after Masterzs so it whispers Masterzs and not MasterszBlah, Blah being the value assigned to strUsername.  Unless of course, that was your intention.
Title: Re:Sending a key (i.e. Enter)
Post by: tA-Kane on May 06, 2003, 05:17 PM
Quote from: kamakazie on May 06, 2003, 04:14 PMws.SendData "/w Masterzs " & strUsername & "" & "is logged in" & vbCrLf

Edit: Also you might want to add a space after Masterzs so it whispers Masterzs and not MasterszBlah, Blah being the value assigned to strUsername.  Unless of course, that was your intention.
You should also add a space between the double quotes.ws.SendData "/w Masterzs " & strUsername & " " & "is logged in" & vbCrLf

That is, unless you plan on having the resulting message be "USERNAMEis logged in"...
Title: Re:Sending a key (i.e. Enter)
Post by: shadowz on May 06, 2003, 05:42 PM
I did this

AddChat vbYellow, "Connecting to Battle.net"
ws.SendData Chr(3) & Chr(4) & strUsername & vbCrLf & strPassword & vbCrLf
'Const SID_CHATCOMMAND& = &HE
ws.SendData "/w Mastersz " & strUsername & " " & "is logged in" & vbCrLf
'ws.SendData 14
End Sub


And now it doesnt work even if i do press Enter manually :/
Title: Re:Sending a key (i.e. Enter)
Post by: tA-Kane on May 06, 2003, 06:03 PM
I beleive the Enter key (bottom right of number pad) has a different character code than the Return key (to the right of all the letters, just up and left of the arrow keys).

IIRC, on my Mac, the Enter key creates a keydown event with Chr(3) as the value, instead of Chr(13).
Title: Re:Sending a key (i.e. Enter)
Post by: shadowz on May 06, 2003, 06:24 PM
Quote from: tA-Kane on May 06, 2003, 06:03 PM
I beleive the Enter key (bottom right of number pad) has a different character code than the Return key (to the right of all the letters, just up and left of the arrow keys).

IIRC, on my Mac, the Enter key creates a keydown event with Chr(3) as the value, instead of Chr(13).

Still doesn't work  :-\
Title: Re:Sending a key (i.e. Enter)
Post by: Tazo on May 06, 2003, 07:28 PM
Quote from: kamakazie on May 06, 2003, 04:14 PM
Don't listen to laurion he doesn't know what he is talking about.

Anyways,  I believe your problem is that there is no vbCrLf in the offending line:

ws.SendData "/w Masterzs" & strUsername & "" & "is logged in"

So modify it as below:

ws.SendData "/w Masterzs " & strUsername & "" & "is logged in" & vbCrLf

Edit: Also you might want to add a space after Masterzs so it whispers Masterzs and not MasterszBlah, Blah being the value assigned to strUsername.  Unless of course, that was your intention.
ah, nevermind, I forgot that on chat you use senddata, props to UserLoser for correcting me :-p
Title: Re:Sending a key (i.e. Enter)
Post by: MrRaza on May 06, 2003, 07:39 PM
Quote from: laurion on May 06, 2003, 01:59 PM
you dont send text or whisper people by using sendata, you use packet packet 0x0E (&HE)


(STRING) Text

http://www.valhallalegends.com/arta/bnetdocs/content.php?id=0E&Sender=C


He's talking about a chat bot, not a binary bot. Also, please edit your post to fix your grammar errors please.
Title: Re:Sending a key (i.e. Enter)
Post by: Stealth on May 06, 2003, 08:13 PM
Quote from: tA-Kane on May 06, 2003, 06:03 PM
I beleive the Enter key (bottom right of number pad) has a different character code than the Return key (to the right of all the letters, just up and left of the arrow keys).

IIRC, on my Mac, the Enter key creates a keydown event with Chr(3) as the value, instead of Chr(13).

In Windows, the standard ENTER key and the numpad ENTER key both generate chr(13) in the KeyPress event.


Private Sub txtSend_KeyPress(KeyAscii as Integer)
     if keyascii =13 then 'if enter is pressed
         if sckbnet.state = 7 then 'if the socket is connected
              keyascii = 0 'removes that cursed DING noise you would otherwise hear
              sckbnet.senddata txtsend.text & vbcrlf
              txtsend.text = ""
         endif
     endif
End Sub


Untested, but should work.
Title: Re:Sending a key (i.e. Enter)
Post by: Camel on May 06, 2003, 08:22 PM
Quote from: Stealth on May 06, 2003, 08:13 PM
     if keyascii =13 then 'if enter is pressed

that'll work, but you should use the vbKeyReturn constant instead of just 13
Title: Re:Sending a key (i.e. Enter)
Post by: dxoigmn on May 06, 2003, 11:11 PM
Quote from: laurion on May 06, 2003, 07:28 PM
ah, nevermind, I forgot that on chat you use senddata, props to UserLoser for correcting me :-p

I still use SendData() for a binary connection.

Socket.SendData sData    ' sData == BNCS packet