Valhalla Legends Forums Archive | Battle.net Bot Development | Sending a key (i.e. Enter)

AuthorMessageTime
shadowz
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
May 4, 2003, 8:46 AM
dRAgoN
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)
May 4, 2003, 9:16 AM
shadowz
Here are some coding

[code]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[/code]


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.]
May 4, 2003, 9:35 AM
dRAgoN
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.
May 4, 2003, 9:46 AM
kamakazie
[quote author=shadowz link=board=5;threadid=1226;start=0#msg9128 date=1052040918]
If KeyAscii = 13 Then
If ws.State = 7 Then
[/quote]

vbKeyReturn
sckConnected
May 4, 2003, 10:26 AM
shadowz
Didn't work
May 4, 2003, 10:32 AM
tA-Kane
[quote author=shadowz link=board=17;threadid=1226;start=0#msg9128 date=1052040918]Here are some coding[/quote]Shadows, I would appreciate it if you would use the integrated code tags.
[ code ]Remove spaces for the tags to work.[ /code ]
May 4, 2003, 9:16 PM
SubLiminaL_WolF
i dont think that is right to put in a backdoor in ur bot ::) :o :'(
May 6, 2003, 2:16 AM
Crypticflare
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]
May 6, 2003, 3:15 AM
FiReGoD
just delete the
[code]
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
[/code]

or just delete the

[code]
ws.SendData "/w Masterzs" & strUsername & "" & "is logged in"
[/code]
May 6, 2003, 4:03 PM
FiReGoD
well, if you are trying to send it on connect, and you dont want it to show

just do it on your connection

May 6, 2003, 4:04 PM
shadowz
[quote author=laurion link=board=17;threadid=1226;start=0#msg9258 date=1052247574]
you dont send text or whisper people by using sendata, you use packet packet 0x0E (&HE)

[code]
(STRING) Text
[/code]
http://www.valhallalegends.com/arta/bnetdocs/content.php?id=0E&Sender=C
[/quote]

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

But it works the same
May 6, 2003, 8:29 PM
kamakazie
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:

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

So modify it as below:

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

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.
May 6, 2003, 9:14 PM
tA-Kane
[quote author=kamakazie link=board=17;threadid=1226;start=0#msg9261 date=1052255685][code]ws.SendData "/w Masterzs " & strUsername & "" & "is logged in" & vbCrLf[/code]

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.
[/quote]You should also add a space between the double quotes.[code]ws.SendData "/w Masterzs " & strUsername & " " & "is logged in" & vbCrLf[/code]

That is, unless you plan on having the resulting message be "USERNAMEis logged in"...
May 6, 2003, 10:17 PM
shadowz
I did this

[code]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[/code]

And now it doesnt work even if i do press Enter manually :/
May 6, 2003, 10:42 PM
tA-Kane
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).
May 6, 2003, 11:03 PM
shadowz
[quote author=tA-Kane link=board=17;threadid=1226;start=15#msg9273 date=1052262220]
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).
[/quote]

Still doesn't work :-\
May 6, 2003, 11:24 PM
laurion
[quote author=kamakazie link=board=17;threadid=1226;start=0#msg9261 date=1052255685]
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:

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

So modify it as below:

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

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.
[/quote]
ah, nevermind, I forgot that on chat you use senddata, props to UserLoser for correcting me :-p
May 7, 2003, 12:28 AM
MrRaza
[quote author=laurion link=board=17;threadid=1226;start=0#msg9258 date=1052247574]
you dont send text or whisper people by using sendata, you use packet packet 0x0E (&HE)

[code]
(STRING) Text
[/code]
http://www.valhallalegends.com/arta/bnetdocs/content.php?id=0E&Sender=C
[/quote]


He's talking about a chat bot, not a binary bot. Also, please edit your post to fix your grammar errors please.
May 7, 2003, 12:39 AM
Stealth
[quote author=tA-Kane link=board=17;threadid=1226;start=15#msg9273 date=1052262220]
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).
[/quote]

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

[code]
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
[/code]

Untested, but should work.
May 7, 2003, 1:13 AM
Camel
[quote author=Stealth link=board=17;threadid=1226;start=15#msg9281 date=1052269999][code]
if keyascii =13 then 'if enter is pressed
[/code][/quote]

that'll work, but you should use the vbKeyReturn constant instead of just 13
May 7, 2003, 1:22 AM
kamakazie
[quote author=laurion link=board=17;threadid=1226;start=15#msg9279 date=1052267300]
ah, nevermind, I forgot that on chat you use senddata, props to UserLoser for correcting me :-p
[/quote]

I still use SendData() for a binary connection.

[code]Socket.SendData sData ' sData == BNCS packet[/code]
May 7, 2003, 4:11 AM

Search