Jump to content

Radom question


Sardith
 Share

Recommended Posts

Hi, i've never randomed a array result. $var[$i][0]

What I was going to do.

Dim $Var, $i

Func Test()
$var = WinList()
For $i = 1 to $var[0][0]
  ; Only display visble windows that have a title
  If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
    ToolTip("", 0, 0)
    Sleep(10)
    ToolTip("Title= " & $var[$i][0] & @LF & "Handle= " & $var[$i][1], 0, 0)
  Sleep(2000)
EndIf
Next
EndFunc

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf

EndFunc



While 1
    Test()
    sleep(4000)
WEnd

What I wanted to do, is some how random one the array, so I could pick a random window title, that is visable to the user. Not sure where to go beyond this.

Edited by Sardith

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Link to comment
Share on other sites

  • Moderators

Hi, i've never randomed a array result. $var[$i][0]

What I was going to do.

$Rprogram = Random(1, 100, 1)

$var[$RProgram][0]

Would that work? If so, how do I check a array, to make sure it's not blank, and if it is. It will random again?

Sardith.. how about trying it and seeing if it would work with a simple demonstration?

Dim $var[6][2]
$var[1][0] = 3
$var[2][0] = ""
$var[3][0] = 5
$var[4][0] = 7
$var[5][0] = 9

While 1
    $nRprogram = Random(1, 5, 1)
    $sOutput = $var[$nRprogram][0]
    If $sOutput <> '' Then
        ToolTip('Output: ' & $sOutput, 0, 0)
    Else;Only to show you that it blocks [2][0]
        ToolTip('Value Empty : $nRprogram = ' & $nRprogram, 0, 0);$nRprogram should always be 2 since I left that empty above
    EndIf
    Sleep(2000)
WEnd

As long as you've been here, you think you would simply test some theories yourself in "simple mode".

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Not a random question. Random the funcation?

Sorry, but I just had to.

Do you even know what a Parsnip is? Hope you like eatting fleshy roots for dinner?

Edited by Sardith

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

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