asiawatcher Posted April 5, 2021 Share Posted April 5, 2021 (edited) Hi all i got this code While 1 If $data <> WinGetText($winname) Then $data = WinGetText($winname) Opt("WinDetectHiddenText", 1) $data1 = WinGetText($winname) Opt("WinDetectHiddenText", 0) $sString = StringTrimLeft($data1, 81) $lines = StringSplit($sString, @CRLF) if $lines[1]<>"" or $lines[1]<>$f then MsgBox($MB_TOPMOST, "KEY FOUND:", $lines[1], 2) MsgBox($MB_TOPMOST, $lines[1], $f, 2) clipput($lines[1]) $f=$lines[1] else endif EndIf sleep(2000) WEnd This takes some hidden text from another c++ gui trims it then pops up a message box if the final trimmed string isn't blank OR isn't equal to its last/previous value (the $f) The thing is that although with this code MsgBox($MB_TOPMOST, $lines[1], $f, 2) i find out both strings are equal and the 1st msgbox which says "key is:" SHOULD NOT be displayed & it gets displayed everytime although both strings are equal (like i find out with this code MsgBox($MB_TOPMOST, $lines[1], $f, 2) ) what am i doing wrong ? look at my screenshot cheers Edited April 5, 2021 by asiawatcher Link to comment Share on other sites More sharing options...
Subz Posted April 5, 2021 Share Posted April 5, 2021 (edited) Have you tried == rather than just =? Or try using StringStripWs to compare strings? Also noticed you were using an "or" this will return true if either expression is correct? StringStripWS example (untested): ;~ StringStripWS flag 7 ;~ $STR_STRIPLEADING (1) = strip leading white space ;~ $STR_STRIPTRAILING (2) = strip trailing white space ;~ $STR_STRIPSPACES (4) = strip double (or more) spaces between words Local $sData = StringStripWS($lines[1],7) If $sData<>"" And $sData<>$f then MsgBox($MB_TOPMOST, "KEY FOUND:", $sData, 2) MsgBox($MB_TOPMOST, $sData, $f, 2) ClipPut($sData) $f=$sData EndIf Edited April 6, 2021 by Subz asiawatcher 1 Link to comment Share on other sites More sharing options...
asiawatcher Posted April 6, 2021 Author Share Posted April 6, 2021 the AND did the trick cheers !! 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