Jump to content

Recommended Posts

Posted

Hi everyone,

I'm working on a project where I want to create a tool that can improve or rephrase written text using the ChatGPT API. The idea is to select any text anywhere in Windows (for example: in a browser, application, system dialog, etc.) and send it to ChatGPT for suggestions. However, there's one specific requirement: I’d like to extract the selected text without relying on the clipboard (no copy-paste).

Is it possible to achieve this using AutoIt, perhaps with UI Automation or WinAPI? The tool should be able to detect and read the currently selected text in any context – ideally universally, not just in specific applications.

I know this might be a stretch, but I’m curious if anyone has experience with similar tasks or knows whether this is even technically feasible with AutoIt.

Any insight, ideas, or code examples would be greatly appreciated!

Thanks in advance!

Posted (edited)
1 hour ago, maniootek said:

The tool should be able to detect and read the currently selected text in any context – ideally universally, not just in specific applications.

There is something I would like to know : after the text is selected, you still need an option (maybe a hotkey) to send the selected text to its final destination. If not, how would the script "know" that it's the right moment to use what is selected ? Maybe you're in the middle of expanding the selection etc...

So do we agree with this ? I mean the fact that, after the selection is done, you still need to key (or click) something to start the process you want ?

Edited by pixelsearch
typo

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted (edited)

If your answer is "Yes, I have to type or click something after the selection is done" then :

This is what I do with my AutoIt translation's script :
1) Select with the mouse the text to translate, keep left button pressed (+++) then

2) click the right button
OR
2) type Ctrl+c

In both cases, it displays immediately the translation, like shown in the pic below :

Translation.png.cbb6c6636d2eb5172a7ccced75390038.png

Ctrl+c could be replaced by a hotkey like F12 (I guess, never tested) but as I need to type or click something to start the translation process, then I prefer to use Ctrl+c, here is the code used in main loop :

If _IsPressed("02", $hDLL) And _IsPressed("01", $hDLL) Then ; Right click (02) and Left click (01)
    Send("{CTRLDOWN}") ; Nine's way 3 lines  https://www.autoitscript.com/forum/topic/212337-stuck-ctrl-key/?do=findComment&comment=1537433
    Send("c")
    Send("{CTRLUP}")
    SplashTextOn("", "Translating...", 250, 50, -1, -1, 1 + 32) ; no title (1) + center text vertically (32)
    GUICtrlSendToDummy($idDummy_Translate) ; this will trigger the Translate control

ElseIf _IsPressed("11", $hDLL) And _IsPressed("43", $hDLL) And _IsPressed("01", $hDLL) Then ; Ctrl + C (11 + 43) and Left click (01)
    While _IsPressed("11", $hDLL) Or _IsPressed("43", $hDLL) ; Ctrl (11) or C (43) +++
        Sleep(10)
    WEnd
    SplashTextOn("", "Translating...", 250, 50, -1, -1, 1 + 32) ; no title (1) + center text vertically (32)
    GUICtrlSendToDummy($idDummy_Translate) ; this will trigger the Translate control
EndIf

It would be interesting to know why you don't want to use Ctrl+c to start the process, if it works without forcing the user to type Ctrl+v (Paste) ?

Edited by pixelsearch
typo

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   1 member

×
×
  • Create New...