Can AHK Copy page title and url?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ButterZ
Posts: 7
Joined: 23 Feb 2019, 18:05

Can AHK Copy page title and url?

04 May 2019, 00:37

What I want to do is have a copy of the active page title and page URL copied into a notepad text document or GUI with links. .

I have little experience with AHK I have made a few simple apps, but I don't know how to make this or where to begin.

I started to make a GUI just to give you guys some inspiration and visual idea of what I am working on.


Image
garry
Posts: 3770
Joined: 22 Dec 2013, 12:50

Re: Can AHK Copy page title and url?

05 May 2019, 12:26

Example for browser Firefox
you can add also an input before write to file
use a listview to read the file , click then column-2 to start url

Code: Select all

;- for Mozilla Firefox , copy TITLE and URL from active TAB
;-----------------------------------------------------------
;- MODIFIED = 20190505
;- CREATED  = 20190505
;---------------------
#warn
#NoEnv
DetectHiddenWindows, Off
SetTitleMatchMode, 2
return

;- key win+7
$#7::
KeyWait p
SetTitleMatchMode, 2
If (WinID := WinExist("A"))   ;- active window
{
f1=%a_desktop%\Title_Url_Copied.txt
WinGetTitle, Title, ahk_id %WinID%
if title contains Mozilla
  {
  xxc:=" - Mozilla Firefox"
  stringreplace,title,title,%xxc%,,all
  url      :=""
  Clipboard:=""
  sleep,200
  sendinput,!s            ;- alt+s copies url in mozilla firefox
  sleep,1000
  sendinput, ^c{right}
  sleep,500
  clipwait,
  URL:=clipboard
;  InputBox, UserInput, comments
;   if errorlevel<>0
;      return
  FileAppend,%Title% `;%url%`r`n,%F1%
  Splashimage,,b w900 h150 x100 Y400 CWsilver m9 b fs10 zh0,%title%`n%url%
  Sleep,900
  Splashimage, off
  run,%F1%
  url      :=""
  Clipboard:=""
  return
  }
return
}
return
esc::exitapp
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Can AHK Copy page title and url?

05 May 2019, 17:40

There's code here to get the title/url for the active tab in Firefox/Chrome:
Firefox/Chrome, get tab names/focus tab - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26947

There's code here to get the titles/urls for all tabs in Internet Explorer:
jeeswg's Internet Explorer and HTML tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=31766
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
garry
Posts: 3770
Joined: 22 Dec 2013, 12:50

Re: Can AHK Copy page title and url?

06 May 2019, 02:26

jeeswg, thank you for the examples also for chrome and internetexplorer
Automator
Posts: 4
Joined: 21 May 2020, 11:19

Re: Can AHK Copy page title and url?

22 May 2020, 03:13

Hey garry,

Thanks to you, I managed to capture name of an active browser card (or any active window):

Code: Select all

!F3::
	
		DetectHiddenWindows, Off			;I don't know whether it's required
		SetTitleMatchMode, 2				;I don't know whether it's required

	If (WinID := WinExist("A"))  				 ;- active window
		{
		WinGetTitle, Title, ahk_id %WinID%		;title of a window or active browser card
		;Clipboard := title

		if title contains Mozilla		;cut Mozilla in the name
  			{
			xxc:=" - Mozilla Firefox"
  			stringreplace,title,title,%xxc%,,all
			}
  		Clipboard:=title
		}

return
Here you can copy URL:

Code: Select all

#F3::
	sendinput,{F6}
	Sleep 25
	sendinput,^c
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Google [Bot], Spawnova and 327 guests