Micro Focus QTP (UFT) Forums
How to chek focus..Need Help... - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to chek focus..Need Help... (/Thread-How-to-chek-focus-Need-Help)



How to chek focus..Need Help... - souvikghosh_diatm - 07-26-2011

Well i am going to ask to all abt a very simple problem which i do not know...I have a text box and i have to check whether the focus is in that edit box or not....


Can any one gv me any idea that how can i check this scenario??? NOTE:: The focus is coming as pre filled on that field....So i can not set it before i check it......



Is there any method that i can Use????Need idea on URGENT basis plzzz....


Any idea or suggestion will xtreamly appreciated.....


------------
Thanx.


RE: How to chek focus..Need Help... - rajpes - 07-26-2011

Why focus is required for that?
Code:
txt=Browser().page().webedit().getROproperty("value")
if len(txt)<>0 then
msgbox 'something is already present'
else Browser().page().webedit().set "new value"
end if



RE: How to chek focus..Need Help... - souvikghosh_diatm - 07-27-2011

@@--rajpes ::

Thanx a lot for your precious suggestion, but i think u did not undrstnd my requirement....i just need to check whether there is any focus on that particular text box or not....

U hv send me d code of to check the length of value present in text box, n if it is zero then set something....that is not required boss....i dnt have to set any thing....just hv to check d focus is there or not....


By d way i hav find out d solution by doing trial n error method for it to check whether focus is there on any particular text field or not....


Thanx once again.....


RE: How to chek focus..Need Help... - rajpes - 07-27-2011

Ok please share what solution you have found.how do you check focus on an object


RE: How to chek focus..Need Help... - souvikghosh_diatm - 07-28-2011

Well, not on an object...i tried it on edit box only....I did not think it would be so simple....

tried d following...

Browser("B").Page("P").WebEdit("WE").GetROProperty("Focus")

It will return 0 or 1...if 1 then focus is present, Else not....


Hope its d permanent solution for every application....Tried it on GWT and its working fine....


Let me know if it is working for all or not.....


-----------
Thanx.


RE: How to chek focus..Need Help... - rajpes - 07-28-2011

Thats amazing. Though spy doesnot show this property it works fine


RE: How to chek focus..Need Help... - souvikghosh_diatm - 07-28-2011

Ya i know spy does not show this...Actually i got it by doing trial and error method....I also did not know dat it would work as d permanent solution for me......ha ha...cheers dude......



-----------
Thanx.


RE: How to chek focus..Need Help... - rajasekhar - 04-03-2012

Hi Friend i followed the same process what you explained but i am getting blank alert screen. My code is

Code:
Dialog("Login").WinEdit("Agent Name:").Set "Raja"
Dialog("Login").WinEdit("Password:").SetSecure "4f7ac2299a7997511b7dfe107a3fa7a5a10912bf"
Dialog("Login").WinButton("OK").Click

a = window("Flight Reservation").ActiveX("MaskEdBox").GetROProperty("Focus")
msgbox a

is any mistake in this?????????????? can you pls share the information.