Skip to content

Check the window before pasting #23

Open

Description

@allo-

Running the LLM leads to some delay and might result in another window having the focus when the text is pasted, causing unintended actions.

It would be good to save the window that is currently focused before running the LLM and check if it still has the focus when pasting the result. In the best case one could check if the right textarea is selected, but I would currently not know a way to do this.

In an own project for Linux I use:

window_id = run_piped(["xdotool", "getactivewindow"])
# Run some code like waiting for the LLM to return a result
window_id2 = run_piped(["xdotool", "getactivewindow"])
if window_id2 != window_id:
    print("active window changed. Aborting.")
    return

I am not sure what's the Windows equivalent and there may also be a pure python approach to that, but I think the general idea of checking if the window is the same would help to prevent chaos when the user doesn't wait for the result. A fallback action when the window changed could be to show a dialog window with the result, so the user can copy & paste it into the right window.

Activity

  1. added
    suggestion
    on Oct 24, 2024
  2. added a commit that references this issue on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    suggestion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions