Jump to content

Array.


Recommended Posts

I'm wanting to make it so that if an array is added more than once it adds a number so the end result is like, Pan(3) because pan messaged me 3 times, frank(1) because he messaged me once, I'm not wanting it to add up in the array. I want it to at the end log who messaged me and how many times.

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
Global $Paused
Global $f = "I'm away.  The window will be closed."
Global $Number = 1
Global $GTitle = 0
AutoItSetOption("WinTitleMatchMode", 2)
#include <file.au3>
#include <array.au3>
Global ChatArray[25]

Func OnAutoItStart()
    If FileExists(@ScriptDir & "\Logs") Then
    Else
        DirCreate(@ScriptDir & "\Logs")
    EndIf
    If FileExists(@ScriptDir & "\Logs\Ammounts.log") Then
        FileDelete(@ScriptDir & "\Logs\Ammounts.log")
    EndIf
    If FileExists(@ScriptDir & "\Logs\Names.log") Then
        FileDelete(@ScriptDir & "\Logs\Names.log")
    EndIf
EndFunc  ;==>OnAutoItStart

While 1
    Sleep(100)
    If WinExists("Chat", "") Then
        $Title = WinGetTitle("Chat", "")
        $Title = $GTitle
        WinActivate("Chat", "")
        WinWaitActive("Chat", "")
        ClipPut($f)
        Send("^v" & "{ENTER}")
        Sleep(100)
        WinClose("Chat", "")
        _FileWriteLog(@ScriptDir & "\Logs\Ammounts.log", $Number)
        _FileWriteLog(@ScriptDir & "\Logs\Names.log", $Title)
        $Number = $Number + 1
        Call("Arrays")
    EndIf
    Sleep(1)
WEnd

Func Arrays()
    Local $AS = _ArraySearch(ChatArray, $Title)
    If $AS Then
    Else
        _ArrayAdd(ChatArray, $Title)
    EndIf
EndFunc

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
    WEnd
EndFunc  ;==>TogglePause

Func OnAutoItExit()
    If FileExists(@ScriptDir & "\Logs") Then
        ShellExecute(@ScriptDir & "\Logs")
    EndIf
EndFunc  ;==>OnAutoItExit

Func Terminate()
    Exit 0
EndFunc  ;==>Terminate
Link to comment
Share on other sites

No I don't want it to increase the array, because I don't know who is going to message me. I just want it to be saved in the log in the end like this.

Fan(4)

Cramps(45)

Tree(1)

Pam(1)

I can't create an array for everybody on my friends list, that would be madness, plus I couldn't give other people the script because they don't necessarily have my friends on their list.

P.S. I've been using autoit for awhile but just not got into arrays, I'm going to bed hopefully I can wake up to some answers. :)

Edited by IKilledBambi
Link to comment
Share on other sites

Then I would recommend to create a 2-dimensional array... 1 dimension with name, 2nd with count... If you receive a message you parse through the array if the senders name is somewhere in the first dimension, if not add the name in dim1 and a 1 in dim2. If senders name is found just add 1 to dim2...

Link to comment
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
 Share

  • Recently Browsing   0 members

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