kjpolker Posted February 12, 2018 Share Posted February 12, 2018 (edited) Hello, I have been digging through the help file and I can't find anything related to what I want. I have in my code: $i = 255 ;blah blah Func item1() WinSetTrans($hWnd, "", $i) $i -= 51 EndFunc The point is to cycle through a new transparency with each call of the function. However, I need to set limits on $i to never be less than 0 or greater than 255. How is this achieved? I am sure it's easy but I just don't see anything on it. Edited February 12, 2018 by kjpolker Link to comment Share on other sites More sharing options...
Rex Posted February 12, 2018 Share Posted February 12, 2018 This might work If $i <= 0 or $i => 255 then Cheers /Rex Link to comment Share on other sites More sharing options...
kjpolker Posted February 12, 2018 Author Share Posted February 12, 2018 I think you meant If $i <= 255 And >= 0 Then For some reason I get an error in expression dialogue on the $i. I previously had tried While $i <= 255 And >= 0 but got a similar error. Link to comment Share on other sites More sharing options...
Rex Posted February 12, 2018 Share Posted February 12, 2018 You need to ad $i after the And operator, else the statement won't work Cheers /Rex Link to comment Share on other sites More sharing options...
Somerset Posted February 12, 2018 Share Posted February 12, 2018 "operators" is what you need to look up in the help file Link to comment Share on other sites More sharing options...
kjpolker Posted February 12, 2018 Author Share Posted February 12, 2018 (edited) Thank you! I didn't catch that. Final code works fine for what I am doing. $i = 255 ;Blah blah Func Transparency1() If $i <= 255 And $i > 0 Then $i -= 51 EndIf WinSetTrans($hWnd, "", $i) EndFunc Func Transparency2() If $i < 255 And $i >= 0 Then $i += 51 EndIf WinSetTrans($hWnd, "", $i) EndFunc Edited February 12, 2018 by kjpolker Link to comment Share on other sites More sharing options...
kjpolker Posted February 12, 2018 Author Share Posted February 12, 2018 @Somerset I was checking that out and figured it would be related to that, I just was having trouble thinking of the logic. I couldn't think of how to implement a variable in a function that didn't loop (I initially was thinking on the lines of For To Step). Thank you for the help! Link to comment Share on other sites More sharing options...
Rex Posted February 12, 2018 Share Posted February 12, 2018 (edited) Thinks that most of had made that mistake once Glad it worked Another way it could be done is using switch $i = 255 ;Blah blah Func Transparency1() Switch $i case 1 to 255 WinSetTrans($hWnd, "", $i) Endswitch EndFunc Func Transparency2() WinSetTrans($hWnd, "", $i) If $i < 255 And $i >= 0 Then $i += 51 EndFunc Cheers /Rex Edited February 12, 2018 by Rex Link to comment Share on other sites More sharing options...
badcoder123 Posted February 12, 2018 Share Posted February 12, 2018 I know this isn't what you're looking for but I think it will lead you the right way. For $i = 255 To 0 Step - 1 WinSetTrans($hWnd, "", $i) $i -= 1 Sleep(20) If $i = 0 Then WinSetTrans($hWnd, "", 255) Next 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