write an ahkv2 scripts that savd the current url of active browser tab
- User
write an ahkv2 scripts that savd the current url of active browser tab
Assistant
Here is an AutoHotkey v2 script that saves the current URL of the active browser tab to a file:
; Get the active window title and class to check if it's a browser WinGetTitle, title, A WinGetClass, class, A ; Check if it's Chrome, Firefox or Edge if (class = "Chrome_WidgetWin_1" or class = "MozillaWindowClass" or class = "Chrome_WidgetWin_1") { ; Get the active tab url Url := "" if (class = "Chrome_WidgetWin_1") { Url := GetChromeUrl() } else if (class = "MozillaWindowClass") { Url := GetFirefoxUrl() } else { Url := GetEdgeUrl() } ; Save url to file FileAppend, %Url%`n, urls.txt } GetChromeUrl() { WinGet, id, ID, A Url := "" if (id) { Url := GetBrowserUrl("ahk_id " id) } return Url } GetFirefoxUrl() { WinGet, id, ID, A Url := "" if (id) { Url := GetBrowserUrl("ahk_id " id) } return Url } GetEdgeUrl() { Url := GetBrowserUrl("ahk_class Edge") return Url } GetBrowserUrl(winTitle) { WinGet, process, ProcessName, %winTitle% WinGet, id, ID, %winTitle% Url := "" if (process && id) { WinGet, url, URL, ahk_id %id% ahk_exe %process% } return Url }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.