How to get the text cursor position in Chrome from my Windows program?

1,925 views
Skip to first unread message

Sergey Koshkin

unread,
Nov 23, 2017, 1:40:07 AM11/23/17
to Chromium-discuss

I can get the text cursor position in any application using GetGUIThreadInfo WinAPI function. Structure GUITHREADINFO contains rect rcCaret for this.

But this function doesn't work in Chrome.

I have created special extension for such aims, but it's not the best solution.

How can I get the text cursor position in Chrome from my Windows program?

Jon Perryman

unread,
Nov 23, 2017, 5:16:32 PM11/23/17
to comfort...@gmail.com, Chromium-discuss
Are you asking about document.activeElement?

Regards, Jon.

--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discuss+unsubscribe@chromium.org.

Sergey Koshkin

unread,
Nov 24, 2017, 12:26:02 AM11/24/17
to Chromium-discuss, comfort...@gmail.com
Jon,

No. Chrome doesn't provide this to other Windows applications.

Best regards,
Sergey


On Friday, November 24, 2017 at 1:16:32 AM UTC+3, Jon Perryman wrote:

Jon Perryman

unread,
Nov 24, 2017, 10:56:33 AM11/24/17
to comfort...@gmail.com, Chromium-discuss
it's great you want to be brief but you need to give us some sort of information. Is your windows app accessing Chrome thru the backend, frontend, ole, an API, websockets or something else? Do you have a mod to chrome or using a third party api to give you access?

Regards, Jon.

Sergey Koshkin

unread,
Nov 24, 2017, 1:03:02 PM11/24/17
to Chromium-discuss, comfort...@gmail.com
Chrome works in OS Windows. It's Windows program in this case (but cross-platform program).
I want to work with Chrome as with any else Windows program.
As I wrote in my first post any Windows program provides information about the text cursor via GetGUIThreadInfo WinAPI function.
But Chrome doesn't work as Windows program.

How "...the backend, frontend, ole, an API, websockets..." can help me to get information about the text cursor?

Best regards,
Sergey

Jon Perryman

unread,
Nov 25, 2017, 10:55:03 AM11/25/17
to Sergey Koshkin, Chromium-discuss
For security reasons, native apps do not have direct access to chrome.regardless of operating system. Seems strange you only want is the selected field which is why I assumed you already found a method to access chrome from a native app. These days, javascript seems to be the only language (other facilities are being deprecated - eventually removed / unsupported).

You could try native messaging although it's not clear whether it is being deprecated. If you are using a server, you could use websockets. This will all depend upon your design. 

Good luck, Jon.

Reply all
Reply to author
Forward
0 new messages