Jump to content
Macro Express Forums

Writing To A Control


lhookway

Recommended Posts

Hi Guys,

 

What is the best way of overwriting the text of a control with text of my own.

 

I know I can use get control to capture a control to a Cnn variable and then use text type to write to that variable.

 

Trouble is it prepends to the existing contents. What I need to do is overwrite the contents of the variable.

 

I don't particularly want to set focus to the control when I do this.

 

Is there an elegant, no fuss way, of overwriting the contents of a text control?

 

Regards,

 

Laurence.

Link to comment
Share on other sites

Welcome to the group Laurence!

 

When talking about edit boxes and the Text Type command (Send Text to Control), I find that they act in whichever manner the software is set. For example, if I have the text input set for INSERT then the text will be inserted wherever the cursor is located. If the software is set to OVERWRITE then the text will be overwritten at the cursor position. Additionally, sending text to the control using Text Type will NOT set focus to the edit box.

 

The only other way to enter text in an edit box is to set focus to the dialog that it is located in and use the Text Type command normally. This gives you the advantage of being able to select existing text, delete it, and the type the new text all with the same Text Type command line. Send Text to Control does not allow for these editing keys.

Link to comment
Share on other sites

Have you tried to double-click on the control? Often a double click will highlight the content of a component. If so then a Text Type to Control would work because the first character typed would replace all the hightlighted text.

 

I would try manually double-clicking on the control and if the entire content is highlighted then insert the "Mouse Double Left Click on Control %C1%" command in your macro.

Link to comment
Share on other sites

Laurence,

 

Earlier today I updated a macro that uses the technique I describe above. It uses the "Mouse Double Left Click on Control %C1%" command. When this command executes, the content of the edit box represented by the control variable is highlighted. This allows the Text Type to Control to overwrite the content of the edit box.

 

The mouse did not move and focus did not change.

Link to comment
Share on other sites

Laurence,

 

How the component reacts depends on how the application was written. Have you tried manually clicking in the field to see what highlights all the text within it? Some applications may highlight the text with a single mouse click, others may require a double click and still others may require some other action. Once you determine what action workds you can write a macro to automate the process.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...