Forum Discussion
Read the object's height and width on runtime.
Find the center and click.
Even if the object location changes,It will dynamically adjust.
MyObject = Sys.Process("xxx").VCLObject("SyntaxEditorForm").VCLObject("mmoTop")
MyObject_Height = MyObject.Height
MyObject_Width = MyObject.Width
Myobject.Click(MyObject_Height/2,MyObject_Width/2,skCtrl)
Hi Vallalarasu,
Thank you for the reply. This will give me the coordinates of the object itself, which I can get easily enough. I need to get the coordinates of text within the control tho. My question is how can I get the coordinates of the text (or cursor) itself, so I can do a Ctrl+Click within the object?
For example, in the pic below, I have searched for '5' and placed the cursor there. I now need to get the coordinates of that '5' character in the editor, so I can then use Click(x,y,skCtrl). If there's a better way to do this, I'd much rather use that, but the only option I've found to do a Ctrl+Click is to use 'Click', with that 3rd parameter.
Any other suggestions?
- Vallalarasu_P6 years agoFrequent Contributor
If the coordinates which you have to find is not an object and a text, Then it can be done by OCR.
var textBlock = recognizedText.BlockByText(textToGet);
if (textBlock != null)
{
// Get info on bounds of the recognized text portion
var x = textBlock.Bounds.Left;
var y = textBlock.Bounds.Top;
var width = textBlock.Bounds.Width;
var height = textBlock.Bounds.Height;}
Hope this matches the requirement.
- dpaulus6 years agoOccasional Contributor
Thanks for the reply Vallalarasu. Yeah, I was hoping to stay away from using OCR, if possible. There's numerous issues I have with using OCR. I actually gave this a try and it didn't identify my text correctly. I may have to just stick to using coordinates in this case, for now, unfortunately. It seems like a relatively simple thing to just move the mouse to the actual cursor position and do a ctrl+click, but I guess not. Anyway, I appreciate the help.
Dennis
- AlexKaras6 years agoChampion Level 3
Hi Dennis,
Doesn't Obj.Click(-1, -1, skCtrl) work for you ?