email link in list view

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sbrady19
Posts: 337
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

email link in list view

14 Aug 2018, 09:08

is it possible to have an email address in a list view be a link so clicking the email address (which might be blue) would open in Outlook and put that email address in the "TO" line. I have code that reads a text file and put the first and last name in column 1, the phone number in column 2. Wondering if I can get the email to be a clickable link. Is this even possible.
Guest

Re: email link in list view

14 Aug 2018, 10:42

Not that I know of directly but

1) simply grab the row you clicked, get the contents of the first cell and if it contains a @ simply run mailt:%contents-of-cell% should work

2) if you don't need the listview as such you can create a html table with proper a href mailto: links, you can show that html page in a AutoHotkey https://autohotkey.com/docs/commands/Gu ... tm#ActiveX control

[ 3) If there isn't too much data and you just want something to click https://autohotkey.com/docs/commands/Gu ... s.htm#Link might be enough (if you have many rows this is not a useful option) ]
garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: email link in list view

14 Aug 2018, 10:51

a basic listview , works for me with thunderbird
EDIT : modified to 3 columns

Code: Select all

;- Listview example with 3 columns, 3-rd column is hidden
#warn
#NoEnv
SetWorkingDir, %A_ScriptDir%

gosub,createTestfile
;fileread,aac,%f1%
;FileRead,aac,  *P1252  %f1% ;-read as ANSI (CP-1252)
FileRead,aac,  *P65001 %f1% ;-read as UTF-8
;FileRead,aac, *P1200  %f1% ;-read as UTF-16 LE

Gui,1:Font,S13 CDefault,Lucida Console
Gui,1:Show,x0 y0 w570 h230,Test

Gui,1:Add, ListView,backgroundteal csilver grid x10 y0 h200 w550 +hscroll altsubmit gLW1 vLV1a, Name|Phone|Email
LV_ModifyCol(1,220)
LV_ModifyCol(2,320)
LV_ModifyCol(3,0)


Loop,parse,aac,`n,`r
{
x:=a_loopfield
if x=
  continue
  B1=
  B2=
  B3=
  stringsplit,b,x,;,
  LV_Add("",b1,b2,b3)
}
return
Guiclose:
exitapp

Lw1:
Gui,Submit,nohide
Gui,ListView, LV1a
  LV_GetText(C1,A_EventInfo,1)
  LV_GetText(C2,A_EventInfo,2)
  LV_GetText(C3,A_EventInfo,3)
  RN:=LV_GetNext("C")
  RF:=LV_GetNext("F")
  GC:=LV_GetCount()
if (rn=0)
  return
 
if A_GuiEvent = Doubleclick
  {
  if c3 contains @
    {
    DATES=%A_DD%-%A_MM%-%A_YYYY%
    stringsplit,CX,C3,`@,
    run,mailto:%C3%?subject=Message Titel %DATES%&Body=Hallo %CX1%`%0a`%0dHow are you ?`%0AI send you this message now....`%0ANext line...
    }
  }
return

createtestfile:
f1=%A_scriptdir%\test2.txt
ifnotexist,%f1%
{
e4x=
(ltrim join`r`n
Chris Myer;+44-22-7654320;[email protected]
Garry Scott;+41-33-7654321;[email protected]
)
fileappend,%e4x%,%f1%,UTF-8
}
return

Last edited by garry on 14 Aug 2018, 12:45, edited 1 time in total.
sbrady19
Posts: 337
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

Re: email link in list view

14 Aug 2018, 12:25

garry. Nice, I pasted into .ahk file and ran it, I clicked on your email and it opened right up in my Outlook.
I think I have found what I am need and am looking for. Thank you very very much.
sbrady19
Posts: 337
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

Re: email link in list view

14 Aug 2018, 12:27

my list view has 3 colums. The 3rd column is where the email is. I'll try to tweak your code to work for me.
sbrady19
Posts: 337
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

Re: email link in list view

14 Aug 2018, 12:41

cant figure out what do to with your code but here is mine.
I just want to double click a row and get the email and make new email.
my app is preset to have BRAD in the text box......just click get number and shawn brady will pop into the list view

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance force




;;;;;;;;;;;;;;;;;;;;;;;; GUI creation
Gui 1: Add, Tab2,w400 h300, Phonebook | Blank |  
Gui 1: Add, edit, w213 h20, brad
Gui 1: Add, Button, w120 h20, Get Number
Gui 1: Add, Button, w120 h20, Open Phonebook
Gui, Add, Listview, r8 gDBLClick w230, Name|Phone|email
Gui, MyGui3: Font, s70
Gui, MyGui3: Add, Text,vDisplayText x10 y10 w1200 ,FILLER    ;needed to specify width 1200 or it is too small and only the first word is displayed


; need 6 controls for phonebook
Gui, Tab, 2
;Gui 1: Add, edit, w250 h20, Asia224 BonBon's New Lip
;Gui 1: Add, Text,, Please enter your name:
;Gui 1: Add, Button, w100 h20, Button1


Gui 1: Show, x700 y120 h300 w300,
GUI, submit, nohide  
return
;;;;;;;;;;;;;;;;;;;;;;;;;; END GUI creation




;1/3
;;;;;;;;;;;;;;;;;;;; OPEN PHONEBOOK BUTTON
buttonopenphonebook:
run, %A_Desktop%\cbn phonebook.txt
SetTitleMatchMode, 2
WinWait,cbn phonebook.txt - Notepad,, 2,
WinGetActiveTitle, Title
WinMove,%Title%,   , 30,  30, 600, 900
return
;;;;;;;;;;;;;;;;;;;; END OPEN PHONEBOOK BUTTON





;2/3
;;;;;;;;;;;;;;;;;;;;;; make GUI3, put double clicked row in GUI
DBLClick:
if(a_guiEvent =="DoubleClick")
{
	;per the list view webpage 
	note := 
	RowNumber = 0     ;This causes the first loop iteration to start the search at the top of the list.
	Loop
	{
	    RowNumber := LV_GetNext(RowNumber)     ;Resume the search at the row after that found by the previous iteration.
	    if not RowNumber     ;The above returned zero, so there are no more selected rows.
	        break
		columns := LV_GetCount("Column")
		note := 
		loop %columns%
		{
			LV_GetText(Text, RowNumber, A_index)
			note .= Text . A_tab
		}
		stringtrimright note ,note,1			    
	    ;MsgBox %note%  ;;;;;NOTE ALWAYS RETURNS [first last][number][email]
	}


;;;;;;;;;;; code shawn added to display a GUI with a text string
Gui, MyGui3: Show,  h180  w1200
guiControl, MyGui3:,DisplayText, %note%
;Gui, MyGui3: submit, nohide
;Gui, MyGui3: Font, s70
;Gui, MyGui3: Add, Text, x40 y60 , %note%
note :=  
MyGui3Close:
MyGui3Escape:
;;;;;;;;;;;END code shawn added to diaplay a GUI with a text string


}
return
;;;;;;;;;;;;;;;;;;;;;; END make GUI3, put double clicked row in GUI




;3/3   set edit2 correctly
;;;;;;;;;;;;;;;;;; Get Number button
buttongetnumber:
IfNotExist, C:\Users\%A_UserName%\Desktop\CBN phonebook.txt
{
;FileCreateDir,  C:\Users\%A_UserName%\Desktop\CBN phonebook.txt
FileAppend ,Abe Moran 2714`nAimee Bruss 2339`nAlesia Hill 2243`nAmelia Achee 2326`nAmy Reid 2110`nAndrew Knox 2286`nAngel Vasko 2190`nAshley Andrews 2130`n`nBen Andrus 2305`nBob Womack 2603`nBobby Gross 3104`nBonnie Lovelace 2632`n`nCaitlyn Burke 2198`nCaleb Wood 2164`nCBN Badge 5037`nCBN Bldg_Serv 3077`nCBN Decal 5066`nCBN IT 3150`nCBN Police 5073`nCBN Weather 5555`nChris Woodland 2209`nChristy Biswell 2214`n`nDan Reany 2228`nDave Kithcart 2176`nDawn Goeb 2424`nDC Decastro 3910`nDean Zawaki 2436`nDemetria Stallings 2233`nDennis Sublett 2437`nDerrick Beacham 2414`nDolores Rivera 2757`nDory Nissen 2121`nDrew Newman 2273`nDrew Parkhill 2174`n`nEd Heath 2225`nErica Linney 2027`nEric Luehrs 2514`nEstella Torres 2263`n`nFancir Sanchez 2324`n`nGail Casteen 2122`nGarrett Rockey 2552`nGeorge Thomas 2189`nGeorgette Knuckles 2272`n`nHeather Boland 2185`nHeather Sells 2261`n`nJackson Harris 2419`nJamie Flora 2435`nJarrod Anderson 2296`nJenniffer Milo 2701`nJessica Dodson 2207`nJohn Reddel 2118`nJohn Sanderl 2516`nJulie Blim 2124`nJustin Carter 2473`n`nKara Roberts 2221`nKashmir Balistreri 2173`nKen Hulme 2282`n`nLigia Lee 2160`nLionel Harris 2187`nLori Stewart 2102`n`nMark Rincavage 2540`nMark Teixeria 2123`nMatt Vilkas 2067`nMatthew Gonzales 2303`nMichelle Wilson 2163`nMimi Elliott 2191`n`nNathan Banister 2439`n`nPete Bustetter 2028`nPhil Peters 2065`nPreston Cobbs 2631`n`nRandy Field 2518`nRebekah Kemp 2308`nRick Hall 2551`nRockey Delauria 2435`nRyan Davidson 2203`n`nShannah Phillips 2433`nShawn Brady 2558 [email protected]`nShawn Brown 2116`nSherry Armbrister 2120`nSkip Bowman 2621`nSuzanne O'Keefe 2168`n`nTerry Denton 2134`nTerry Strouss 2544`nTim Branson 2156`n`nVideo Tape 2505`n`nWes Rickards 2375`nWilliam Ellison 2436`nWil Dawson 2269`n`nZsaZsa Palagi 2069, C:\Users\%A_UserName%\Desktop\CBN phonebook.txt
}
sleep 500


LV_Delete()
the_list = 

controlgettext, UserInput, edit1

the_loop_number = 1
Loop, read, C:\Users\%A_UserName%\Desktop\CBN phonebook.txt
{

	IfInString, A_LoopReadLine, %UserInput%
        {
	the_list = %the_list%`r`n%A_LoopReadLine%  ;the return does not work, the next person is the next character NOT the next LINE
	StringSplit, word, A_LoopReadLine , %A_Space%
	LV_ADD("",word1 " " word2, word3,word4)
	LV_ModifyCol()  ; Auto-size each column to fit its contents.
        }

}

return
;;;;;;;;;;;;;;;;;; END 3/3 Get Number button





;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ButtonButton1:
;ControlGetText, OutputVar , edit1 ; Control name shown by WindowSpy
;MsgBox %OutputVar%

Gui, 2: Add, Tab2,  w400 h300 ,
Gui, 2: Show, x900 y150 h300 w300,
Gui, 2: Add, Text,, Please enter your name:
;gui, font, s40, Verdana 

return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;






garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: email link in list view

14 Aug 2018, 12:48

script above , just modified to 3 columns

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Google [Bot], hiahkforum, jchestnut, mcd, Sem552 and 135 guests