问题描述
限时送ChatGPT账号..确定当前活动文本输入光标的屏幕坐标的最佳方法是什么?
What is the best way to determine the screen co-ordinates of the currently active text input cursor?
我需要将其用于内嵌音译程序,以便在输入文本时向用户显示一些建议选项.
I need this for an in-line transliteration program so that I can display some suggestions options to the user as the text is entered.
推荐答案
首先将线程输入附加到活动应用程序 (AttachThreadInput
).然后使用 GetCaretPos<获取插入符号的位置/代码>.位置在客户端坐标,调用
GetFocus
获得带有插入符号的窗口的句柄,然后使用 ClientToScreen
.最后通过再次调用 AttachThreadInput
来分离线程输入.
First attach the thread input to the active application (AttachThreadInput
). Then get the caret's position with GetCaretPos
. The position is in client coordinates, call GetFocus
to have the handle to the window that has the caret, then convert the coordinates to screen coordinates with ClientToScreen
. Finally detach the thread input by calling again AttachThreadInput
.
这篇关于如何确定 Windows 中的文本光标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论