Sign in to follow this  
Followers 0
DoubleMcLovin

Retrieve text from an mIRC window.

7 posts in this topic

I am trying to make a bot that will wait for a regex statement in mIRC and reply accordingly. I have some of the basic mechanics set up, and I think I can probably even get it to post. I only have 2 problems:

1) Determining the ID# of the text field automatically (so that I can send through the right area)

2) ControlGetText even on the proper ID of the window cannot retrieve correct text, it always gets my active windows rather than the text in the window no matter which area I select.

Share this post


Link to post
Share on other sites



Why don't you use the mIRC scripting language for that?

You can use that for finding the text, then export it somewhere (create a window with the text or a file), use the text with AutoIt, and whatever reply you have, save it back to the file and have mIRC take it and use it...

Using only AutoIt to control mIRC won't be that easy and using mIRC for the bot won't be that powerful, conbine them in some way and you might make it work....


s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

FYI spam bots and the like a frowned upon. Unless you want to explain your full intentions...

Def. Not a spam bot. I want the bot to be capable of interpreting text, such as when someone says "How do I register my nick?" The bot will pick up on a regex statement something like (?i)How.*register.*nick (my regex is a little rusty). and will reply with a pm telling the individual how to register their nick. I had one I had worked out in perl using some ideas from other scripts that I played around with until it worked, but my HDD died on me so I lost that, and I would like to code one from scratch now. If I just wanted the spambot it wouldn't be too difficult to use autoit to just send keystrokes. I want to be able to interpret text in the channel which should stand to prove I do not plan on being a spammer with this.

I will look into a way to use the mIRC language along with this, I'd image I can create a file that flushes after 100kb or something, but with the large quantities of text flowing through some channels that might prove rather inefficient a method. Surely there is a way to get autoit to read directly from the window?

Edited by DoubleMcLovin

Share this post


Link to post
Share on other sites

I have, the best I could find were 2 scripts in C++ and Perl. No one had any insight for using autoIt

Share this post


Link to post
Share on other sites

Best option, use the AutoIt IRC library instead of botting through automation. It's perfectly functional.

Note: This is not my code, I just updated it to fix the PONG, the code is in the examples forum.

;===============================================================================
;
; Description:  Connects you to a IRC Server, and gives your chosen Nick
; Parameter(s):     $server - IRC Server you wish to connect to
;   $port - Port to connect to (Usually 6667)
;   $nick - Nick you choose to use (You can change later)
; Requirement(s): TCPStartup () to be run
; Return Value(s): On Success - Socket identifer
;   On Failure - It will exit on error
; Author(s):    Chip
; Note(s):  English only
;
;===============================================================================
Func _IRCConnect ($server, $port, $nick)
    Local $i = TCPConnect(TCPNameToIP($server), $port)
    If $i = -1 Then Exit MsgBox(1, "IRC.au3 Error", "Server " & $server & " is not responding.")
    TCPSend($i, "NICK " & $nick & @CRLF)
    TCPSend($i, "USER " & $nick & " 0 0 " & $nick &@CRLF)
    Return $i
EndFunc

;===============================================================================
;
; Description:  Joins an IRC Channel
; Parameter(s):     $irc - Socket Identifer from _IRCConnect ()
;   $chan - Channel you wish to join
; Requirement(s): _IRCConnect () to be run
; Return Value(s): On Success - 1
;   On Failure - -1 = Server disconnected.
; Author(s):    Chip
; Note(s):  English only
;
;===============================================================================
Func _IRCJoinChannel ($irc, $chan)
    If $irc = -1 Then Return 0
    TCPSend($irc, "JOIN " & $chan & @CRLF)
    If @error Then
        MsgBox(1, "IRC.au3", "Server has disconnected. 1")
        Return -1
    EndIf
    Return 1
EndFunc

;===============================================================================
;
; Description:  Sends a message using IRC
; Parameter(s):     $irc - Socket Identifer from _IRCConnect ()
;                   $msg - Message you want to send
;   $chan - Channel/Nick you wish to send to
; Requirement(s): _IRCConnect () to be run
; Return Value(s): On Success - 1
;   On Failure - -1 = Server disconnected.
; Author(s):    Chip
; Note(s):  English only
;
;===============================================================================
Func _IRCSendMessage ($irc, $msg, $chan="")
    If $irc = -1 Then Return 0
    If $chan = "" Then
        TCPSend($irc, $msg & @CRLF)
        If @error Then
            MsgBox(1, "IRC.au3", "Server has disconnected. 3")
            Return -1
        EndIf
        Return 1
    EndIf
    TCPSend($irc, "PRIVMSG " & $chan & " :" & $msg & @CRLF)
        If @error Then
        MsgBox(1, "IRC.au3", "Server has disconnected. 4")
        Return -1
    EndIf
    Return 1
EndFunc

;===============================================================================
;
; Description:  Changes a MODE on IRC
; Parameter(s):     $irc - Socket Identifer from _IRCConnect ()
;                   $mode - Mode you wish to change
;   $chan - Channel/Nick you wish to send to
; Requirement(s): _IRCConnect () to be run
; Return Value(s): On Success - 1
;   On Failure - -1 = Server disconnected.
; Author(s):    Chip
; Note(s):  English only
;
;===============================================================================
Func _IRCChangeMode ($irc, $mode, $chan="")
    If $irc = -1 Then Return 0
    If $chan = "" Then
        TCPSend($irc, "MODE " & $mode & @CRLF)
        If @error Then
        MsgBox(1, "IRC.au3", "Server has disconnected. 5")
        Return -1
    EndIf
    Return 1
    EndIf
    TCPSend($irc, "MODE " & $chan & " " & $mode & @CRLF)
        If @error Then
        MsgBox(1, "IRC.au3", "Server has disconnected. 6")
        Return -1
    EndIf
    Return 1
EndFunc

;===============================================================================
;
; Description:  Returns a PING to Server
; Parameter(s):     $irc - Socket Identifer from _IRCConnect ()
;                   $ret - The end of the PING to return
; Requirement(s): _IRCConnect () to be run
; Return Value(s): On Success - 1
;   On Failure - -1 = Server disconnected.
; Author(s):    Chip
; Note(s):  English only
;
;===============================================================================
Func _IRCPing($irc, $ret)
    If $ret = "" Then Return -1
    TCPSend($irc, "PONG " & $ret & @CRLF)
        If @error Then
        MsgBox(1, "IRC.au3", "Server has disconnected. 2")
        Return -1
    EndIf
    ConsoleWrite("PONG" & $ret & @CRLF)
    Return 1
EndFunc

You can use that to connect and interact with IRC networks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0