-1

I am using surface automation tool thin application (desktop application). In that I need to delete all the text already present in textbox and then write the word.

For example, in login page for username textbox I want to delete username's content and then write new username.

So, I am first sending global send key event or global send key (tried both), then sending
""<{CTRL}A>{CTRL}{DEL}"&[username]", but it's not working.

I want to use "Control all +del" option. I dont want to use {DEL 20}

esqew
  • 42,425
  • 27
  • 92
  • 132
Priya Sangle
  • 19
  • 1
  • 2
  • 8
  • For the one close vote as Off-topic -> Super User migration: this is without a doubt on-topic for Stack Overflow, as evidenced by the rest of the `blueprism` tag regarding the enterprise-grade automation platform. – esqew Mar 14 '19 at 12:27

1 Answers1

4

If you are using surface automation techniques, then you need to make sure that your target textbox is active/selected first, which you can do by sending Global Mouse Click Centre to this sub-region.

When it comes to sending CTRL+a+DEL keystrokes combination then correct syntax would be:

Global Send Keys - "^a{DEL}" & [test variable]

Global Send Key Events - "<{CTRL}a>{CTRL}{DEL}" & [test variable]

Remember that keystrokes need to be sent to target application, not to the textbox itself. If it does not work, then maybe the target application does not work with CTRL+a combination.

Another way to go would be imitating double mouse click by sending Global Mouse Click Centre with short (0.1s for example) pause between steps to the target textbox, and then sending "{DEL}" & [test variable] to the application. Double mouse click should highlight text in the field and DEL keystroke should delete it.

Hope this helps

Damian B
  • 339
  • 2
  • 8
  • 2
    Double mouse click does not always highlight the text in the field, it will always highlight the word at the cursor position. Usually triple mouse click will select the whole text. I personally prefer (control) home, shift+(control) end, delete to delete all the text in a field. – Jerry Mar 14 '19 at 10:44
  • Good point, I focused on the 'username' only and thought about it as a single string. Also in some applications there's a possibility to right click and choose 'select all' option, however it's not going to be easy with surface automation. – Damian B Mar 14 '19 at 10:54
  • Hi @DamianB none of your three option works for me. I did as you said. they are just appending [test variable] to already present text – Priya Sangle Mar 15 '19 at 11:15
  • Hi @Jerry can you please give me combination syntax for your suggested answer – Priya Sangle Mar 15 '19 at 11:16
  • 1
    Have you tried CTRL+a keystroke combination manually? Are you sure that your target application accepts it? Syntax for solution @Jerry proposed would be "^{HOME}+^{END}{DEL}" & [test variable] for Global Send Keys and "{HOME}<{SHIFT}<{CTRL}{END}>{SHIFT}>{CTRL}{DEL}" & [test variable] for Global Send Key Events. However I strongly recommend testing application behavior against these keystrokes manually first and then trying to automate it. – Damian B Mar 15 '19 at 11:45
  • @DamianB u r right surface automation does not support anything other than "del" and "BS" manually so there is no point of using all the above option. I just have to use "DEL 50" something like this – Priya Sangle Mar 18 '19 at 05:16
  • Some of user name/password textboxes have character count limit, so you can check if there's any and if it is, you'll know how many times you need to send "{DEL}". Remember that when using just "DEL" you need to position cursor on the leftmost side within the textbox first. – Damian B Mar 18 '19 at 08:37