Jump to content

ifthen statment problems


Recommended Posts

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?

Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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

:P

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...