Jump to content

Can you use an array as a value in the ControlID?


 Share

Recommended Posts

Hello,

I am trying to click on different parts of a GUI defined as values of an array. Here's my script:

#include <array.au3>
#include <String.au3>

global $activity[6], $text

$activity[0]="VoIPSipPeer1"
$activity[1]="VoIPSipPeer2"
$activity[2]="VoIPSipPeer3"
$activity[3]="VoIPSipPeer4"
$activity[4]="VoIPSipPeer5"
$activity[5]="VoIPSipPeer6"


Opt("WinTitleMatchMode", 2)
Opt("SendKeyDelay", 500)
WinActivate("IxLoad")
WinWaitActive("IxLoad")
;Send("!Vd")
;sleep(5000)

For $i = 0 to 5
   $text=String($activity[$i])
   ControlClick("IxLoad","", "[TEXT:$text]")
   ConsoleWrite("Text:" & $text & @CRLF)
   Sleep(500)
Next

Exit

I am seeing that the value of $text variable is correct but the ControlClick function fails to click on the right area of the GUI. If I replace the $text with any of the values of my array then the command is executed properly. I have also tried enclosing the $text variable in double "" and also tried without the String function.

My question: can we use variables after TEXT: in the ControlID? Any reply is welcomed.

Thank you,

Ionut

Link to comment
Share on other sites

This might work...

#include <array.au3>
#include <String.au3>

Global $activity[6], $text

$activity[0] = "VoIPSipPeer1"
$activity[1] = "VoIPSipPeer2"
$activity[2] = "VoIPSipPeer3"
$activity[3] = "VoIPSipPeer4"
$activity[4] = "VoIPSipPeer5"
$activity[5] = "VoIPSipPeer6"


Opt("WinTitleMatchMode", 2)
Opt("SendKeyDelay", 500)
WinActivate("IxLoad")
WinWaitActive("IxLoad")
;Send("!Vd")
;sleep(5000)

For $i = 0 To UBound($activity) - 1
    $text = String($activity[$i])
    ControlClick("IxLoad", "", "[TEXT:" & $activity[$i] & "]")
    ConsoleWrite("Text:" & $text & @CRLF)
    Sleep(500)
Next

Exit
Link to comment
Share on other sites

ControlClick("IxLoad","", "[TEXT:$text]") is sending [TEXT:$text] as a string literal to the function - which will not work.

Try something like:

#include <array.au3>
#include <String.au3>

Global $activity[6], $text

$activity[0] = "VoIPSipPeer1"
$activity[1] = "VoIPSipPeer2"
$activity[2] = "VoIPSipPeer3"
$activity[3] = "VoIPSipPeer4"
$activity[4] = "VoIPSipPeer5"
$activity[5] = "VoIPSipPeer6"


Opt("WinTitleMatchMode", 2)
Opt("SendKeyDelay", 500)
WinActivate("IxLoad")
WinWaitActive("IxLoad")
;Send("!Vd")
;sleep(5000)

For $i = 0 To 5
    $text = String($activity[$i])
    ControlClick("IxLoad", "", "[TEXT:" & $text & " ]")
    ConsoleWrite("Text:" & $text & @CRLF)
    Sleep(500)
Next

Exit

Edit: KaFu just beat me to it :(

Edited by bo8ster

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

ControlClick("IxLoad","", "[TEXT:"&$text&"]")

*Edit*

well, looks like I was beat twice :(

Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

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...