Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
MartinaX Valued Contributor.
Valued Contributor.
1135 views

Using SendKeys method to delete what written before

Hi everyone!

I need some help with SendKeys Method. I wrote what you can see in the picture down below using the following instructions:

set mySendKeys = CreateObject("WScript.shell")
mySendKeys.SendKeys("MELIS PIETRO (PADRE) PER 1/2-FARRIS GIUSEPPINA (MADRE) PER 1/2").

Now I have to delete MELIS PIETRO (PADRE) PER 1/2-FARRIS GIUSEPPINA (MADRE) PER 1/2 and write another expression using the same method: could anybody help me, please? I need it for work.

Thank you so much.

Kind regards,

MartinSendKeys.png

0 Likes
13 Replies
Micro Focus Expert
Micro Focus Expert

Re: Using SendKeys method to delete what written before

hi, 

You can use more sendKeys to do so by sending Ctrl+A and Back. 

Thanks.

Jamse

MartinaX Valued Contributor.
Valued Contributor.

Re: Using SendKeys method to delete what written before

Hi!

Could you write your suggestion, please? Therefore, how can I select what I wrote before to delete it?

Thanks.

Martina 

0 Likes
Knowledge Partner
Knowledge Partner

Re: Using SendKeys method to delete what written before

In the majority of cases I've usually been able to send a null string to remove a value via sendkeys, would this work fot=r you?

With Browser("micClass:=Browser").Page("micClass:=Page)

	.WebEdit("html id:=password").Click
	Wait(1)
	MISC_SendKeys("")

End With

Sub MISC_SendKeys(sKey)
	Set WSH = CreateObject("WScript.Shell")
	WSH.SendKeys sKey 
	Set WSH = Nothing
End Sub

Mark Smith.

liorde Honored Contributor.
Honored Contributor.

Re: Using SendKeys method to delete what written before

Hi,
Is this a multi-line editor? Do you have to clear all text in the area or only 1 line (or 1 line at a time)?
Anyway, the way to approach this with SENDKEYS is either what James suggested :
set mySendKeys = CreateObject("WScript.shell")
mySendKeys.SendKeys("^(a)")  '' ctrl+a
wait 0500
mySendKeys.SendKeys("{DELETE}")

Of you need to delete line by line then just change it to 

mySendKeys.SendKeys("{END}")
wait 0, 250
mySendKeys.SendKeys("+{HOME}")
wait 0, 250
mySendKeys.SendKeys("{DELETE}")

Hope this  helps.

MartinaX Valued Contributor.
Valued Contributor.

Re: Using SendKeys method to delete what written before

It works, perfect!

Thanks.

0 Likes
liorde Honored Contributor.
Honored Contributor.

Re: Using SendKeys method to delete what written before

Glad it helps..!

0 Likes
MartinaX Valued Contributor.
Valued Contributor.

Re: Using SendKeys method to delete what written before

Hi guys!

Unfortunately the instructions you suggested work only with active screen and only if I click at the end of the part in question in order to let UFT delete it. The object where I have to write is a WinObject (the window) and the text I have to cancel is seen as a Web Element. Could you help me again, please?

Thank you,

Martina

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: Using SendKeys method to delete what written before

hi, 

To run a test in a disconnected RDP, you need to configure the credential in UFT and open UFT before disconnecting the remote session. You can find more details in the online help. 

Running a Test in a minimized session is not supported to my knowledge.

Thanks.

James

0 Likes
liorde Honored Contributor.
Honored Contributor.

Re: Using SendKeys method to delete what written before

Hi again,

Do you wish to ACTIVATE the window before performing the "delete-text" action on it?
If it has worked before , what has changed? What do you mean by Active screen? Do you have a few screens to toggle from under the same application? It makes sense that your focus has to be on the window before interacting with it in any way...

 

Please elaborate on your problem...

0 Likes
MartinaX Valued Contributor.
Valued Contributor.

Re: Using SendKeys method to delete what written before

Hi!

This is a part of a test and the problem is that, when it arrives at that point, the instructions I wrote to delete those names aren't read by UFT, because I can't put mouse pointer at the end of the line automatically. The click on the window doesn't work (Browser("xxx”).Page("xxx”)..WebElement("xxx”).Click) . If I pause the test, click on the window manually and run it again, SendKeys method works. I wish it's clearer now.

Thanks.

0 Likes
Knowledge Partner
Knowledge Partner

Re: Using SendKeys method to delete what written before

Would doing a double-click frpollowed by sending "" work?

Mark Smith.

0 Likes
RajkumarR Outstanding Contributor.
Outstanding Contributor.

Re: Using SendKeys method to delete what written before


@MartinaX wrote:

The click on the window doesn't work (Browser("xxx”).Page("xxx”)..WebElement("xxx”).Click) .


Can you check if the WebElement description is correct? Click Highlight from the OR & see if it correctly highlights the object.

_____________________
Rajkumar Rajangam
0 Likes
Rems Frequent Contributor.
Frequent Contributor.

Re: Using SendKeys method to delete what written before

Hi,

Was the issue solved?

Is it possible to get the co-ordinates of the webelement and workout the co-ordinates to click, click there and then delete text and send the new text.

Dim deviceReplay : Set deviceReplay = CreateObject("Mercury.DeviceReplay")
 deviceReplay.MouseClick x,y,0

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.