Jump to content

Help with a script Im working on


Recommended Posts

I'm working a script for the browser game Evony, which will alert you of Incoming attacks via Audible alert or Cell Phone Text.

Im having a few problems though, only one part of the script works, depending on which one comes first. If I switch the one that does sound to come before the one that does text, the sound works and vise versa. See below:

While 1
While $TOn = True
Do
$coord = PixelSearch( $CoordX, $CoordY, $CoordX, $CoordY, 0xAA150E, 20 )
If Not @error Then _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
Until Not @error
Sleep(3600000)
WEnd
WEnd

While 1
While $AOn = True
$coord = PixelSearch( $CoordX, $CoordY, $CoordX, $CoordY, 0xAA150E, 20 ) 
If Not @error Then Alert($coord, $AlarmSound)
WEnd
WEnd

Not quite sure what Im doing wrong but any help to point me in the right direction would be great. The Whole scipt and config file is below:

;##################################
; Include
;##################################
#Include<file.au3>

;##################################
; Audio Hotkey Startup
;##################################
HotKeySet("{F5}", "AStartStop")
$AOn = False

;##################################
; Text/Email Hotkey Startup
;##################################
HotKeySet("{F6}", "TStartStop")
$TOn = False

;##################################
; Variables
;##################################
Global $CellEmail = IniRead("Config.ini", "Text", "CellPhoneEmail", "NotFound")
Global $SmtpServer = "smtp.mail.yahoo.com"         
Global $FromName = "Evony Attack Alarm"        
Global $FromAddress = "***********@yahoo.com" 
Global $ToAddress = $CellEmail
Global $Subject = "You're Being Attacked!"                  
Global $Body = "Please log into Evony right away, You are being attacked by an Enemy!"                              
Global $AttachFiles = ""                       
Global $CcAddress = ""       
Global $BccAddress = ""     
Global $Importance = "High"                  
Global $Username = "*******"                    
Global $Password = "*******"                  
Global $IPPort = 465  
Global $ssl = 1  
Global $CoordX = IniRead("Config.ini", "CordX", "x", "NotFound")
Global $CoordY = IniRead("Config.ini", "CordY", "y", "NotFound")
Global $AlarmSound = IniRead("Config.ini", "Alarm", "Alarm", "NotFound")


While 1
While $TOn = True
Do
$coord = PixelSearch( $CoordX, $CoordY, $CoordX, $CoordY, 0xAA150E, 20 )
If Not @error Then _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
Until Not @error
Sleep(3600000)
WEnd
WEnd

While 1
While $AOn = True
$coord = PixelSearch( $CoordX, $CoordY, $CoordX, $CoordY, 0xAA150E, 20 ) 
If Not @error Then Alert($coord, $AlarmSound)
WEnd
WEnd


;##################################
; Audio Hotkey Function
;##################################                          

Func AStartStop()
If $AOn = False Then
$AOn = True
MsgBox(0, "Evony Attack Alarm", "Audible Alarm Enabled.")
Else
$AOn = False
MsgBox(0, "Evony Attack Alarm", "Audible Alarm Disabled.")
EndIf
EndFunc

;##################################
; Text Hotkey Function
;##################################  
Func TStartStop()
If $TOn = False Then
$TOn = True
MsgBox(0, "Evony Attack Alarm", "Text Message Alarm Enabled.")
Else
$TOn = False
MsgBox(0, "Evony Attack Alarm", "Text Message Alarm Disabled.")
EndIf
EndFunc

;##################################
; Audible Alert Function
;################################## 

Func Alert($coord, $ColAlert = "Alert")
Local $temp, $File
$temp = StringReplace($ColAlert & " " & $ColAlert, " ", "+")
$File = StringRegExpReplace($ColAlert, "([ .,!])", "") 
If Not FileExists(@TempDir & "\" & $File & ".mp3") Then _
InetGet("http://translate.google.com/translate_tts?q=" & $temp, _
@TempDir & "\" & $File & ".mp3")
SoundPlay(@TempDir & "\" & $File & ".mp3", 1)
Return
EndFunc ;==>Alert

;##################################
; Text/Email Script
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc)
EndIf

;##################################
; Text/Email Function
;##################################
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
        $objEmail.HTMLBody = $as_Body
    Else
        $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
;~          ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
            If FileExists($S_Files2Attach[$x]) Then
                ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF)
                $objEmail.AddAttachment($S_Files2Attach[$x])
            Else
                ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
                SetError(1)
                Return 0
            EndIf
        Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 then $IPPort = 25
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Set email Importance
    Switch $s_Importance
        Case "High"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
        Case "Normal"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
        Case "Low"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
    ; Sent the Message
    $objEmail.Send
    
    If @error Then
        SetError(2)
        Return $oMyRet[1]
    EndIf
    $objEmail=""
EndFunc  

;##################################
; Error Function
;##################################
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
EndFunc

[CordX]
x=315

[CordY]
y=727

[Alarm]
Alarm=Enemy Attack!


[Text]
CellPhoneEmail=**********@yahoo.com
Link to comment
Share on other sites

http://www.autoitscript.com/forum/index.php?showannouncement=11&f=2

Have you read that?

I would hardly call it a bot, it doesent automate one thing in that game. It Just looks for pixel changes at a certain coord on the screen. So not really sure how that rule applies to this, looking at the code should tell you that.

I'm asking for help, to point me in the right direction.

Edited by SilverDeath
Link to comment
Share on other sites

  • Moderators

SilverDeath,

it doesent automate one thing in that game. It Just looks for pixel changes at a certain coord on the screen

Sounds like a bot to me! What else would you call a script which does something you should be doing yourself when you play? :P

I'm asking for help

And as the announcement makes quite clear, you are not going to receive any here. :blink:

For your own sake, please do not persist. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thats fine if you say it automates the game, then ok. Please delete this topic.

Ill repost a new one with the evony stuff ommitted. I had a change of heart afterall, I now intend to use this script to alert me when a intant message window pops up. :blink:

Link to comment
Share on other sites

  • Developers

Thats fine if you say it automates the game, then ok. Please delete this topic.

Ill repost a new one with the evony stuff ommitted. I had a change of heart afterall, I now intend to use this script to alert me when a intant message window pops up. :blink:

Nah, just leave is better.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 11 years later...
  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...