Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to write “blindly” to whatever object is selected
#1
Solved: 11 Years, 3 Months, 2 Weeks ago Question 
How can I “blindly” tell QTP to simply type whatever I want it to. So I don’t define anything, not the window name, not the form or object names, I simply want QTP to type say “Hello” wherever it is without regard to anything else. The example being, I already know that the object will be focused from form entry but I don’t know the objects details. How do I simply tell QTP to just type what I have defined?

Is this possible – and if so how?

This is something I have attempted to find a solution for, for some time now but after a lot of looking online I have been unable to find a solution, so hope someone will be able to say how it can be done (presuming it can be done at all – as I am leading to the conclusion it is beyond the means of QTP to do this).

Thanks in advance for any help in resolving this!
Reply
#2
Solved: 11 Years, 3 Months, 2 Weeks ago
Hi D2010,

It's a strange requirement.... But we have the solution :-)
You can use the wscirpt and enter the value.

Try this my friend...

Code:
Set Wsh = CreateObject ("WSCript.shell")
Wsh.SendKeys "Hello"
Set Wsh = Nothing 'Relaesing the Wsh object.

But, could you tell me why you want to do this.....
Thanks,
SUpputuri
Reply
#3
Solved: 11 Years, 3 Months, 2 Weeks ago
Thanks Supputuri, that worked perfectly.

In regards to you asking why, I can't recall the exact business purpose as I first attempted this over a year ago when I was just learning QTP and the contractors I was working with were unable to resolve this issue so I left the issue alone. I only asked now as I posted another query about the focusing of objects.

I believe it may have been something to do with the form creating dynamic objects dependent upon your previous data entry, therefore I would not know which of the objects would be created, but would know that upon entry to the form the object would already be selected and therefore I could simply enter the data I required without any regards to what it was.

Thanks again for your help, it is greatly appreciated.
Reply
#4
Solved: 11 Years, 3 Months, 2 Weeks ago
Hmm :-) good Interesting.
Thanks,
SUpputuri
Reply
#5
Solved: 11 Years, 3 Months, 2 Weeks ago
Supputuri,

Can the Wsh method be used for other keyboard actions such as 'micDwn' (pressing the arrow keys)? - I tried it by replacing the "Hello" with micDwn but couldn't get it to work, so presume it either can't be down or is done differently. Any ideas?
Probably should have searched online before asking, but I have found the answer to my own question. For anyone elses benefit, yes it can be done and below are the key values:

micF1 WshShell.SendKeys "{F1}"
micF2 WshShell.SendKeys "{F2}"
micF3 WshShell.SendKeys "{F3}"
micF4 WshShell.SendKeys "{F4}"
micF5 WshShell.SendKeys "{F5}"
micF6 WshShell.SendKeys "{F6}"
micF7 WshShell.SendKeys "{F7}"
micF8 WshShell.SendKeys "{F8}"
micF9 WshShell.SendKeys "{F9}"
micF10 WshShell.SendKeys "{F10}"
micF11 WshShell.SendKeys "{F11}"
micF12 WshShell.SendKeys "{F12}"
SF1 WshShell.SendKeys "+{F1}"
SF2 WshShell.SendKeys "+{F2}"
SF3 WshShell.SendKeys "+{F3}"
SF4 WshShell.SendKeys "+{F4}"
SF5 WshShell.SendKeys "+{F5}"
SF6 WshShell.SendKeys "+{F6}"
SF7 WshShell.SendKeys "+{F7}"
SF8 WshShell.SendKeys "+{F8}"
SF9 WshShell.SendKeys "+{F9}"
SF10 WshShell.SendKeys "+{F10}"
SF11 WshShell.SendKeys "+{F11}"
SF12 WshShell.SendKeys "+{F12}"
"SF1" WshShell.SendKeys "+{F1}"
"SF2" WshShell.SendKeys "+{F2}"
"SF3" WshShell.SendKeys "+{F3}"
"SF4" WshShell.SendKeys "+{F4}"
"SF5" WshShell.SendKeys "+{F5}"
"SF6" WshShell.SendKeys "+{F6}"
"SF7" WshShell.SendKeys "+{F7}"
"SF8" WshShell.SendKeys "+{F8}"
"SF9" WshShell.SendKeys "+{F9}"
"SF10" WshShell.SendKeys "+{F10}"
"SF11" WshShell.SendKeys "+{F11}"
"SF12" WshShell.SendKeys "+{F12}"
"CF1" WshShell.SendKeys "^{F1}"
"CF2" WshShell.SendKeys "^{F2}"
"CF3" WshShell.SendKeys "^{F3}"
"CF4" WshShell.SendKeys "^{F4}"
"CF5" WshShell.SendKeys "^{F5}"
"CF6" WshShell.SendKeys "^{F6}"
CF1 WshShell.SendKeys "^{F1}"
CF2 WshShell.SendKeys "^{F2}"
CF3 WshShell.SendKeys "^{F3}"
CF4 WshShell.SendKeys "^{F4}"
CF5 WshShell.SendKeys "^{F5}"
CF6 WshShell.SendKeys "^{F6}"
micHome WshShell.SendKeys "{HOME}"
micEnd WshShell.SendKeys "{END}"
micBack WshShell.SendKeys "{BACKSPACE}"
micReturn WshShell.SendKeys "{ENTER}"
micTab WshShell.SendKeys "{TAB}"
micDwn WshShell.SendKeys "{DOWN}"
micUp WshShell.SendKeys "{UP}"
micLeft WshShell.SendKeys "{LEFT}"
micRight WshShell.SendKeys "{RIGHT}"
micEsc WshShell.SendKeys "{ESC}"
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to get selected childitem in webtable? rupali0205 1 5,952 02-08-2012, 03:43 PM
Last Post: rupali0205

Forum Jump:


Users browsing this thread: 4 Guest(s)