esteban Posted August 15, 2006 Posted August 15, 2006 Here's my problem, I am trying to open a msgbox after a wingettext on notepad. My code looks like this : $text=Wingettext("test") if $text="start" then msgbox(1,"test", "Success!") endif I am sure that $text="start" . i simply cant get the if statement to work correctly. can any one help me?
azeazezar Posted August 15, 2006 Posted August 15, 2006 Here's my problem, I am trying to open a msgbox after a wingettext on notepad. My code looks like this : $text=Wingettext("test") if $text="start" then msgbox(1,"test", "Success!") endif I am sure that $text="start" . i simply cant get the if statement to work correctly. can any one help me? Can you give us a screenshot of the AutoIt Window Info Tool and the window?
kjmarket Posted August 15, 2006 Posted August 15, 2006 The code works. Your problem is that you are only looking for a window that contains the text you specified. Do you know the exact title of the window you want to get the text from? That would help a lot. Pink Floyd - The Wall
MHz Posted August 16, 2006 Posted August 16, 2006 Ensure you are using WinWait() to wait for the window to come along, else WinGetText() may execute too early. Also you may need to account for the carriage return if exists. Only adding @LF would make it work for me. This works for me. Run('Notepad') WinWait('Untitled') ControlSend('Untitled', '', 'Edit1', 'start'); add some text to notepad $text = WinGetText('Untitled') If $text = ('start' & @LF) Then MsgBox(0, 'OK', 'success') EndIf MsgBox(0, '$test=', '"' & $text & '"'); Check variable contents
Valuater Posted August 16, 2006 Posted August 16, 2006 Many times i find myself using If StringinStr($text, 'start') Then that way if there is a line feed or "other" character, you still can get you desired results 8)
Moderators SmOke_N Posted August 16, 2006 Moderators Posted August 16, 2006 Many times i find myself using If StringinStr($text, 'start') Then that way if there is a line feed or "other" character, you still can get you desired results 8)I do that often ... 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.
esteban Posted August 16, 2006 Author Posted August 16, 2006 thank you Valuater, after using StringinStr everything worked. thank you!
MHz Posted August 17, 2006 Posted August 17, 2006 I would have used StringStripWhiteSpace() to get the "start", because if the line contained "jumpstart" then StringInStr() would also return true. "jumpstart" is a different word.
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