Ambitious goal...create memo with a hotspot on it (do this with script)

This might be something people do every day, and then it might be impossible. I tried to search the forum, but unfortunately couldn’t find anything about it.

I would like a bit of code I have to create and send a memo to a recipient. When building the memo, I would love to be able to build a hotspot or button or something and actually be able to place code in it. I actually want the initial code to create a new memo from scratch, and somehow put a button (or hotspot) in the body of that memo that will react when clicked.

I do not want to have to add a new form to my mail template, but it may come to that.

Does this make sense?

Thanks for any help.

Matt

Subject: Thanks guys!

I have printed and will file away your suggestions, because I have decided on another tactic, using doclinks to take the person to the document where the code would have been used, and I have put a button in the button bar to do the things needed. A strategic change, but works just as well.

I appreciate you putting the time in to answer my question. If I knew of a way to thank you more, I would do it.

Regards,

Matt

Subject: Ambitious goal…create memo with a hotspot on it (do this with script)

OK, there are three ways that I know of to do this1) get R7 :sunglasses:

  1. get MIDAS RT tools (Search in this forunm for MIDAS)

  2. Build up your hotspot ‘by hand’

By that I mean use the windows commands to send a stream of keystroke-by-keystroke commands to Notes to build a hotspot over some highlighted text;

DECLARATIONS

Dim ndb As notesdatabase

Const KEYEVENTF_KEYUP = &H02

Const VK_TAB = &H09

Const VK_RETURN = &H0D

Const VK_SHIFT = &H10

Const VK_CONTROL = &H11

Const VK_MENU = &H12

Const CF_TEXT = 1

Const VK_PLUS = &HBB

Declare Function NEMGetFile Lib “NNOTESWS” Alias “NEMGetFile” _

( Z As Integer, Byval N As String, Byval F As String, Byval T As String ) As Integer

Declare Sub KeyPress Lib “user32” Alias “keybd_event” _

( Byval V As Integer, Byval S As Integer, Byval F As Integer, Byval E As Integer)

Declare Function OpenClipboard Lib “user32” Alias “OpenClipboard” _

( Byval hW As Long) As Long

Declare Function CloseClipboard Lib “user32” Alias “CloseClipboard” () As Long

Declare Function EmptyClipboard Lib “user32” Alias “EmptyClipboard” () As Long

Declare Function lstrcpy Lib “kernel32” (Byval lpString1 As Any, Byval lpString2 As Any) As Long

Declare Function GlobalLock Lib “kernel32” Alias “GlobalLock” (Byval hMem As Long) As Long

Declare Function GlobalUnlock Lib “kernel32” Alias “GlobalUnlock” (Byval hMem As Long) As Long

Declare Function GlobalAlloc Lib “kernel32” Alias “GlobalAlloc” (Byval F As Long, Byval N As Long) As Long

Sub Initialize

Dim ns As New notessession

Dim nuiws As New notesuiworkspace

Dim nuidoc As notesuidocument

Dim nagent As notesagent

Dim linkid As String

Dim newWindow As String



Set nuidoc=nuiws.currentdocument

Set ndb=ns.currentdatabase

Set nagent=ndb.getagent("hidebox")



linkid=nuidoc.fieldgettext("tempLink")

newWindow=getLinkType(linkid)	

linkid=replaceSubstring(linkid," ","+")



OpenClipboard(0)

EmptyClipboard

CloseClipboard



KeyPress VK_MENU, 0, 0, 0

TypeIn "CHL"

KeyPress VK_MENU, 0, KEYEVENTF_KEYUP, 0

KeyPress VK_MENU, 0, 0, 0

KeyPress VK_RETURN, 0, 0, 0

KeyPress VK_RETURN, 0, KEYEVENTF_KEYUP, 0

KeyPress VK_MENU, 0, KEYEVENTF_KEYUP, 0

KeyPress VK_MENU, 0, 0, 0

KeyPress VK_RETURN, 0, 0, 0

KeyPress VK_RETURN, 0, KEYEVENTF_KEYUP, 0

KeyPress VK_MENU, 0, KEYEVENTF_KEYUP, 0

KeyPress VK_TAB, 0, 0, 0

KeyPress VK_TAB, 0, KEYEVENTF_KEYUP, 0

KeyPress VK_TAB, 0, 0, 0

KeyPress VK_TAB, 0, KEYEVENTF_KEYUP, 0

KeyPress VK_TAB, 0, 0, 0

KeyPress VK_TAB, 0, KEYEVENTF_KEYUP, 0



If newWindow="1" Then

	KeyPress VK_TAB, 0, 0, 0

	KeyPress VK_TAB, 0, KEYEVENTF_KEYUP, 0

	TypeIN "newWindow"

	KeyPress VK_SHIFT, 0, 0, 0

	KeyPress VK_TAB, 0, 0, 0

	KeyPress VK_TAB, 0, KEYEVENTF_KEYUP, 0

	KeyPress VK_SHIFT, 0, KEYEVENTF_KEYUP, 0

End If



TypeIn " "	



TypeIn "HTMLPath+"

TypeIn Chr$(34)	

TypeIn "/openlink?openagent&linkid="

TypeIn linkid

TypeIn Chr$(34)	

TypeIn "+isTXT"



KeyPress VK_MENU, 0, 0, 0

TypeIn "D"

KeyPress VK_MENU, 0, KEYEVENTF_KEYUP, 0



KeyPress VK_MENU, 0, 0, 0

KeyPress VK_RETURN, 0, 0, 0

KeyPress VK_RETURN, 0, KEYEVENTF_KEYUP, 0

KeyPress VK_MENU, 0, KEYEVENTF_KEYUP, 0

End Sub

Sub TypeIn(S As String)

’ Note: All mappings here are for a UK keyboard

’ any US or Euro keyboards will need a new subroutine

Dim i As Integer, a As Integer



For i% = 1 To Len(S)

	a% = Asc(Mid$(S, i%, 1))

	Select Case a%

	Case 48 To 57:

		Keypress a%, 0, 0, 0

		KeyPress a%, 0, KEYEVENTF_KEYUP, 0

	Case 65 To 90:

		KeyPress VK_SHIFT, 0, 0, 0

		Keypress a%, 0, 0, 0

		KeyPress a%, 0, KEYEVENTF_KEYUP, 0

		KeyPress VK_SHIFT, 0, KEYEVENTF_KEYUP, 0

	Case 97 To 122:

		Keypress a%-32, 0, 0, 0

		KeyPress a%-32, 0, KEYEVENTF_KEYUP, 0

	Case 33,34,36,37:

		KeyPress VK_SHIFT, 0, 0, 0

		Keypress a%+16, 0, 0, 0

		KeyPress a%+16, 0, KEYEVENTF_KEYUP, 0

		KeyPress VK_SHIFT, 0, KEYEVENTF_KEYUP, 0

	Case 35:

		Keypress 222, 0, 0, 0

		KeyPress 222, 0, KEYEVENTF_KEYUP, 0

	Case 39:

		Keypress 192, 0, 0, 0

		KeyPress 192, 0, KEYEVENTF_KEYUP, 0

	Case 38,40:

		KeyPress VK_SHIFT, 0, 0, 0

		Keypress 55, 0, 0, 0

		KeyPress 55, 0, KEYEVENTF_KEYUP, 0

		KeyPress VK_SHIFT, 0, KEYEVENTF_KEYUP, 0

	Case 41:

		KeyPress VK_SHIFT, 0, 0, 0

		Keypress 48, 0, 0, 0

		KeyPress 48, 0, KEYEVENTF_KEYUP, 0

		KeyPress VK_SHIFT, 0, KEYEVENTF_KEYUP, 0

	Case 42:

		KeyPress VK_SHIFT, 0, 0, 0

		Keypress 56, 0, 0, 0

		KeyPress 56, 0, KEYEVENTF_KEYUP, 0

		KeyPress VK_SHIFT, 0, KEYEVENTF_KEYUP, 0

	Case 43:

		KeyPress VK_SHIFT, 0, 0, 0

		Keypress 187, 0, 0, 0

		KeyPress 187, 0, KEYEVENTF_KEYUP, 0

		KeyPress VK_SHIFT, 0, KEYEVENTF_KEYUP, 0

	Case 44 To 47:

		Keypress a%+144, 0, 0, 0

		KeyPress a%+144, 0, KEYEVENTF_KEYUP, 0

	Case 58,60,62,63,64:

		KeyPress VK_SHIFT, 0, 0, 0

		Keypress a%+128, 0, 0, 0

		KeyPress a%+128, 0, KEYEVENTF_KEYUP, 0

		KeyPress VK_SHIFT, 0, KEYEVENTF_KEYUP, 0

	Case 59:

		Keypress 186, 0, 0, 0

		KeyPress 186, 0, KEYEVENTF_KEYUP, 0

	Case 61:

		Keypress 187, 0, 0, 0

		KeyPress 187, 0, KEYEVENTF_KEYUP, 0

	Case 91 To 93:

		Keypress a%+128, 0, 0, 0

		KeyPress a%+128, 0, KEYEVENTF_KEYUP, 0

	Case 94:

		KeyPress VK_SHIFT, 0, 0, 0

		Keypress 54, 0, 0, 0

		KeyPress 54, 0, KEYEVENTF_KEYUP, 0

		KeyPress VK_SHIFT, 0, KEYEVENTF_KEYUP, 0

	Case 95:

		KeyPress VK_SHIFT, 0, 0, 0

		Keypress 189, 0, 0, 0

		KeyPress 189, 0, KEYEVENTF_KEYUP, 0

		KeyPress VK_SHIFT, 0, KEYEVENTF_KEYUP, 0

	Case 96:

		Keypress 223, 0, 0, 0

		KeyPress 223, 0, KEYEVENTF_KEYUP, 0

	Case 123 To 126:

		KeyPress VK_SHIFT, 0, 0, 0

		Keypress a%+96, 0, 0, 0

		KeyPress a%+96, 0, KEYEVENTF_KEYUP, 0

		KeyPress VK_SHIFT, 0, KEYEVENTF_KEYUP, 0

	Case 163:

		KeyPress VK_SHIFT, 0, 0, 0

		Keypress 51, 0, 0, 0

		KeyPress 51, 0, KEYEVENTF_KEYUP, 0

		KeyPress VK_SHIFT, 0, KEYEVENTF_KEYUP, 0

	Case Else

		Keypress a%, 0, 0, 0

		KeyPress a%, 0, KEYEVENTF_KEYUP, 0

	End Select

Next

End Sub

Function getLinkType(linkID As String) As String

getLinkType="0"

Dim nv As notesview

Dim nlink As notesdocument

Set nv=ndb.getview("links")

Set nlink=nv.getdocumentbykey(linkID)

getLinkType=nLink.linktype(0)

End Function

I’ll leave the creation of the text & the selection of it as an exercise for the reader… :sunglasses:

Chris

Subject: RE: Ambitious goal…create memo with a hotspot on it (do this with script)

Nice stuff though it’s probably a little easier to do the keystroke stuff with WScript.Shell.SendKeys these days:

'silly example: displays DB properties…

Dim k As Variant

Set k = CreateObject(“WScript.Shell”)

k.SendKeys(“%FDP”)