Sign in to follow this  
Followers 0
Ozi

Ubound and arrays

7 posts in this topic

can i use ubound to count how many words i have in a key in an INI (ill use StringSplit and commas as the delimiters) and then lets say it returns 10 words, could i some how add 1 to each dimension name like Send($var[1])+1 then it'll do Send($var[2])+1 and so on?

I might be saying it wrong but I hope someone gets the idea... <_<

Share this post


Link to post
Share on other sites



$var = INIRead("C:\test.ini", "Section", "Key", "Unable to read INI.")

Case $msg = $Button1

If WinExists("Test Window", "" ) Then

WinActivate("Test Window", "")

Send("{CTRLDOWN}{f}")

Send("{CTRLUP}")

$Search = StringSplit($var, ",")

For $i = 1 To Ubound($Search) - 1

Send($Search[$i] + 1)

Next

Send("{Enter}")

I was hoping this would search the INI for how many words (each word separted by a comma) there were in the INI ($var) and then if let's say 10 words it would keep incrementing the $Search[$i] so it would be able to send all the words in the INI to the active window, whether there be ten words or 20.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$var = INIRead("C:\test.ini", "Section", "Key", "Unable to read INI.")

Case $msg = $Button1

If WinExists("Test Window", "" ) Then

WinActivate("Test Window", "")

Send("{CTRLDOWN}{f}")

Send("{CTRLUP}")

$Search = StringSplit($var, ",")

For $i = 1 To Ubound($Search) - 1

Send($Search[$i] + 1)

Next

Send("{Enter}")

I was hoping this would search the INI for how many words (each word separted by a comma) there were in the INI ($var) and then if let's say 10 words it would keep incrementing the $Search[$i] so it would be able to send all the words in the INI to the active window, whether there be ten words or 20.

Element [0] returned of the array contains the number of words so you can rewrite your code like this

$var = INIRead("C:\test.ini", "Section", "Key", "Unable to read INI.")
Case $msg = $Button1
    If WinExists("Test Window", "" ) Then
        WinActivate("Test Window", "")
        Send("{CTRLDOWN}{f}")
        Send("{CTRLUP}")
        $Search = StringSplit($var, ",")
        ;Check if any words found
        If IsArray($Search) Then
            For $i = 1 To $Search[0]
                Send($Search[$i])
            Next
            Send("{Enter}")
        EndIf
Edited by Bowmore

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

@Bowmore, that types the words in the INI all at once. I want them typed one at a time.

Like use the commas as delimiters so when it gets to the first word it will type it, then press enter

then go on to the next word, type it, press enter and so on.

Share this post


Link to post
Share on other sites

@Bowmore, that types the words in the INI all at once. I want them typed one at a time.

Like use the commas as delimiters so when it gets to the first word it will type it, then press enter

then go on to the next word, type it, press enter and so on.

This should achive the desired effect

var = INIRead("C:\test.ini", "Section", "Key", "Unable to read INI.")
Case $msg = $Button1
    If WinExists("Test Window", "" ) Then
        WinActivate("Test Window", "")
        Send("{CTRLDOWN}{f}")
        Send("{CTRLUP}")
        $Search = StringSplit($var, ",")
        ;Check if any words found
        If IsArray($Search) Then
            For $i = 1 To $Search[0]
                Send($Search[$i] & "{Enter}")
            Next
        EndIf

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

Ok, it's working somewhat now, but I have Key=word1,word2

and then when the window thats it looking for becomes active it only sends word1 but not word2.

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