Jump to content

Controlsettext Example


Guest Buck
 Share

Recommended Posts

'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 . . .

Link to comment
Share on other sites

  • Developers

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" )

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Oops.  I'll change it.

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

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

  • Developers

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:

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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.
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...