• Welcome to Valhalla Legends Archive.
 

KeyPress

Started by Yegg, November 09, 2004, 03:20 PM

Previous topic - Next topic

Yegg

im not sur y but my bots txtSend_KeyPress stopped working, whenever i hit enter to send a message it does absolutely nothing, it doesn't send and it doesn't get an error. take a look at the following code is there something wrong with it?

Private Sub txtSend_KeyPress(KeyAscii As Integer)
    If KeyAscii = "13" Then
        If Len(Form1.txtSend.Text) >= 1 Then
        pbuffer.InsertNTString Form1.txtSend.Text
        pbuffer.sendPacket &HE
        txtSend.Text = ""
        KeyAscii = "0"
        End If
    End If
End Sub


(also, how can i find out the ascii number for all the letters and numbers?)

The-FooL

#1
Why are you comparing KeyAscii to a string?

Yegg

hmm, well i've always done keypress this way and its worked fine. i just dont c how that should make a difference.

Stealth

KeyAscii is a numeric value. There's no reason to treat it as a string literal, which is exactly the result of putting quotes around it. It forces your computer to do more thinking, wasting (albeit a minute amount of) time and clock cycles.
- Stealth
Author of StealthBot

Yegg

ok now, i have the following code and it does the same thing as before.

Private Sub txtSend_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        If Len(Form1.txtSend.Text) >= 1 Then
        pbuffer.InsertNTString Form1.txtSend.Text
        pbuffer.SendPacket &HE
        Form1.txtSend.Text = ""
        KeyAscii = 0
        End If
    End If
End Sub


i dont get y this isn't working when the exact same code works on my other bot. is it possinble that im missing something in PacketBuffer.cls?

UserLoser.

It looks fine to me.  My guess is you're thinking the Battle.net server is supposed to echo back to you your own chat messages like any other sent a chat message, well, it doesn't.  What happens if you try sending "/time"?

Yegg

#6
when i do /time the bot doesn't do ne thing because it isn't sending messages 2 battle.net. it seems a lot like its not reading the ascii character. is the following code in my packetbuffer correct?


Public Function InsertNTString(data As String)
    Buffer = Buffer & data & Chr(0)
End Function

Public Function SendPacket(PacketID As Byte)
If Form1.wsBNET.State <> sckConnected Then: Exit Function
    Form1.wsBNET.SendData Chr(&HFF) & Chr(PacketID) & MakeWORD(Len(Buffer) + 4) & Buffer
    Clear
End Function

Dyndrilliac

Some general pointers, may or may not help

1) Use constants. (I.E., 13 becomes vbKeyReturn)

2) What's the point in doing "KeyAscii = 0"?

3) You're not doing a check to make sure your connected before inserting a null terminated string which could probably cause wierd shit to happen.

4) Make sure the text curso is in the text box at the time you press enter and the object is "In Focus".

5) Instead of checking the length of the string being sent, do "if not string = vbNullstring or string = space$(len(string))"
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

Newby

Quote from: Stealth on November 09, 2004, 03:35 PM
It forces your computer to do more thinking, wasting (albeit a minute amount of) time and clock cycles.
If you're so worried about losing that many clock cycles, you wouldn't be programming in Visual Basic. ;)
- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

hismajesty

Quote2) What's the point in doing "KeyAscii = 0"?

To stop the computer from beeping.

Yegg

#10
ok, now im really confused, i read wut u told me to do dyndrillaid (cant spell ur name unless i look) and heres the following code.

Private Sub txtSend_KeyPress(KeyAscii As Integer)
txtSend.SetFocus
    If KeyAscii = "13" Then
            pbuffer.InsertNTString txtSend.Text
            pbuffer.SendPacket &HE
            txtSend.Text = ""
            KeyAscii = "0"
    End If
End Sub

im a lil confused with this, it only sends the message when i hit enter and shift at the same time? even when i dont use the quotes around 13 and 0 it still functions the same way. how do i fix this?

Warrior

why the hell do you have a set focus? If you already pressed enter woudlnt you still be in focus?
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

Yegg

im not sur y i have setfocus, i wus jus trying some stuff. apparently it didn't help either. also, i updated my post as u sent ur message. ok, i took out setfocus, it functions the same way still.

Dyndrilliac

Quote from: Yegg on November 13, 2004, 11:21 AM
ok, now im really confused, i read wut u told me to do dyndrillaid (cant spell ur name unless i look) and heres the following code.

Private Sub txtSend_KeyPress(KeyAscii As Integer)
txtSend.SetFocus
    If KeyAscii = "13" Then
            pbuffer.InsertNTString txtSend.Text
            pbuffer.SendPacket &HE
            txtSend.Text = ""
            KeyAscii = "0"
    End If
End Sub


im a lil confused with this, it only sends the message when i hit enter and shift at the same time? even when i dont use the quotes around 13 and 0 it still functions the same way. how do i fix this?

The value of KeyAscii is an integer. Stop comparing-it-with/assigning-it a string (KeyAscii = "0" & If KeyAscii = "13").

Do: if keyascii = vbkeyreturnandkeyascii = 0

Do the set focus when the Text Box is not in focus,

Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

Warrior

* Warrior wonders how in the hell he made a Bot
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?