I've written a fairly good console chatbot over the past few days.. except.. it can't chat. Does anyone have any idea how I'd send messages from a console without the bot specifically asking for them?
EDIT -
Perhaps I should ask for a message, get on with life, and once ones finally returned, repeat?
No go. It stops all events until a message is returned. If it was simply the way I did it..
On CSB_LoggedOnAs:
Call StartChat()
My StartChat Sub
Public Sub StartChat()
Dim S as String
Let S = Console.ReadText()
Call frmCSBEvents.CSB.Send(CStr(S))
Call AddChat("<" & frmCSBEvents.CSB.Username & "> " & CStr(S))
End Sub
QuoteDoes anyone have any idea how I'd send messages from a console without the bot specifically asking for them?
The same way you would from a non-console app.
QuoteThe same way you would from a non-console app.
Okay, lets do it your way then. Does anybody know how I can load a textbox on my console that I can type in? No? Hrm, must not be the same way.
QuoteEDIT -
No go. It stops all events until a message is returned. If it was simply the way I did it..
Generally that's solved by putting
ReadConsoleInput (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/readconsoleinput.asp)() in an infinite loop in main() and creating a seperate thread for other functions.
Quote from: Joex86] link=topic=11667.msg113392#msg113392 date=1116787212]
QuoteThe same way you would from a non-console app.
Okay, lets do it your way then. Does anybody know how I can load a textbox on my console that I can type in? No? Hrm, must not be the same way.
CreateWindow (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/createwindow.asp)().
How do I use a second thread in VisualBasic?
CreateThread (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createthread.asp)().
*rofl* Lord
Does anybody want to help me here? All I can get out of what LoRd[nK] is telling me is that I need to use an API call.
Click the links.
Quote from: Joex86] link=topic=11667.msg113404#msg113404 date=1116790002]
Does anybody want to help me here? All I can get out of what LoRd[nK] is telling me is that I need to use an API call.
Were you expecting this to be easy?
well he got baby fed the console code, so I'd assume yes :p
DarkMinion supplied a simple example a long time ago. It is here (http://www.valhallalegends.com/dmsource.htm). Yes, it's in C++, but it's no harder to translate it into VB code than it would be to read documentation somewhere else.
Don't use _beginthread() and _endthread(), use CreateThread() and ExitThread(), or don't use any at all and just find a workaround for it which shouldn't be too hard
Use WinExec()
Quote from: 111787 on May 22, 2005, 04:31 PM
Use WinExec()
WinExec (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/winexec.asp)() doesn't create a new thread. It executes an application.
I would honestly look into VB Express or VB.Net and do multi-threading that way. Its muchos easier imho.
@LoRd and Warrior: Awesome! I got it working thanks to you guys! No.
Quote from: Joex86] link=topic=11667.msg113636#msg113636 date=1116975156]
@LoRd and Warrior: Awesome! I got it working thanks to you guys! No.
I've provided you with all that you need short of the actual code. If all you wanted was to steal someone elses work, you should have said so.
Since you're not willing to do any actual work, perhaps you should Google up a control that has it already done for you.
Quote from: Joex86] link=topic=11667.msg113636#msg113636 date=1116975156]
@LoRd and Warrior: Awesome! I got it working thanks to you guys! No.
The easiest way to do it would be to make the form have a textbox and minimize it to the tray when you are not using it. That is what I did anyway.
=/. Well, LoRd[nK], perhaps if MSDN wasn't so confusing, I'd be willing to do it. All their examples are in C-ish syntax, and their explinations use terms foreign to me, so no. Just no.
I don't get how you can't port it..you know data types right? You know the structure of an API call right? At the bottom it tells you the library to use and everything, it's easy.
Indeed, the MSDN pages are done in such a way that the content can be easily translated across multiple languages.
Quote from: Forged on May 27, 2005, 03:40 PM
Quote from: Joex86] link=topic=11667.msg113636#msg113636 date=1116975156]
@LoRd and Warrior: Awesome! I got it working thanks to you guys! No.
The easiest way to do it would be to make the form have a textbox and minimize it to the tray when you are not using it. That is what I did anyway.
What "form?" He's writing a console app in VB (eww >:().
By default all vb programs still have a form, you just hide it when you launch the console.
Quote from: Forged on May 30, 2005, 05:37 PM
By default all vb programs still have a form
No they don't.
Quote from: LoRd[nK] on May 30, 2005, 07:08 PM
Quote from: Forged on May 30, 2005, 05:37 PM
By default all vb programs still have a form
No they don't.
I think he means with default VB IDE settings, when you create a new 'Standard EXE' project, it has a form already there named 'Form1'
Quote from: UserLoser on May 30, 2005, 07:34 PM
Quote from: LoRd[nK] on May 30, 2005, 07:08 PM
Quote from: Forged on May 30, 2005, 05:37 PM
By default all vb programs still have a form
No they don't.
I think he means with default VB IDE settings, when you create a new 'Standard EXE' project, it has a form already there named 'Form1'
Yes, but you don't have to use it... or even bother to hide it; just remove it and set the program to start in main().
I don't really see a point in adding a window to a console program... you can type directly from a console and by adding a window you'd defeat the purpose of using a console at all.
I believe what you want done can be accomplished, without creating threads, by using WaitForMultipleObjects() (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/waitformultipleobjects.asp) -- along with the console's stdin and socket's handles.
Edit: Actually, I think you'd need to use select(), because WaitForMultipleObjects doesn't allow socket descriptors.
Use a message or network loop? It's quite easily possible to 'trick' VB into executing a non-stop loop using DoEvents as a your message loop while still performing other functions.
Quote from: LoRd[nK] on May 30, 2005, 07:51 PM
Quote from: UserLoser on May 30, 2005, 07:34 PM
Quote from: LoRd[nK] on May 30, 2005, 07:08 PM
Quote from: Forged on May 30, 2005, 05:37 PM
By default all vb programs still have a form
No they don't.
I think he means with default VB IDE settings, when you create a new 'Standard EXE' project, it has a form already there named 'Form1'
Right, but he has been stupified by your responses to his question.
Yes, but you don't have to use it... or even bother to hide it; just remove it and set the program to start in main().
I don't really see a point in adding a window to a console program... you can type directly from a console and by adding a window you'd defeat the purpose of using a console at all.
Aha, DoEvents. THANK YOU USERLOSER!!! <33.
Thanks to everyone else who tried to help too. <33.
My way of doing it (though C++ oriented, you could do it in VB I think).
I have not tested it yet, but I believe with the API MsgWaitForMultipleObjects(...) you can wait on STD output handles, which in turn could allow you to actively be in a state of accepting console text, which you can have the user input and then send those to battle.net when that handle triggers.
You could also create a new thread dedicated to Battle.net message I/O. Have it wait for user input, send the message, display the results, and repeat.
Quote from: NicoQwertyu on May 30, 2005, 11:00 PM
I believe what you want done can be accomplished, without creating threads, by using WaitForMultipleObjects() (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/waitformultipleobjects.asp) -- along with the console's stdin and socket's handles.
Edit: Actually, I think you'd need to use select(), because WaitForMultipleObjects doesn't allow socket descriptors.