ts29 Posted February 12, 2010 Share Posted February 12, 2010 (edited) $state = WinGetState($hWnd) If BitAnd( $state, 1) AND ( $state, 2) AND ( $state, 4) Then blablabla Is this do-able? Because when i do this code, i get unexpected behaviour in that even if the window is not visible and also not enabled( 2 and 4, 1 is whether window exists), the program scans the desktop as a "client" instead and returns maximum negative values on the integer coordinates (-32000,-32000). I did search the Help File for If.. Then.. Else Conditional Statements but i did not find anything Edited February 12, 2010 by ts29 Link to comment Share on other sites More sharing options...
Steveiwonder Posted February 12, 2010 Share Posted February 12, 2010 (edited) $state = WinGetState($hWnd) If $state = 2+4+8+16 Then ;dooo stuffff EndIf You need to add up the values from WinGetState 1 = Window exists 2 = Window is visible ; ---- 4 = Window is enabled ; ---- 8 = Window is active ; ---- 16 = Window is minimized 32 = Window is maximized ; ---- but any other if statment is like this.. If $var1 = "a" & $var2 = "a" & $var3 = "a" Then Edited February 12, 2010 by Steveiwonder They call me MrRegExpMan Link to comment Share on other sites More sharing options...
FinalVersion Posted February 12, 2010 Share Posted February 12, 2010 Forgive me if I'm wrong, but in C++ you can use || for or. So if any of the conditions are true, code will be executed. But with and, all conditions must be met. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
ts29 Posted February 12, 2010 Author Share Posted February 12, 2010 Ahh thanks a lot. I shall go and try it out and tell you guys how it goes. Link to comment Share on other sites More sharing options...
FinalVersion Posted February 12, 2010 Share Posted February 12, 2010 I just tried both these and they work. $a = "b" $b = "a" If $b = "a" And $a = "b" Then MsgBox(0, "!", "!") EndIf $a = "b" $b = "a" If $a = "a" Or $a = "b" Then MsgBox(0, "!", "!") EndIf [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
czardas Posted February 12, 2010 Share Posted February 12, 2010 You can also use the boolean expression - Not. See the help file under the keyword - If.$a = "b" $b = "a" If $a = "b" And Not StringInStr($b, "b") Then MsgBox(0, "!", "!") EndIf operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
martin Posted February 12, 2010 Share Posted February 12, 2010 Forgive me if I'm wrong, but in C++ you can use || for or. So if any of the conditions are true, code will be executed. But with and, all conditions must be met. In C or C++ you use || for Logical Or and | for Bitwise Or. Steviewonder has given a not-to-be-followed example by using addition to combine styles; styles and many other values should be Ored to get the result otherwise things can go wrong. For example BitOr(7,1) is not the same as 7 + 1. You misunderstood his example of using &. In AutoIt the & operator is not for a logical And operation but for string concatenation. In AutoIt 7 & 1 will produce the string "71" from the 2 numbers. @ ts29 Your example should be like this $state = WinGetState($hWnd) If BitAnd( $state, 1) AND BitAnd( $state, 2) AND BitAnd( $state, 4) Then blablabla or If BitAnd( $state, BitOr(1,2,4)) then Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
ts29 Posted February 12, 2010 Author Share Posted February 12, 2010 In C or C++ you use || for Logical Or and | for Bitwise Or. Steviewonder has given a not-to-be-followed example by using addition to combine styles; styles and many other values should be Ored to get the result otherwise things can go wrong. For example BitOr(7,1) is not the same as 7 + 1. You misunderstood his example of using &. In AutoIt the & operator is not for a logical And operation but for string concatenation. In AutoIt 7 & 1 will produce the string "71" from the 2 numbers. @ ts29 Your example should be like this $state = WinGetState($hWnd) If BitAnd( $state, 1) AND BitAnd( $state, 2) AND BitAnd( $state, 4) Then blablabla or If BitAnd( $state, BitOr(1,2,4)) then Ahh thank you. Although i used the example of If $state = 1+2+4 Then Thank you for that very elegant code though. Link to comment Share on other sites More sharing options...
czardas Posted February 12, 2010 Share Posted February 12, 2010 Ahh thank you. Although i used the example of If $state = 1+2+4 Then I think you must have missunderstood what martin was saying. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
martin Posted February 12, 2010 Share Posted February 12, 2010 .. i used the example of If $state = 1+2+4 Then and if the window is Active the test will fail. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
ts29 Posted February 13, 2010 Author Share Posted February 13, 2010 and if the window is Active the test will fail.Ah, yes, but when i click on the exe on the desktop, the window is visible, maximized, but greyed out and inactive. So it's exactly what I need. Thank you though. 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