How to do a Ctrl+Click in a Text Edit Object without using coordinates
Hi,
I'm looking for a way to avoid having to use actual coordinates to do a Ctrl+Click Action. The Click method has this capability, by using a 3rd paramter 'skCntrl', but to use this, I have to provide coordinates. e.g. Obj.Click(X, Y, skCtrl)
I found a similar post that dynamically figures out the coordinates of the Mouse (see below), which works great, but I would like it to look at the actual cursor position, instead of the mouse pointer position. I can also get this to work if I only have 1 line of text, but the goal is to be able to search for any text (possibly in a long script in the Editor object), set the cursor, and then do a Ctrl+Click, at that given point.
Any Ideas?
Sample code to get coordinates dynamically by Mouse cursor position:
def Test():
import time
time.sleep(5)
MyObject = Sys.Process("xxx").VCLObject("SyntaxEditorForm").VCLObject("mmoTop")
# Gets current mouse cursor coordinates on screen
screenMouseX = Sys.Desktop.MouseX
screenMouseY = Sys.Desktop.MouseY
Log.Message("X: " + str(screenMouseX) + " Y: " + str(screenMouseY))
# Gets the object behind the mouse cursor
onscreenObj = Sys.ObjectFromPoint(screenMouseX,screenMouseY)
# Converts the screen coordinates to coordinates relative to the object
controlPoint = MyObject.ScreenToWindow(screenMouseX,screenMouseY)
Log.Message("objX: " + str(controlPoint.X) + " objY: " + str(controlPoint.Y))
# Control Clicks object from the converted coordinates
onscreenObj.Click(controlPoint.X,controlPoint.Y, skCtrl)