Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

get type cyrsor position at screen from microsoft word and any enviroment for type text

hi
i want to show a form when user type anything in microsoft word or any word proccesor enviroment sych as MS Notepad or . and need to get type cursor position at screen for displaying my form from this position. please help me for get type cursor position at screen.
and so sorry for my bad english ;-)
best regards.
0
mahdiparak
Asked:
mahdiparak
1 Solution
 
atul_parmarCommented:
Hi, try this

var
  p : TPoint;
  hWord, Pid1, Pid2 : THandle;
  WordTitle : String;
begin
  WordTitle := 'Document1 - Microsoft Word';
  hWord := FindWindow(nil, PChar(WordTitle));
  if (hWord = 0) or (hWord <>  GetForegroundWindow) then Exit;
  Pid1 := GetWindowThreadProcessId(hWord, nil);
  Pid2 := GetCurrentThreadId;
  AttachThreadInput(Pid1, Pid2, True);
  if GetCaretPos(p) then
    if Windows.ClientToScreen(hWord, p) then
      MoveWindow(Handle, p.X, p.Y, Width, Height, True);
end;
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now