Author | Message | Time |
---|---|---|
JoeTheOdd | 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 - [s]Perhaps I should ask for a message, get on with life, and once ones finally returned, repeat?[/s] No go. It stops all events until a message is returned. If it was simply the way I did it.. On CSB_LoggedOnAs: [code]Call StartChat()[/code] My StartChat Sub [code]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[/code] | May 22, 2005, 6:31 PM |
LoRd | [quote]Does anyone have any idea how I'd send messages from a console without the bot specifically asking for them?[/quote] The same way you would from a non-console app. | May 22, 2005, 6:38 PM |
JoeTheOdd | [quote]The same way you would from a non-console app.[/quote] 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. | May 22, 2005, 6:40 PM |
LoRd | [quote]EDIT - No go. It stops all events until a message is returned. If it was simply the way I did it..[/quote] Generally that's solved by putting ReadConsoleInput() in an infinite loop in main() and creating a seperate thread for other functions. | May 22, 2005, 6:44 PM |
LoRd | [quote author=Joe[x86] link=topic=11667.msg113392#msg113392 date=1116787212] [quote]The same way you would from a non-console app.[/quote] 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. [/quote] CreateWindow(). | May 22, 2005, 6:48 PM |
JoeTheOdd | How do I use a second thread in VisualBasic? | May 22, 2005, 6:58 PM |
LoRd | CreateThread(). | May 22, 2005, 7:01 PM |
Quarantine | *rofl* Lord | May 22, 2005, 7:23 PM |
JoeTheOdd | 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. | May 22, 2005, 7:26 PM |
hismajesty | Click the links. | May 22, 2005, 8:06 PM |
LoRd | [quote author=Joe[x86] 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. [/quote] Were you expecting this to be easy? | May 22, 2005, 8:10 PM |
Quarantine | well he got baby fed the console code, so I'd assume yes :p | May 22, 2005, 8:22 PM |
UserLoser. | DarkMinion supplied a simple example a long time ago. It is here. 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 | May 22, 2005, 9:26 PM |
111787 | Use WinExec() | May 22, 2005, 9:31 PM |
LoRd | [quote author=111787 link=topic=11667.msg113428#msg113428 date=1116797474] Use WinExec() [/quote] WinExec() doesn't create a new thread. It executes an application. | May 22, 2005, 10:00 PM |
Imperceptus | I would honestly look into VB Express or VB.Net and do multi-threading that way. Its muchos easier imho. | May 23, 2005, 1:35 AM |
JoeTheOdd | @LoRd and Warrior: Awesome! I got it working thanks to you guys! No. | May 24, 2005, 10:52 PM |
LoRd | [quote author=Joe[x86] link=topic=11667.msg113636#msg113636 date=1116975156] @LoRd and Warrior: Awesome! I got it working thanks to you guys! No. [/quote] 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. | May 25, 2005, 12:09 AM |
Forged | [quote author=Joe[x86] link=topic=11667.msg113636#msg113636 date=1116975156] @LoRd and Warrior: Awesome! I got it working thanks to you guys! No. [/quote] 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. | May 27, 2005, 8:40 PM |
JoeTheOdd | =/. 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. | May 27, 2005, 10:24 PM |
Quarantine | 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. | May 28, 2005, 12:52 AM |
hismajesty | Indeed, the MSDN pages are done in such a way that the content can be easily translated across multiple languages. | May 28, 2005, 3:03 AM |
NicoQwertyu | [quote author=Forged link=topic=11667.msg113936#msg113936 date=1117226420] [quote author=Joe[x86] link=topic=11667.msg113636#msg113636 date=1116975156] @LoRd and Warrior: Awesome! I got it working thanks to you guys! No. [/quote] 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. [/quote] What "form?" He's writing a console app in VB (eww >:(). | May 30, 2005, 5:14 PM |
Forged | By default all vb programs still have a form, you just hide it when you launch the console. | May 30, 2005, 10:37 PM |
LoRd | [quote author=Forged link=topic=11667.msg114236#msg114236 date=1117492661] By default all vb programs still have a form [/quote] No they don't. | May 31, 2005, 12:08 AM |
UserLoser. | [quote author=LoRd[nK] link=topic=11667.msg114254#msg114254 date=1117498126] [quote author=Forged link=topic=11667.msg114236#msg114236 date=1117492661] By default all vb programs still have a form [/quote] No they don't. [/quote] 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' | May 31, 2005, 12:34 AM |
LoRd | [quote author=UserLoser link=topic=11667.msg114257#msg114257 date=1117499693] [quote author=LoRd[nK] link=topic=11667.msg114254#msg114254 date=1117498126] [quote author=Forged link=topic=11667.msg114236#msg114236 date=1117492661] By default all vb programs still have a form [/quote] No they don't. [/quote] 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] 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. | May 31, 2005, 12:51 AM |
NicoQwertyu | I believe what you want done can be accomplished, without creating threads, by using WaitForMultipleObjects() -- 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. | May 31, 2005, 4:00 AM |
UserLoser. | 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. | May 31, 2005, 4:48 AM |
Forged | [quote author=LoRd[nK] link=topic=11667.msg114258#msg114258 date=1117500716] [quote author=UserLoser link=topic=11667.msg114257#msg114257 date=1117499693] [quote author=LoRd[nK] link=topic=11667.msg114254#msg114254 date=1117498126] [quote author=Forged link=topic=11667.msg114236#msg114236 date=1117492661] By default all vb programs still have a form [/quote] No they don't. [/quote] 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] 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. [/quote] | May 31, 2005, 3:29 PM |
JoeTheOdd | Aha, DoEvents. THANK YOU USERLOSER!!! <33. Thanks to everyone else who tried to help too. <33. | June 2, 2005, 4:53 PM |
Mephisto | 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. | June 3, 2005, 9:51 PM |
NicoQwertyu | [quote author=NicoQwertyu link=topic=11667.msg114266#msg114266 date=1117512051] I believe what you want done can be accomplished, without creating threads, by using WaitForMultipleObjects() -- 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. [/quote] | June 4, 2005, 2:41 AM |