1

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
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45

1 Answers1

0

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..

Community
  • 1
  • 1
errorseven
  • 2,672
  • 2
  • 14
  • 20
  • Thanks @Ahkcoder, InnerText doesn't work sadly, I already tried :( But your tips helped! I first solved the issue myself by using `StrinTrimLeft´ `StringTrimRight´ However your method is more straightforward. For putting the text at the end: Weirdly enough I just had to reboot the PC. Now it's working Another problem: Sadly I have noticed that the copied string into the subject field isn't always correct :: _protocol c16019 (Small letter C instead of capital C) , lSN (&02707° (**% instead of 1, ° instead of**), site é2902 (**é instead of 2**), requisition &02921403(**& instead of 1**)_ – Amir Oulad Haj Amar Jun 10 '15 at 09:19
  • It seems that AHK is using my special caracters (the caracters row below the F1-F12 keys) Why and how can I resolve this ? – Amir Oulad Haj Amar Jun 10 '15 at 09:19
  • That's another question and warrants another separate post. Generally when someone takes the time and posts an answer that is helpful, even if you solved it yourself, you mark it as answered or give them an up vote. – errorseven Jun 10 '15 at 18:51
  • I am really gratefull that you took the time to reply and even post a correct answer. I tried to thank you and mark my comment as resolved, but for some reason I am getting several "unknown" error received. I have notified the moderators and even asked them to delete a post of mine (absolutely stupid question, impossible to provide an answer).as I was unable to do it myself. I will try to post a snippet of the error I get when I try to delete/resolve a post or thank someone. – Amir Oulad Haj Amar Jun 10 '15 at 19:23
  • Oke, the unkown error doesn't pop anymore Just resolved the issue :) Upvote however requires reputation 15. But still thanks for thelp !! – Amir Oulad Haj Amar Jun 10 '15 at 19:29