testmeout Posted November 20, 2005 Share Posted November 20, 2005 Ok I have tried my code several different ways and nothing is working, I have tried strictly If..ElseIf...Else, I have tried Select Case within Select Case, and I have tried Select Case within If, nothing is working I am not sure if I have maxed out the limit or what but here is my current code. When I do a debug it always get stuck at the first statement within that group, I don't know whats going on expandcollapse popupIf $dealcard == 4 Then Select Case $mytotal < 9 AND $card1 Or $card2 <> 11 ControlClick("Program Name", "209", "209") Sleep(1000) Case 9 <= $mytotal <=11 AND $card1 Or $card2 <> 11 ControlClick("Program Name", "210", "210") Sleep(1000) Case 12 <= $mytotal <= 20 AND $card1 Or $card2 <> 11 ControlClick("Program Name", "208", "208") Sleep(1000) Case 13 <= $mytotal <= 14 ControlClick("Program Name", "209", "209") Sleep(1000) Case 15 <= $mytotal <= 17 ControlClick("Program Name", "210", "210") Sleep(1000) Case $mytotal == 18 If ControlCommand( "Program Name", "210", "210", "IsVisible", "1" ) Then ControlClick("Program Name", "210", "210") Sleep(1000) EndIf If ControlCommand( "Program Name", "210", "210", "IsVisible", "0" ) Then ControlClick("Program Name", "208", "208") Sleep(1000) EndIf Case $mytotal >= 19 ControlClick("Program Name", "208", "208") Sleep(1000) Case $card1 == 2 AND $card2 == 2 Or $card1 == 3 AND $card2 == 3 ControlClick("Program Name", "211", "211") Sleep(1000) Case $card1 == 4 AND $card2 == 4 ControlClick("Program Name", "209", "209") Sleep(1000) Case $card1 == 5 AND $card2 == 5 ControlClick("Program Name", "210", "210") Sleep(1000) Case $card1 == 6 AND $card2 == 6 Or $card1 == 7 AND $card2 == 7 Or $card1 == 8 AND $card2 == 8 Or $card1 == 9 AND $card2 == 9 ControlClick("Program Name", "211", "211") Sleep(1000) Case $card1 == 10 AND $card2 == 10 ControlClick("Program Name", "208", "208") Sleep(1000) Case $card1 == 1 AND $card2 == 1 ControlClick("Program Name", "211", "211") Sleep(1000) Case Else If ControlCommand( "Program Name", "112", "112", "IsVisible", "1" ) Then ControlClick("Program Name", "112", "112") Endif EndSelect EndIf I have ten of these If $dealcard == 1-10 and all of them get stuck on Sleep(1000) on the first case of that group Any ideas? Link to comment Share on other sites More sharing options...
Valuater Posted November 20, 2005 Share Posted November 20, 2005 first you could remove the sleep(1000) from each if/case and put it (once) just before the last endif/endselect second you can use getmessage() case.... if... end inside the case yours above wont work ( i dont think) **** still on this one huh? 8) Link to comment Share on other sites More sharing options...
testmeout Posted November 22, 2005 Author Share Posted November 22, 2005 Are you talking about GUIGetMsg()? I am not sure how to implement that command for this situation, could you please explain. I am not creating any GUI interface, so I don't think this would apply. Link to comment Share on other sites More sharing options...
LxP Posted November 22, 2005 Share Posted November 22, 2005 The following lines are at fault here: Case $mytotal < 9 AND $card1 Or $card2 <> 11 Case 9 <= $mytotal <=11 AND $card1 Or $card2 <> 11 Case 12 <= $mytotal <= 20 AND $card1 Or $card2 <> 11 Case 13 <= $mytotal <= 14 Case 15 <= $mytotal <= 17 Perhaps by this: $card1 Or $card2 <> 11 you mean this: ($Card1 <> 11) Or ($Card2 <> 11); if one of the cards does not equal 11 and when you mean this: 12 <= $mytotal <= 20 you must say this: ($MyTotal >= 12 And $MyTotal <= 20) Also, the following may not work as expected: Case $card1 == 2 AND $card2 == 2 Or $card1 == 3 AND $card2 == 3 Case $card1 == 6 AND $card2 == 6 Or $card1 == 7 AND $card2 == 7 Or $card1 == 8 AND $card2 == 8 It's best to use brackets so as not to be ambiguous. If your use of caps here indicate higher precedence then you want this: Case ($card1 == 2 AND $card2 == 2) Or ($card1 == 3 AND $card2 == 3) Case ($card1 == 6 AND $card2 == 6) Or ($card1 == 7 AND $card2 == 7) Or ($card1 == 8 AND $card2 == 8) Link to comment Share on other sites More sharing options...
testmeout Posted November 22, 2005 Author Share Posted November 22, 2005 Thanks for the corrections, but something is still wrong with the nesting Is it better to have the select case within an if statement or select case within select case or if within if statement No matter what I have tried it always executes the first cases control click Case $mytotal < 9 AND $card1 Or $card2 <> 11 ControlClick("Program Name", "209", "209") Even when the case is false and doesn't evaluate the other cases. I have no clue why it does this. Any ideas? Link to comment Share on other sites More sharing options...
LxP Posted November 22, 2005 Share Posted November 22, 2005 Because logically this is still incorrect: Case $mytotal < 9 AND $card1 Or $card2 <> 11The code beneath this line will be chosen for execution whenever $Card2 does not equal 11 or whenever ($MyTotal < 9 And $Card1 <> 0). This is probably not what you want.If by $card1 Or $card2 <> 11 you mean $card1 <> 11 Or $card2 <> 11, you must explicitly state this to AutoIt.When you are using And and Or together, you must use brackets to clearly determine how the logic should be interpreted.My guess (without any knowledge of what you're trying to do) is that your Case line should therefore be written like this: Case ($MyTotal < 9) And ($Card1 <> 11 Or $Card2 <> 11) ; If both $MyTotal is less than 9, AND either $Card1 or $Card2 ; or both cards do not equal 11, then execute the following code Link to comment Share on other sites More sharing options...
testmeout Posted November 23, 2005 Author Share Posted November 23, 2005 Thank you so much for your help LxP, the code is working great once I bracketed everything, except one part is still not evaluating and I'm not sure why If $dealcard == 4 Then Select Case (($mytotal < 9) AND ($card1 <> 11 Or $card2 <> 11)) ControlClick("Program Name", "209", "209") Case (($mytotal >= 9 And $mytotal <=11) AND ($card1 <> 11 Or $card2 <> 11)) ControlClick("Program Name", "210", "210") $currentvalue = (IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1) Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue) Case (($mytotal >= 12 And $mytotal <= 20) AND ($card1 <> 11 Or $card2 <> 11)) ControlClick("Program Name", "208", "208") Case ($mytotal >= 13 And $mytotal <= 14) ControlClick("Program Name", "209", "209") Case ($mytotal >= 15 And $mytotal <= 17) ControlClick("Program Name", "210", "210") $currentvalue = (IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1) Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue) Case ($mytotal == 18) If ControlCommand( "Program Name", "210", "210", "IsVisible", "1" ) Then ControlClick("Program Name", "210", "210") $currentvalue = (IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1) Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue) ElseIf ControlCommand( "Program Name", "210", "210", "IsVisible", "0" ) Then ControlClick("Program Name", "208", "208") $currentvalue = (IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1) Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue) EndIf Case ($mytotal >= 19) ControlClick("Program Name", "208", "208") Up until this point there are no problems but the following code still won't evaluate it just does the first case because it is true first. Case (($mytotal < 9) AND ($card1 <> 11 Or $card2 <> 11)) ControlClick("Program Name", "209", "209") So should I make it Case (($mytotal < 9) AND ($card1 <> 11 Or $card2 <> 11) And (($card1 <> 2 AND $card2 <> 2) Or ($card1 <> 3 AND $card2 <>3) Or ($card1 <> 4 AND $card2 <> 4) Or ($card1 <> 5 AND $card2 <> 5) Or ($card1 <> 6 AND $card2 <> 6) Or ($card1 <> 7 AND $card2 <> 7) Or ($card1 <> 8 AND $card2 <> 8) Or ($card1 <> 9 AND $card2 <> 9))) ControlClick("Program Name", "209", "209") I am sure the better way to do it would be to create a variable If (($card1 <> 2 AND $card2 <> 2) Or ($card1 <> 3 AND $card2 <>3) Or ($card1 <> 4 AND $card2 <> 4) Or ($card1 <> 5 AND $card2 <> 5) Or ($card1 <> 6 AND $card2 <> 6) Or ($card1 <> 7 AND $card2 <> 7) Or ($card1 <> 8 AND $card2 <> 8) Or ($card1 <> 9 AND $card2 <> 9)) Then $pair = 1 EndIf Case (($mytotal < 9) AND ($card1 <> 11 Or $card2 <> 11) And $pair <> 1) ControlClick("Program Name", "209", "209") Is this the best way to accomplish this or should I just move the bottom code to the top duh I am going to try that since whenever it hits a true case then it finishes Rest of Code (Well going to be begining) Case (($card1 == 2 AND $card2 == 2) Or ($card1 == 3 AND $card2 == 3)) ControlClick("Program Name", "211", "211") $currentvalue = (IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1) Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue) Case ($card1 == 4 AND $card2 == 4) ControlClick("Program Name", "209", "209") Case ($card1 == 5 AND $card2 == 5) ControlClick("Program Name", "210", "210") $currentvalue = (IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1) Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue) Case (($card1 == 6 AND $card2 == 6) Or ($card1 == 7 AND $card2 == 7) Or ($card1 == 8 AND $card2 == 8) Or ($card1 == 9 AND $card2 == 9)) ControlClick("Program Name", "211", "211") $currentvalue = (IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1) Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue) Case ($card1 == 10 AND $card2 == 10) ControlClick("Program Name", "208", "208") Case ($card1 == 1 AND $card2 == 1) ControlClick("Program Name", "211", "211") $currentvalue = (IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1) Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue) Case Else If ControlCommand( "Program Name", "112", "112", "IsVisible", "1" ) Then ControlClick("Program Name", "112", "112") Endif EndSelect Sleep(1000) EndIf Thanks for all the help I hope moving it up works Link to comment Share on other sites More sharing options...
themax90 Posted November 23, 2005 Share Posted November 23, 2005 What exactly are you making? I made a blackjack video game, perhaps you would like to use the card deck system to make it a bit easier.http://www.autoitscript.com/forum/index.ph...topic=14163&hl=The actual zip is in my signature. It could streamline your process and forgo alot of work. I don't know if you have a card database yet, just a suggestion. Link to comment Share on other sites More sharing options...
LxP Posted November 23, 2005 Share Posted November 23, 2005 What exactly are you making? I made a blackjack video game, perhaps you would like to use the card deck system to make it a bit easier.From the provided code it appears that the original poster is working on automating another game. Up until this point there are no problems but the following code still won't evaluate it just does the first case because it is true first.Select..Case..EndSelect will only ever run at most one Case block, so introducing a variable as you describe would likely get the job done. If you feel like it however, I would suggest perhaps posting your complete code in case your logic can be simplified. For instance: If (($card1 <> 2 AND $card2 <> 2) Or ($card1 <> 3 AND $card2 <>3) Or ($card1 <> 4 AND $card2 <> 4) Or ($card1 <> 5 AND $card2 <> 5) Or ($card1 <> 6 AND $card2 <> 6) Or ($card1 <> 7 AND $card2 <> 7) Or ($card1 <> 8 AND $card2 <> 8) Or ($card1 <> 9 AND $card2 <> 9)) Then can most probably be simplified to this (i.e. it would be true for the above case): If $Card1 <> $Card2 Then or perhaps this (again depending on precisely what you want to achieve): If ($Card1 > 1) And ($Card2 > 1) And ($Card1 < 10) And ($Card2 < 10) And ($Card1 <> $Card2) Then 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