Auothotkey: Remove string, placement string in subject box

57 views Asked by At

Can somebody help me out, finding why my code doesn't work ?

My code:

    #b::
pwb := WBGet()
pTable:= pwb.document.GetElementsByTagName("Table") [4] ;outerHTML ;Set Tag name and Array value
Loop, % pTable.rows.length {
LSN:= pTable.rows[9] .GetElementsByTagName("TD") [1].outerHTML ; LSN
protocol:= pTable.rows[9] .GetElementsByTagName("TD") [3].outerHTML ; Protocol
Site:=pTable.rows[10] .GetElementsByTagName("TD") [1].outerHTML ; Site
Requisition:=pTable.rows[12] .GetElementsByTagName("TD") [3].outerHTML ; Requisition

subject= %protocol% , %LSN% , %site% , %Requisition%

;send the contents of subject into the subject of outlook
controlSend, RichEdit20WPT4, {end} , ahk_class rctrl_renwnd32 ;send to the end of the subject field
controlSendRaw, RichEdit20WPT4, %subject%, ahk_class rctrl_renwnd32  ; sent to the subject field
subject :=""  ; empty the variable after process completed
return
}  "

I want to send the variable subject= %protocol% , %LSN% , %site% , %requisition% to the the end of certain text in the subject field in my e-mail.

But I have 2 problems:

  1. I get the following in the subject field: <TD>SP005 VIABLE , 101999 , C277 , 103484490

How can I remove the TD ?

  1. I don't get the variable at the end of a certain text, but at the beginning of the text.

thus <TD>SP005 VIABLE , 101999 , C277 , 103484490 - Query discrepant info

Why ?

I thought that the following code would send the variable behind the certain text ?

controlSend, RichEdit20WPT4, {end} , ahk_class rctrl_renwnd32
1

There are 1 answers

5
errorseven On BEST ANSWER

Instead of:

LSN := pTable.rows[9].GetElementsByTagName("TD")[1].outerHTML

Try:

LSN := pTable.rows[9].GetElementsByTagName("TD")[1].innerText

Here's an explanation.

If that doesn't work you can try StringReplace:

StringReplace, LSN, LSN, <TD>,, ALL

As far as your code that is not sending your text to the End of you document try ControlFocus, ControlClick, and Sleep

;Set focus on Control
   controlFocus, RichEdit20WPT4, ahk_class rctrl_renwnd32 
;MouseClick on the Control, set the Caret! 
   controlClick, RichEdit20WPT4, ahk_class rctrl_renwnd32 
;Pause for a millisecond
   Sleep, 10 
;Move Caret to end of document!
   controlSend, RichEdit20WPT4, {end} , ahk_class rctrl_renwnd32 
   Sleep, 10

etc..