Sign in to follow this  
Followers 0
Guest Buck

Controlsettext Example

9 posts in this topic

'Elo all:

I had some problems using ControlSetText, so I decided to try the example in the help file:

Example

RunWait("notepad")

ControlSetText("Untitled -", "", "Edit1", "New Text Here" )

I think RunWait is wrong, because that will have the script wait until notepad exits until it continues execution. Another problem is the title - "Untitled -". My notepad opens with a title of "Untitled - Notepad", as well as the few other PC's I checked. If I modify the example code to:

Run("notepad")

$var = ControlSetText("Untitled - Notepad", "", "Edit1", "New Text Here" )

msgbox(0,"Debug", $var)

This still does not work, and ControlSetText returns a 0.

If I open notepad first from the start menu, and run this code:

$var = ControlSetText("Untitled - Notepad", "", "Edit1", "New Text Here" )

msgbox(0,"Debug", $var)

It does work.

I'm going to play with it a bit more, and see if I can get it working with the app I actually need, but in the meantime:

Anyone else have these problems?

Anybody see some dumb mistake?

Thanks for your help . . .

Share this post


Link to post
Share on other sites



If I open notepad first from the start menu, and run this code:

$var = ControlSetText("Untitled - Notepad", "", "Edit1", "New Text Here" )

msgbox(0,"Debug", $var)

It does work.

The ControlSetText is probably already performed with the Notepad program running. Adding a WinWait between the Run and ControlSetText statement will probably solve it.

Run("notepad")
WinWait ("Untitled - Notepad", "", 2)
$var = ControlSetText("Untitled - Notepad", "", "Edit1", "New Text Here" )

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

That did it.

Thanks!

Share this post


Link to post
Share on other sites

Oops.  I'll change it.

i am missing the oops here.... :whistle:

Should the ControlSetText wait for a window to become active ??


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

i am missing the oops here....  :whistle:

Should the ControlSetText wait for a window to become active ??

Its not meant to wait for it to be active, its just meant to wait for it to exist. Most of the time, Run("notepad") then ControlSetText("") immediately after will probably fail because Notepad hasn't finished being created yet.

Share this post


Link to post
Share on other sites

ok understand the oops now... B)

valik... i am a bit lost about your statement. i thought it just returns a 0 if the windows isn't found. :whistle:


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

ok understand the oops now... B)

valik... i am a bit lost about your statement. i thought it just returns a 0 if the windows isn't found. :whistle:

I didn't understand what you were not understanding, ignore my post.

Share this post


Link to post
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
Sign in to follow this  
Followers 0