u/sikyungbin

How to reliably switch to a specific open tab (ChatGPT) in Chrome when tab titles change dynamically? (AHK v2 / UIA)

Hi everyone,

I'm building an AutoHotkey v2 script to send selected text directly to an open ChatGPT tab in Google Chrome using UI Automation (UIA v2).

However, I've run into a persistent challenge with tab identification and switching:

The Problem:

Dynamic Tab Titles: Once a conversation starts, Chrome changes the tab title from "ChatGPT" to whatever the first sentence of the user prompt is (e.g., "How to fix UIA issue..."). Thus, matching tab names via string search fails after the first query.

Favicon ImageSearch Reliability: Using ImageSearch on tab favicons breaks when Chrome tabs shrink due to having 30+ tabs open, or when switching between active (light background) and inactive (dark background) tab states.

Chrome Tab Search Popup (Ctrl+Shift+A or TabStripFlatEdgeButton): Opening the Tab Search popup and typing chatgpt sometimes fails to filter open tabs in real-time or doesn't consistently focus the first "Open Tab" item when pressing Enter.

What I Want to Achieve:

If a ChatGPT tab is already open anywhere in Chrome (even as the 15th tab out of 40), switch to it seamlessly without moving the physical mouse cursor.

If no ChatGPT tab is open, create a new tab (Ctrl+T) and navigate to https://chatgpt.com/.

Once on the tab, focus and input text into the prompt textarea (AutomationId: "prompt-textarea").

Question:

What is the cleanest and most robust method in AHK v2 / UIA (or Chrome command line) to identify and bring an open tab to the foreground by its domain URL (chatgpt.com) regardless of dynamic tab titles or tab counts?

Please note that I want to avoid using CDP (Chrome DevTools Protocol), as I prefer not to deal with protocol-level implementations.

Any code or architectural advice would be greatly appreciated! Thanks in advance.

reddit.com
u/sikyungbin — 7 days ago