Champak Posted November 6, 2008 Share Posted November 6, 2008 So I have numerous WinGetStates in an IF condition: If WinGetState() = 15 Then ; ElseIf WinGetState() = 15 Then ; ElseIf WinGetState() = 15 Then ; ElseIf WinGetState() = 15 Then ........... EndIf The problems is towards the end it gets slow, takes longer to get to the ElseIf towards the end....obviously I guess. Is there a faster way to do this? Link to comment Share on other sites More sharing options...
LarryDalooza Posted November 6, 2008 Share Posted November 6, 2008 Opt("WinWaitDelay",50) ... or if you are feeling frisky... Opt("WinWaitDelay",0) Lar. AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 6, 2008 Share Posted November 6, 2008 (edited) So I have numerous WinGetStates in an IF condition: If WinGetState() = 15 Then ; ElseIf WinGetState() = 15 Then ; ElseIf WinGetState() = 15 Then ; ElseIf WinGetState() = 15 Then ........... EndIf The problems is towards the end it gets slow, takes longer to get to the ElseIf towards the end....obviously I guess. Is there a faster way to do this? Use a variable so you don't repeat the WinGetState(): $iState = WinGetState(WinGetHandle("[ACTIVE]")) Select Case BitAND($iState, 32) ConsoleWrite("Maximized" & @LF) Case BitAND($iState, 16) ConsoleWrite("Minimized" & @LF) Case BitAND($iState, 8) ConsoleWrite("Active" & @LF) Case BitAND($iState, 4) ConsoleWrite("Enabled" & @LF) Case BitAND($iState, 2) ConsoleWrite("Visible" & @LF) Case BitAND($iState, 1) ConsoleWrite("Exists" & @LF) EndSelect The problem here is that multiple bits are set in the window state, so once it hits on Maximized for example it will not go on to check Visible. But this is consistent with your ElseIf chain, anyway. Did you mean to check against the same value over and over? What's the point? Edited November 6, 2008 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...
Champak Posted November 6, 2008 Author Share Posted November 6, 2008 Lar, I actually tried that...no go...thanks. PsaltyDS, You've confused me a little. You gave the example, but then you say it is like the ElseIf chain.?.? I need to see which of 20 possible windows has a value of 15. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 6, 2008 Moderators Share Posted November 6, 2008 Well you can only have one active window, so store your titles/handles in an array that you are looking for, do a WinGetTitle("")/WinGetHandle("") once, then loop through the 20 window titles/handles you have stored, if the active window matches one of them, then you do 1 WinGetState($h_wnd, "", 7), so all in all, you only called window functions twice. 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 More sharing options...
Champak Posted November 6, 2008 Author Share Posted November 6, 2008 I was just coming back to give my solution and I see smoke_n you suggest basically what I did...thanks anyway. $rrr = WinGetTitle("[active]") If "Title1" = $rrr Then ; ElseIf "Title2" = $rrr Then ; ElseIf "Title3" = $rrr Then ; ElseIf "Title4" = $rrr Then ; endif 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