Sign in to follow this  
Followers 0
Xenobiologist

ControlSend ControlSetText

7 posts in this topic

#1 ·  Posted (edited)

Hi,

I did post in support forum, but I didn't get an answer, that is why I try again here. Link : Topic in support

Opt('WinTitleMatchMode', 4)
Run("notepad.exe")
WinWait("classname=Notepad")
ControlSetText("classname=Notepad", "", "Edit1", "1@ " & "{ASC 064}" & @CRLF) ; sends @ {ASC 064} and Cursor stays at first pos.
ControlSend("classname=Notepad", "", "Edit1", "2@ " & "{ASC 064}" & @CRLF) ; sends @ @
ControlSend("classname=Notepad", "", "Edit1", "3@ " & "{ASC 064}" & @CRLF, 1) ; sends @ {ASC 064}

ControlSetText seems to always set text raw comparing it to ControlSend. Additionally the cursor stays at first position after ControlSetText (is this the way it should be?)

Is this already documented?

Besides, ...

the examples of ControlSetText and ControlSend should be changed to a NON-English example. (Using classname in lieu of title) or it should be pointed out.

Thanks!

Mega

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites



Hi,

I did post in support forum, but I didn't get an answer, that is why I try again here. Link : Topic in support

Opt('WinTitleMatchMode', 4)
Run("notepad.exe")
WinWait("classname=Notepad")
ControlSetText("classname=Notepad", "", "Edit1", "1@ " & "{ASC 064}" & @CRLF) ; sends @ {ASC 064} and Cursor stays at first pos.
ControlSend("classname=Notepad", "", "Edit1", "2@ " & "{ASC 064}" & @CRLF) ; sends @ @
ControlSend("classname=Notepad", "", "Edit1", "3@ " & "{ASC 064}" & @CRLF, 1) ; sends @ {ASC 064}

ControlSetText seems to always set text raw comparing it to ControlSend. Additionally the cursor stays at first position after ControlSetText (is this the way it should be?)

Is this already documented?

Besides, ...

the examples of ControlSetText and ControlSend should be changed to a NON-English example. (Using classname in lieu of title) or it should be pointed out.

Thanks!

Mega

ControlSetText doesn't do simulated keystrokes it just sets the exact text as written. The order you should attempt to automate the text in a control is:

1. ControlSetText

2. ControlSend - keystroke sim

3. Send - keystroke sim

Share this post


Link to post
Share on other sites

ControlSetText doesn't do simulated keystrokes it just sets the exact text as written. The order you should attempt to automate the text in a control is:

1. ControlSetText

2. ControlSend - keystroke sim

3. Send - keystroke sim

Hi Jon,

thanks for that. One question left. The cursor stays at first position after ControlSetText. Is this your intention, or is it just because the control doesn't recognize the keystrokes?

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

There are no keystrokes sent with ControlSetText() so it doesn't recognize keystrokes because they don't exist.

Share this post


Link to post
Share on other sites

There are no keystrokes sent with ControlSetText() so it doesn't recognize keystrokes because they don't exist.

Thanks, that what I tried to put in words above. So, ControlSetText is always True(Success) or False? - what I mean is Send and even ControlSend can be breaked during execution and ControlSetText can be, right?

Are there any other reasons why ControlSetText is "better" than ControlSetText?

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

ControlSetText literally sends a native windows message to a control which says "please change your text to this". If it works on a control it is 100% reliable. Both Send and ControlSend are imperfect and not 100% reliable as they use simulated keystrokes that can go wrong/be interrupted. ControlSetText does not use keystrokes, is instant and cannot be interrupted.

Share this post


Link to post
Share on other sites

ControlSetText literally sends a native windows message to a control which says "please change your text to this". If it works on a control it is 100% reliable. Both Send and ControlSend are imperfect and not 100% reliable as they use simulated keystrokes that can go wrong/be interrupted. ControlSetText does not use keystrokes, is instant and cannot be interrupted.

Thanks!

That's what I wanted to here and I what I expected. Great. Nice to learn such things.

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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