Obtaining Current Webpage Link, Title and Add Text

Post your working scripts, libraries and tools for AHK v1.1 and older
smogmanus
Posts: 45
Joined: 27 Jul 2015, 12:44

Obtaining Current Webpage Link, Title and Add Text

Post by smogmanus » 13 Jan 2024, 10:55

;~ I have always had the need to save webpages and links for future reference and along with easily text from that webpage for further explanation of page content. I use this script ten times a day. I did not write the code to do the work there included is a reference link to who wrote the working code I added code to serve my needs. How to extract url from a webpage?
;~ Source for the real programming I just added what I needed.
;~ viewtopic.php?f=63&t=92161&p=430924&hilit=atnbueno+current+tab#p429201
;~ Video of how it works.
;~ https://studio.youtube.com/video/puLG8vxE3jo/edit


;~ #Requires AutoHotkey v1.1.33+
; getactiveurl.ahk
#SingleInstance, force
#NoTrayIcon


Menu, Tray, Icon, % A_WinDir "\system32\netshell.dll", 86 ; Shows a world icon in the system tray

ModernBrowsers := "ApplicationFrameWindow,Chrome_WidgetWin_0,Chrome_WidgetWin_1,Maxthon3Cls_MainFrm,MozillaWindowClass,Slimjet_WidgetWin_1"
LegacyBrowsers := "IEFrame,OperaWindowClass,MozillaWindowClass"

return
;~ How to extract url from a webpage?
;~ Source for the real programming I just added what I needed.
;~ viewtopic.php?f=63&t=92161&p=430924&hilit=atnbueno+current+tab#p429201

::findlink1::
run, http://autohotkey.com/board/topic/17633-/?p=434518
return

::findlink2::
; "GetAddressBar" based in code by uname
run, http://autohotkey.com/board/topic/103178-/?p=637687
return

::findlink3::
; The code below is part of the Acc.ahk Standard Library by Sean (updated by jethrow)
run, http://autohotkey.com/board/topic/77303-/?p=491516
return

::findoriginal::
run, https://www.autohotkey.com/board/topic/111114-get-the-url-of-the-current-active-browser-tab/
return




::supdate::
SetKeyDelay, 1500, 1500
;~ This was added to prevent script loss from various computer using dropbox
FormatTime, CurrentDateTime,, yyyyMMddHHmm
DestFile := A_ScriptDir "\shareable-repository\bbb-1-shareable-docs-" CurrentDateTime ".ahk"
SourceFile := A_ScriptDir "\bbb-1-shareable-docs.ahk"
;~ Always check variables spelling and correct path
;~ MsgBox, % DestFile
;~ MsgBox % SourceFile
FileCopy, %SourceFile%, %DestFile%

Sleep, 1000

SetKeyDelay, -1 ; Reset key delay to default values
return

;saves current clipboard to clipboardold
cbsave(){
global
clipboardold = %clipboard%
ClipWait, 1
clipboard =
clipboard :=
}

;restores old clipboard content
cbrest(){
global
clipboard = %clipboardold%
ClipWait, 1
SetKeyDelay -1,-1,-1
}




^!p:: ;sends webpage title
mtclient()
return


mtclient() {
;~ global sURL, title, scname, scbody
sURL := GetActiveBrowserURL()
SetKeyDelay 111755,111755,111755
winget, ActiveID, ID, A
;~ MsgBox %sURL% %A%


nTime := A_TickCount
if (sURL = "") {
}

else

{
sURL := GetActiveBrowserURL()
;~ MsgBox %sURL%
WinGetTitle, title, A
;~ MsgBox Title %title%
WinGetClass, sClass, A
browserid=sURL
;~ MsgBox, %title%|%sURL%|%sClass%|%browserid%

}


;~ MsgBox CB %clipboard%
cbsave()
MsgBox, 4100, Copy Text For Body of Email, Highlight text needed in body of message`r use Control A to Highlight Control C to load into clipboard.
IfMsgBox No
return
IfMsgBox Yes

;~ MsgBox Before %clipboard%


;~ MsgBox % clipboard
clipboard := (RegExReplace(clipboard, "%", "``%"))
sleep 500
;~ MsgBox Clip Clean After %clipboard%
;~ clipboard := RegExReplace(clipboard, "\r", "`r`n")
sleep 500
;~ cbsave()
;~ MsgBox After Screen Copy %clipboard%
ClipWait, 1

scbodypaste := clipboard
cbrest()
InputBox, scbodyplus, Enter any additional text to copied material.
scbody := scbodypaste . scbodyplus
;~ MsgBox Pasted %scbody%
;~ cbrest()
;~ MsgBox Back to original %clipboard%
;~ MsgBox Before %clipboard%
;~ scbody := clipboard
;~ clipwait, 1
;~ MsgBox, %scbody%
;~ scbody := RegExReplace(scbody,"%","`%")
;~ sleep 500
;~ MsgBox First regexe %scbody%
;~ return
;~ MsgBox Clip Clean After %clipboard%
;~ scbody := RegExReplace(scbody, "\r", "`r`n")
;~ sleep 500
;~ MsgBox %scbody%

Gui +LastFound +OwnDialogs +AlwaysOnTop
inputbox, scname, Enter Name of New Script,,,,,, ;add additional text I have not found out how to paste multiple

;~ Gui +LastFound +OwnDialogs +AlwaysOnTop
;~ inputBox, scbody, Enter Additional Text,That Supports This Story,,,,,, ;1550,150 ;add additional text I have not found out how to paste multiple paragraphs.
Gui +LastFound +OwnDialogs +AlwaysOnTop
inputBox, pcom, Enter Private Such As Hash Mark or Another Description Comments,,,,,, ;1550,150 ;add additional text I have not found out how to paste multiple paragraphs.
ClipWait, 1

;~ FileDelete %A_ScriptDir%\formattext.txt
sleep 500

;~ MsgBox %scbody%
;~ gosub reglink
;~ scbody := RegExReplace(scbody, "\`r", "\`r\`n")


;~ MsgBox Reglink
ClipWait, 2 ;: This command waits for 2 seconds for the clipboard to contain data.

SetKeyDelay 100,100 ;: This command sets the delay between keystrokes to 100 milliseconds.

;~ clipboard = %title% ;: This line sets the clipboard to the value of the title variable.

;~ sURL := RegExReplace(sURL,"%","`%") ; This line uses the RegExReplace` function to search for the character "%" in the title and replace it with a literal "%" character.
;~ MsgBox sURL Before %sUrl%
sURL := RegExReplace(sURL, "%", "``%")
;~ MsgBox, After sURL %sURL%

;~ MsgBox scbody Before %scbody%
;~ scbody := RegExReplace(scbody, "%", "``%")
;~ MsgBox scbody After %scbody%
;~ scbody := RegExReplace(scbody, "``r", "`r`n")

;~ MsgBox, % title Before
;~ title := RegExReplace(title, "%", "``%")
;~ MsgBox, % title after


;~ scbody %scbody%
;~ regular expressions to clean up pulled text from website
title := (RegExReplace(title, "— Tor Browser", ""))
title := (RegExReplace(title, "%", "``%"))
title := regexreplace(title,�,"")
title := RegExReplace(title,"^\(\d+\)\s*","")
;~ s* line 208 %title%
title := RegExReplace(title,"Mozilla Firefox","") ; This line uses the RegExReplace function to search for the string "� Mozilla Firefox" in the title and replace it with an empty string.
;~ Mozilla Gone Line 210 %title%
title := RegExReplace(title, "^\(\)\s", "") ; remove () at the beginning of a line
;~ Removes () l 213 %title%
title := RegExReplace(title, "^\d+\s{1}", "") ; remove any number at the beginning of a line
;~ Line 215 Remove Number begining of line %title%
;~ title := RegExReplace(title, "[(0-9)]")
;~ MsgBox %title%
title := RegExReplace(title,"׀","") ;This line uses the RegExReplacefunction to search for the pattern "stline= (([0-9)]))" in the title and replace it with "stline =". The RegExReplace function uses regular expressions to perform the search and replace.
;~ Line 220 Remove | line 220 %title%
title := RegExReplace(title,"stline = (([0-9)]))","stline =") ;This line uses the RegExReplacefunction to search for the pattern "stline= (([0-9)]))" in the title and replace it with "stline =". The RegExReplace function uses regular expressions to perform the search and replace.
;~ Line 223 Put in stline %title%
title := RegExReplace(title,"&","and") ; This line uses the RegExReplace function to search for the character "&" in the title and replace it with "and".
;~ Line 225 Remove & %title%
;~ MsgBox %title%
title := RegExReplace(title,"�","") ; This line uses the RegExReplace function to search for the character "�" in the title and replace it with an empty string.
;~ line 229 "�" %title%
title := RegExReplace(title,"Google","") ; This line uses the RegExReplace function to search for the string "Google" in the title and replace it with an empty string.
;~ Line 231 Google Remove %title%
title := RegExReplace(title,"-.+YouTube","") ; This line uses the RegExReplace function to search for the pattern "-.+YouTube.+�" in the title and replace it with an empty string.
;~ Line 234 Remove Youtube %title%
title := RegExReplace(title,"YouTube","") ; This line uses the RegExReplace function to search for the string "Chrome" in the title and replace it with an empty string.
;~ Line 236 Remove Youtube %title%
;~ MsgBox %title%
title := RegExReplace(title,"x97","") ; This line uses the RegExReplace function to search for the string "x97" in the title and replace it with an empty string.
;~ Line 241 x97 %title%
title := RegExReplace(title,"Chrome","") ; This line uses the RegExReplace function to search for the string "Chrome" in the title and replace it with an empty string.
;~ Line 234 Chrome %title%

;~ MsgBox %title%
;~ title := RegExReplace(title,"??","")
;~ MsgBox Line 248 remove ?? %title%



ClipWait, 1
;~ MsgBox %scbody%

FormatTime, DateTimeString,, M/d/yyyy h:mm tt
;~ Send, %DateTimeString%
;~ MsgBox Script Name %scname% A_return{a_space} Title %title%`rsURL %sURL%`rSbody %scbody%



;~ MsgBox Script Name %scname% A_return
;~ MsgBox Title %title%
;~ MsgBox Link %sURL%
;~ MsgBox Sbody %scbody%
SetKeyDelay 111755,111755,111755
DetectHiddenWindows, on
;~ WinActivate, ahk_exe outlook.com
sleep 2000

;~ #Persistent
SetKeyDelay 111755, 111755, 111755
DetectHiddenWindows, on

/*
Example of pulling webpage information writing it to a file to be shared again.
adds captured information to a file to be repeat again.


::everyapp:: ;utilitiesapp
stline =
(
Everything is a fabulous utility for finding files anywhere on your computer or network.
Download Everything ... for Windows - Filehippo.com
https://filehippo.com/download_everything/

Comprehensive search utility for Windows! Everything is a popular search utility tool for Windows.
It uses fast indexing features to display folders and files. It's worth mentioning that Everything is known for fast initial indexing, which takes about one minute to complete. According to the developers, indexing a new Windows 10 installer takes less than one second to complete. Unlike Windows Search Function, Everything displays folders and files matching the user's input. As such, you can use multiple filters for advanced searches that give accurate results.
)
clipw()
return
::everyappr.::
run, https://filehippo.com/download_everything/
return
*/

FileAppend,`r`:`:%scname%`:`: `;`~%DateTimeString% %pcom% `nstline =`n`(`n%title%`n%sURL%`n`r%scbody%`n`)`nclipw`(`)`nreturn `n`:`:%scname%r.`:`:`nrun %sURL%`nreturn`n`n, %A_ScriptDir%\bbb-1-shareable-docs.ahk

setKeyDelay -1, -1, -1
sleep 1500

;reloads updated files
;~ run, %A_Scriptdir%\ahkstart.ahk
;~ FileCopy %A_ScriptDir%\bbb-1-shareable-docs.ahk, %A_ScriptDir%\shareable-repository\bbb-1-shareable-docs%A_DDD%-%A_MMM%-%A_DD%-%A_YYYY%.ahk


SetKeyDelay, 1500, 1500
;~ This was added to prevent script loss from various computer using dropbox
FormatTime, CurrentDateTime,, yyyyMMddHHmm
DestFile := A_ScriptDir "\shareable-repository\bbb-1-shareable-docs-" CurrentDateTime ".ahk"
SourceFile := A_ScriptDir "\bbb-1-shareable-docs.ahk"
;~ Always check variables spelling and correct path
;~ MsgBox, % DestFile
;~ MsgBox % SourceFile
FileCopy, %SourceFile%, %DestFile%

Sleep, 1000

SetKeyDelay, -1 ; Reset key delay to default values

;~ MsgBox, File copied to: %DestFile%
WinActivate, bbb-1-shareable-docs.ahk - SciTE4AutoHotkey
run, %A_Scriptdir%\ahkkill.bat
return
}

;~ How to extract url from a webpage?
;~ Source for the real programming I just added what I needed.
;~ viewtopic.php?f=63&t=92161&p=430924&hilit=atnbueno+current+tab#p429201


;~ chatgpt generated
GetAddressBar(accObj) {
if ((accObj.accRole(0) == 42) and IsURL(accObj.accValue(0))) {
return accObj
}
if ((accObj.accRole(0) == 42) and IsURL("http://" . accObj.accValue(0))) { ; Modern browsers omit "http://"
return accObj
}
for nChild, accChild in Acc_Children(accObj) {
accAddressBar := GetAddressBar(accChild)
if IsObject(accAddressBar) {
return accAddressBar
}
}
}

;~ chatgpt generated
GetActiveBrowserURL() {
global ModernBrowsers, LegacyBrowsers
WinGetClass, sClass, A
If (sClass In ModernBrowsers) {
Return GetBrowserURL_ACC(sClass)
} Else If (sClass In LegacyBrowsers) {
Return GetBrowserURL_DDE(sClass) ; empty string if DDE not supported (or not a browser)
} Else {
Return ""
}
}

;~ chatgpt generated
GetBrowserURL_DDE(sClass) {
WinGet, sServer, ProcessName, % "ahk_class " sClass
StringTrimRight, sServer, sServer, 4
iCodePage := A_IsUnicode ? 0x04B0 : 0x03EC ; 0x04B0 = CP_WINUNICODE, 0x03EC = CP_WINANSI
DllCall("DdeInitialize", "UPtrP", idInst, "Uint", 0, "Uint", 0, "Uint", 0)
hServer := DllCall("DdeCreateStringHandle", "UPtr", idInst, "Str", sServer, "int", iCodePage)
hTopic := DllCall("DdeCreateStringHandle", "UPtr", idInst, "Str", "WWW_GetWindowInfo", "int", iCodePage)
hItem := DllCall("DdeCreateStringHandle", "UPtr", idInst, "Str", "0xFFFFFFFF", "int", iCodePage)
hConv := DllCall("DdeConnect", "UPtr", idInst, "UPtr", hServer, "UPtr", hTopic, "Uint", 0)
hData := DllCall("DdeClientTransaction", "Uint", 0, "Uint", 0, "UPtr", hConv, "UPtr", hItem, "UInt", 1, "Uint", 0x20B0, "Uint", 10000, "UPtrP", nResult) ; 0x20B0 = XTYP_REQUEST, 10000 = 10s timeout
sData := DllCall("DdeAccessData", "Uint", hData, "Uint", 0, "Str")
DllCall("DdeFreeStringHandle", "UPtr", idInst, "UPtr", hServer)
DllCall("DdeFreeStringHandle", "UPtr", idInst, "UPtr", hTopic)
DllCall("DdeFreeStringHandle", "UPtr", idInst, "UPtr", hItem)
DllCall("DdeUnaccessData", "UPtr", hData)
DllCall("DdeFreeDataHandle", "UPtr", hData)
DllCall("DdeDisconnect", "UPtr", hConv)
DllCall("DdeUninitialize", "UPtr", idInst)
csvWindowInfo := StrGet(&sData, "CP0")
StringSplit, sWindowInfo, csvWindowInfo, `" ;"; comment to avoid a syntax highlighting issue in autohotkey.com/boards
Return sWindowInfo2
}


GetBrowserURL_ACC(sClass) {
global nWindow, accAddressBar
If (nWindow != WinExist("ahk_class " sClass)) ; reuses accAddressBar if it's the same window
{
nWindow := WinExist("ahk_class " sClass)
accAddressBar := GetAddressBar(Acc_ObjectFromWindow(nWindow))
}
Try sURL := accAddressBar.accValue(0)
If (sURL == "") {
WinGet, nWindows, List, % "ahk_class " sClass ; In case of a nested browser window as in the old CoolNovo (TO DO: check if still needed)
If (nWindows > 1) {
accAddressBar := GetAddressBar(Acc_ObjectFromWindow(nWindows2))
Try sURL := accAddressBar.accValue(0)
}
}
If ((sURL != "") and (SubStr(sURL, 1, 4) != "http")) ; Modern browsers omit "http://"
sURL := "http://" sURL
If (sURL == "")
nWindow := -1 ; Don't remember the window if there is no URL
Return sURL
}


IsURL(sURL) {
Return RegExMatch(sURL, "^(?<Protocol>https?|ftp)://(?<Domain>(?:[\w-]+\.)+\w\w+)(?::(?<Port>\d+))?/?(?<Path>(?:[^:/?# ]*/?)+)(?:\?(?<Query>[^#]+)?)?(?:\#(?<Hash>.+)?)?$")
}



Acc_Init()
{
static h
If Not h
h:=DllCall("LoadLibrary","Str","oleacc","Ptr")
}
Acc_ObjectFromWindow(hWnd, idObject = 0)
{
Acc_Init()
If DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0
Return ComObjEnwrap(9,pacc,1)
}
Acc_Query(Acc) {
Try Return ComObj(9, ComObjQuery(Acc,"{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1)
}
Acc_Children(Acc) {
If ComObjType(Acc,"Name") != "IAccessible"
ErrorLevel := "Invalid IAccessible Object"
Else {
Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
If DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 {
Loop %cChildren%
i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=9?Acc_Query(child):child), NumGet(varChildren,i-8)=9?ObjRelease(child):
Return Children.MaxIndex()?Children:
} Else
ErrorLevel := "AccessibleChildren DllCall Failed"
}
}

;~ end of real programming
;~ How to extract url from a webpage?
;~ Source for the real programming I just added what I needed.
;~ viewtopic.php?f=63&t=92161&p=430924&hilit=atnbueno+current+tab#p429201



zeropage:
winget, ActiveID, ID, A
WinActivate, ahk_exe firefox.exe
send, 0
WinActivate, ahk_id %ActiveId%
return




/*

To rewrite this script to send either an email or a text message using AHK_Class, you can use the following approach:

Modify the clipw function to accept a parameter indicating the type of message to send (email or text).
In the clipw function, check the value of this parameter.
If the parameter is "email", use AHK_Class to open an email client (such as Outlook) and send the message.
If the parameter is "text", use AHK_Class to open a text messaging app (such as Android Messages) and send the message.

Here is an example of how the modified clipw function might look:

clipw(msgType){
global
clipboardold = %clipboard%

clipboard =
sleep 500
clipboard :=
sleep 500

clipboard = %stline%
ClipWait, 1

if (msgType = "email") {
; Open an email client and send the message
; Replace "Outlook" with the AHK_Class of your email client
WinGet, id, ID, Outlook
WinActivate, ahk_id %id%
sendinput ^n
sleep 500
sendinput ^v
sleep 500
sendinput {enter}
}
else if (msgType = "text") {
; Open a text messaging app and send the message
; Replace "Android Messages" with the AHK_Class of your text messaging app
WinGet, id, ID, Android Messages
WinActivate, ahk_id %id%
sendinput ^v
sleep 500
sendinput {enter}
}

clipboard = %clipboardold%
}

To call this modified clipw function to send an email, you can use the following code:

clipw("email")

To call the function to send a text message, you can use the following code:

clipw("text")

*/

::mesmes::
MsgBox %sURL%
return

::workdir::
MsgBox, %A_Workingdir%
Return


::scriptdir.::
MsgBox %A_ScriptDir%
return

::surl.::
SendInput, %sURL%
return

::sendlink::
sendinput %sURL%
Return

::wd.::
MsgBox, %a_workingdir%
return
::wgclass::
WinGetClass, class, A
MsgBox, The active window's class is "%class%".
Return



^!e:: ;sends webpage title
;~ mtclient()

mtrun(){
global
SetKeyDelay 11755,11755,11755
FileDelete, %A_scriptdir%\runll.txt
sleep 1000
nTime := A_TickCount
sURL := GetActiveBrowserURL()
fileappend,`:`:`:`:`n, %A_scriptdir%\runll.txt
sleep 1000
fileappend, run`, %sURL%`n, %A_scriptdir%\runll.txt
;~ fileappend, run, %sURL%`n, %A_scriptdir%\runll.txt
sleep 1000
FileAppend return`n,%A_scriptdir%\runll.txt
Sleep 1000
RunWait, %sciahk% %A_scriptdir%\runll.txt
FileRead, newpost, %A_WorkingDir%\runll.txt
;MsgBox, %newpost%
StringReplace, %newpost%, %newpost%, `n, , All
;MsgBox, %newpost%
Run, %sciahk% %A_WorkingDir%\runll.txt
sleep 100

setKeyDelay -1, -1, -1
;~ SendInput, return
}
return

^#k:: ;sends webpage title and link only
mtfriend(){
;~ email config for shareable document
global
nTime := A_TickCount
sURL := GetActiveBrowserURL()
MsgBox %sURL%
WinGetTitle, title, A
WinGetClass, sClass, A
gosub reglink
run, mailto:%getemailadd%?subject=%title%&Body=%title% `%0A%sURL%
}
Return


::getlink:: ;This gets the current browser link
nTime := A_TickCount
sURL := GetActiveBrowserURL()
MsgBox %sURL%

return

reglink:
;~ MsgBox Reglink
ClipWait, 2 ;: This command waits for 2 seconds for the clipboard to contain data.

SetKeyDelay 100,100 ;: This command sets the delay between keystrokes to 100 milliseconds.

;~ clipboard = %title% ;: This line sets the clipboard to the value of the title variable.




sURL := RegExReplace(title,"\%","`%") ; This line uses the RegExReplace` function to search for the character "%" in the title and replace it with a literal "%" character.

;~ scbody := RegExReplace(scbody, "``r", "`r`n")
;~ ClipWait, 1


title := StringReplace,title,title, "x97",, All
;~ title := RegExReplace(title,"x97","")
;~ title := RegExReplace(title,"x97","") ; This line uses the RegExReplace function to search for the string "x97" in the title and replace it with an empty string.
MsgBox Remove X97 %title%

title := RegExReplace(title,"^\(\d+\)\s*","")
title := RegExReplace(title,"Mozilla Firefox","") ; This line uses the RegExReplace function to search for the string "� Mozilla Firefox" in the title and replace it with an empty string.


title := RegExReplace(title, "^\(\)\s", "") ; remove () at the beginning of a line
;~ MsgBox %title%
title := RegExReplace(title, "^\d+\s{1}", "") ; remove any number at the beginning of a line
;~ MsgBox %title%
;~ title := RegExReplace(title, "[(0-9)]")
;~ MsgBox %title%

title := RegExReplace(title,"׀","") ;This line uses the RegExReplacefunction to search for the pattern "stline= (([0-9)]))" in the title and replace it with "stline =". The RegExReplace function uses regular expressions to perform the search and replace.
;~ MsgBox %title%

title := RegExReplace(title,"stline = (([0-9)]))","stline =") ;This line uses the RegExReplacefunction to search for the pattern "stline= (([0-9)]))" in the title and replace it with "stline =". The RegExReplace function uses regular expressions to perform the search and replace.
;~ MsgBox %title%
title := RegExReplace(title,"&","and") ; This line uses the RegExReplace function to search for the character "&" in the title and replace it with "and".
;~ MsgBox %title%

;~ MsgBox %title%
title := RegExReplace(title,"YouTube","") ; This line uses the RegExReplace function to search for the string "YouTube" in the title and replace it with an empty string.
;~ MsgBox %title%
title := RegExReplace(title,"�","") ; This line uses the RegExReplace function to search for the character "�" in the title and replace it with an empty string.
;~ MsgBox %title%
title := RegExReplace(title,"�","") ; This line uses the RegExReplace function to search for the string "� Mozilla Firefox" in the title and replace it with an empty string.

title := RegExReplace(title,"Google","") ; This line uses the RegExReplace function to search for the string "Google" in the title and replace it with an empty string.
;~ MsgBox %title%

title := RegExReplace(title,"-.+YouTube","") ; This line uses the RegExReplace function to search for the pattern "-.+YouTube.+�" in the title and replace it with an empty string.
;~ MsgBox %title%
title := RegExReplace(title,"-.+YouTube","") ; This line uses the RegExReplace function to search for the pattern "-.+YouTube.+�" in the title and replace it with an empty string.
;~ MsgBox %title%
title := RegExReplace(title,"Chrome","") ; This line uses the RegExReplace function to search for the string "Chrome" in the title and replace it with an empty string.

;~title := RegExReplace(title,"^()","")

title := RegExReplace(title,"�","") ; x96
;~ MsgBox %title%

title := RegExReplace(title,"�","") ; x97
;~ MsgBox %title%
title := RegExReplace(title,"�","") ; x92
;~ MsgBox %title%
title := RegExReplace(title,"YouTube","") ; This line uses the RegExReplace function to search for the string "Chrome" in the title and replace it with an empty string.
return









::clipdirty::

MsgBox Before %clipboard%
clipboard:= RegExReplace(clipboard, "%", "``%")
MsgBox Clip Clean After %clipboard%
scbody := RegExReplace(scbody, "``r", "`r`n")
scbody := clipboard
MsgBox %scbody%
return

::nsp::
sendinput ```%0A
return


::^+!u::
nTime := A_TickCount
sURL := GetActiveBrowserURL()
WinGetClass, sClass, A
If (sURL != "")
MsgBox, % "The URL is """ sURL """`nEllapsed time: " (A_TickCount - nTime) " ms (" sClass ")"
Else If sClass In % ModernBrowsers "," LegacyBrowsers
MsgBox, % "The URL couldn't be determined (" sClass ")"
Else
MsgBox, % "Not a browser or browser not supported (" sClass ")"
Return

/*
; Create an Outlook application object
Outlook := ComObjCreate("Outlook.Application")

; Create a new email
Mail := Outlook.CreateItem(0) ; 0 represents olMailItem

; Set the email subject and body
Mail.Subject := %title%
Mail.Body := %scname% `r%scbody%

; Add recipient (To) - Change to your recipient's email address
Mail.Recipients.Add("ahkupdate@outlook.com")

; Send the email
Mail.Send()

; Release COM objects
Mail := ""
Outlook := ""

; Wait for the email to be sent (adjust as needed)

;~ FileAppend,
;~ (
;~ :`:%scname%`:`:
;~ `~%DateTimeString% %pcom%
;~ nstline =
;~ `n
;~ `n%title%
;~ `n%sURL%
;~ `n
;~ `r%scbody%
;~ `n
;~ `n
;~ `nclipw(``)
;~ `nreturn
;~ `:`:%scname%r.`:`:
;~ `nrun %sURL%
;~ `nreturn

;~ ), %A_ScriptDir%\bbb-1-shareable-docs.ahk

;~ SetKeyDelay -1, -1, -1
;~ Sleep 1500

; Reload or execute any other necessary commands here

; Close Outlook
Process, Close, outlook.exe

Exit
*/

gregster
Posts: 9096
Joined: 30 Sep 2013, 06:48

Re: Obtaining Current Webpage Link, Title and Add Text

Post by gregster » 13 Jan 2024, 11:09

@smogmanus,
I moved your topic to the AHK v1 'Scripts and Functions' subforum since this is not v2 code. Please note the separate forums for AHK v1 and v2 (now the main release) and choose the appropriate subforum, in the future.

Please add code (or codebox) tags around the script(s) you have posted above. Thank you!
Edit: I see that we talked about this before: compare viewtopic.php?f=76&t=114070&p=509219#p509220

gya
Posts: 25
Joined: 04 Nov 2021, 01:22

Re: Obtaining Current Webpage Link, Title and Add Text

Post by gya » 14 Jan 2024, 06:53

@smogmanus,

Hello,

Maybe these links will help you:
Hotstrings.ahk, application for learning / managing of hotstrings - AutoHotkey Community @ viewtopic.php?t=82352
Multi-line version of Hotstring Helper - AutoHotkey Community @ viewtopic.php?f=6&t=114688
GUI that shows multiple columns of multiple clickable items - AutoHotkey Community @ viewtopic.php?f=76&t=108769

Best regards.

Post Reply

Return to “Scripts and Functions (v1)”