Hina Posted April 9, 2009 Share Posted April 9, 2009 $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 MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1]) EndIf Next Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc I am confuse @ these steps $i = 1 to $var[0][0] $var[$i][0] <> "" AND IsVisible($var[$i][1]) Explain what actually $i is doing in the who code & what is $var[0][0] is doing why not we can write $i= 2 & $var[1][0] etc need explanation if possible Link to comment Share on other sites More sharing options...
youknowwho4eva Posted April 9, 2009 Share Posted April 9, 2009 $var = WinList() Look up WinList in the help file. It returns an array 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 MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1]) EndIf Next This for loop catches all programs listed by winlist that are actually visible. Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc The whole reason for the for loop is so you don't have to go through each part of the array manually Giggity Link to comment Share on other sites More sharing options...
Hina Posted April 10, 2009 Author Share Posted April 10, 2009 Please someone explain it to me. To youknowwho4eva The point which U are talking about it I have idea about it but I want the logic of my above mention code. Please someone help me Link to comment Share on other sites More sharing options...
CodyBarrett Posted April 10, 2009 Share Posted April 10, 2009 FOR loops are to automatically go through it for as many times as you specify.. FOR $i=0 TO 10 goes through the loop 10 times.. possibly 11..(does it start at the number?) any how... and this $var[$i][0] <> "" AND IsVisible($var[$i][1])means if the list isnt blank and if the first one is visable [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 10, 2009 Share Posted April 10, 2009 (edited) FOR loops are to automatically go through it for as many times as you specify.. FOR $i=0 TO 10 goes through the loop 10 times.. possibly 11..(does it start at the number?) any how...The value starts with the first number. So "0 To 10" results in 11 loops. and this means if the list isnt blank and if the first one is visableClose. If means if that particular element is not empty (WinList returns the title in [n][0] and the handle in [n][1]), and the window with that title is visible (checked by the IsVisible function). This method is not actually good practice unless you know for sure the windows you are looking for have a non-blank title and only one instance. It would be better to use $var[$i][1] (the handle) because every window has one and it is always unique. P.S. Just for fun, note also that the start, end, and step numbers in a For/Next loop don't have to be integers: For $n = 0.5 To 5 ConsoleWrite("$n = " & $n & @LF) Next ConsoleWrite(@LF) For $i = 0.5 To 5 Step 0.3 ConsoleWrite("$i = " & $i & @LF) Next Edited April 10, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
CodyBarrett Posted April 10, 2009 Share Posted April 10, 2009 there you go.. learn something new everyday [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now