Use the WinGetTitle function, as most browsers set the current URL in the header.
loop { ; Get current Window ID & Name WinGet, active_id, ID, A WinGet, process_name, ProcessName, A WinGetTitle, this_title, ahk_id %active_id% ; Format the time-stamp. current=%A_DD%/%A_MM%/%A_YYYY%, %A_Hour%:%A_Min% ; Only do anything if any other windows was activated if(active_id = PrevActiveId) { if process_name contains chrome.exe,firefox.exe,iexplore.exe,flock.exe,k-meleon.exe,javaw.exe { ; Write titles to the log.txt file. fileappend, %current% - %process_name% - %this_title%`n, log.txt } } else { ; Write titles to the log.txt file. fileappend, %current% - %process_name% - %this_title%`n, log.txt } Sleep, 1000 PrevActiveId = %active_id% }
Anthony mastrean
source share