Search the Community
Showing results for tags 'event mode'.
-
Hi All, I am developing an IRC Bot and have come across a small problem. Everything works fine until the ConnectToIRC function is called. This is when a while Loop is in play, I assume this is because the while loop is hogging the program and blocking other commands. so my question, Is there a way around this or a way I could do this differently so that I can receive data when it comes in and also use controls on the gui? If I remove the while loop inside the ConnectToIRC function, Other gui buttons work correctly (Close Button for example) Thanks for any help or insight you may provide. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GUIEdit.au3> #Include <ScrollBarConstants.au3> #include <ComboConstants.au3> #Include <Array.au3> Opt("GUIOnEventMode", 1) $Form1 = GUICreate("AutoIT IRCBot", 537, 339, 192, 124) $Edit1 = GUICtrlCreateEdit("", 8, 8, 521, 257, $ES_AUTOVSCROLL + $WS_VSCROLL) $btnSend = GUICtrlCreateButton("Send", 456, 304, 73, 25) $inIRCServ = GUICtrlCreateInput("irc.freenode.net", 8, 272, 97, 21) $inPort = GUICtrlCreateInput("6667", 112, 272, 65, 21) $inChat = GUICtrlCreateInput("", 288, 304, 161, 21) $btnCon = GUICtrlCreateButton("Connect", 184, 272, 73, 25) $Combo1 = GUICtrlCreateCombo("Channel", 288, 272, 161, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseBot") GUICtrlSetOnEvent($btnCon, "ConnectToIRC") GUICtrlSetOnEvent($btnSend, "IRCSend") GUISetState(@SW_SHOW) TCPStartup() ;~ Read INI Values Global $vIRCNick = IniRead("ircbot.ini", "information", "Nick", "AutoITIRCBot") Global $vIRCAltNick = IniRead("ircbot.ini", "information", "AltNick", "AutoITIRCBot_") Global $vIRCRealName = IniRead("ircbot.ini", "information", "RealName", "AutoITIRCBot") Global $vIRCChannels = IniRead("ircbot.ini", "information", "Channels", "#AutoITIRCBot") $vChanArr = StringSplit($vIRCChannels, "|") While 1 Sleep(100) WEnd Func ConnectToIRC() GUICtrlSetState($btnCon, $GUI_DISABLE) GUICtrlSetState($inIRCServ, $GUI_DISABLE) GUICtrlSetState($inPort, $GUI_DISABLE) $vIRCServer = TCPNameToIP(GuiCtrlRead($inIRCServ)) $vIRCPort = GuiCtrlRead($inPort) $vConnect = TCPConnect($vIRCServer, $vIRCPort) TCPSend($vConnect, "USER " & $vIRCNick & " 0 0 :" & $vIRCRealName & @CRLF) TCPSend($vConnect, "NICK " & $vIRCNick & @CRLF) For $i = 1 to Ubound($vChanArr) -1 TCPSend($vConnect, "JOIN " & $vChanArr[$i] & @CRLF) GUICtrlSetData($Combo1, $vChanArr[$i], $vChanArr[$i]) Next While 1 $vRecv = TCPRecv($vConnect, 4096) If $vRecv <> "" Then GuiCtrlSetData($Edit1, $vRecv, 1) EndIf Wend EndFunc Func CloseBot() Exit EndFunc Ini File [information] Nick=UKTestBot AltNick=UKTestBot_ RealName=UKTestBOT Channels=#test333|#test222
- 2 replies
-
- while loop
- gui
-
(and 1 more)
Tagged with: