Jump to content

Recommended Posts

Posted

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?

Posted

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?
Posted

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
Posted

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

  • Moderators
Posted

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.

Posted

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.

:P

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
×
×
  • Create New...