Sign in to follow this  
Followers 0
IKilledBambi

Array.

6 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

this what you mean?

dim $array1[16]
dim $array2[16]

For $i = 0 to 14 
    $array1[$i] = "joe["&$i&"]";random names i thought of
    $array2[$i] = "sam["&$i&"]"
    MsgBox(0, "", $array1[$i]&" "&$array2[$i])
    
Next
Edited by Rental

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

IKilledBambi

Example:

#include <Array.au3> ;Only for _ArrayDisplay

Dim $aTest[4]

$aTest[0] = 3
$aTest[1] = "One"
$aTest[2] = "Two"
$aTest[3] = "Three"

_ArrayDisplay($aTest, "Before")

$aTest[0] += 1
ReDim $aTest[$aTest[0] + 1]
$aTest[$aTest[0]] = "Four"

_ArrayDisplay($aTest, "After")

Share this post


Link to post
Share on other sites

I can't pre-define an array I don't want it to go up in array number, i want a whole new number created, i want pam(1) not pam[1]

Share this post


Link to post
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...

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