Using Send & SendText delima

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Using Send & SendText delima

Post by gchichester » Wed Jan 11, 2017 3:50 pm

What would cause the first two Send commands to work but the last fail?
I have tried using Send & SendText with and without the {" "}
I tried used the Code Builder as well with the same results
I have verified Booking Number is not a variable
I'm currently running v14.03.7

Code: Select all

Send>{"OOLU DOC"}
Press Tab * 2
EndIf
Wait>.75
Send>{"Jwilk"}
Wait>.75
Press Tab
Wait>.75
SendText>Booking Number
And once again using

Code: Select all

 and 
does not work????
Thank you in advance for all your help
Gil

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Using Send & SendText delima

Post by mightycpa » Wed Jan 11, 2017 11:51 pm

Why are you sending curly braces at all? Is this a windows application?

Code: Select all

Send>{"OOLU DOC"}
Press Tab * 2
EndIf
Wait>.75
Send>{"Jwilk"}
Wait>.75
Press Tab
Wait>.75
SendText>Booking Number
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Using Send & SendText delima

Post by Marcus Tettmar » Thu Jan 12, 2017 12:52 pm

There's nothing in your code that does anything about focus. Maybe you've only provided a portion of the code, but there's nothing here that ensures the correct window is focused.

These are the things that would make Send "fail":

- The window you want to send to is not focused (in the foreground).
- The field you want to type into is not the focused (active) field.
- The window or field is not yet ready for input.
- You are trying to send text into a process running as admin but Macro Scheduler/your compiled macro is not running as admin (see this article).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Re: Using Send & SendText delima

Post by gchichester » Thu Jan 12, 2017 2:21 pm

The focused window is a Outlook New "Untitled Message", Sorry I failed to add that part of my code to the post.
I could tell the window had focus because the first Send>OOLU DOC worked correctly without
enclosing it with {" "} as well as the Send>JWilk
It failed on the third Send>Booking Number sending only Booking. So I thought that the spaces may be causing the issue
Which didn't make sense because the OOLU DOC send worked and it has a space.
That's when I added the {" "} to all 3, still had issue. I remembered about the IGNORESPACES variable added it with mixed results. So I've worked around the issue by creating variables for each Send>

Now something is preventing the Press Tab * x from working throughout the code
Please see commented code

Complete Code
[code]//Open Outlook/Send Message
Let>IGNORESPACES=2
Let>GSC=gchichester
Let>JJW=Jwilk
Let>SLCode=MOLU
Let>CMA=CMDU DOC
Let>Ever=EGLV DOC
Let>MOL=MOLU DOCUMENTATION
Let>OOCL=OOLU DOC
Let>BK#=Booking Number
Let>BkNum=2582588044

RunProgram>C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE
Wait>2
UIClick>{"Inbox - Wilk Office - Microsoft Outlook"},{"New E-mail"}
Wait>.50
SetFocus>Untitled - Message*

//Get Shipline email address
Wait>.75
If>%SLCode%=CMDU
Send>%CMA%
Press Tab * 3
Endif

If>%SLCode%=EGLV
Send>%Ever%
Press Tab * 3
EndIf

If>%SLCode%=MOLU
Send>%MOL%
Wait>1
Press Tab * 3
EndIf

If>%SLCode%=OOLU
Send>%OOCL%
Wait>1
Press Tab * 3
EndIf

// For some reason these two send end up in the same Bcc... field of the Outlook new message window
//It's like the Press Tab is being ignored

Wait>1
Send>%JJW%
Wait>1
Press Tab
Wait>1
Send>%BK#% %BkNum%
//

Wait>.75
UIClick>{"Untitled - Message*"},{"Check Names"}
Wait>.75
UIClick>{"Untitled - Message (HTML) "},{"Attach File"}
Wait>.75
Send>{"C:\BOLs\%BKNum%.pdf"}
Wait>.75
UIClick>{"Insert File"},{"Insert"}
Wait>1

**BREAKPOINT**
//Click Send
//UIClick>{"Untitled - Message (HTML) "},{"Send"}[/code]
Thank you in advance for all your help
Gil

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: Using Send & SendText delima

Post by CyberCitizen » Thu Jan 12, 2017 11:59 pm

I have found with some applications that the tabs two quick don't help so try
Press Tab
Wait>0.2
Press Tab
Wait>0.2
Press Tab
Wait>0.2
FIREFIGHTER

gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Re: Using Send & SendText delima

Post by gchichester » Fri Jan 13, 2017 12:06 am

Thanks for the thought!
If I understand the wait> command I think 0.75 is 3/4 of a second and is longer than 0.2 of a second.
And some are waiting for a full second, and I have even tried 2 and 3 seconds
Thank you in advance for all your help
Gil

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: Using Send & SendText delima

Post by CyberCitizen » Fri Jan 13, 2017 1:29 am

I have just edited a script that will email within Outlook with attachment is there a reason your doing it this way, could you not just have outlook open and it send the email on your behalf?
FIREFIGHTER

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: Using Send & SendText delima

Post by CyberCitizen » Fri Jan 13, 2017 1:35 am

Here is the code I am using, will send to the email address with attachment etc. Outlook needs to be running, but that is it.
Now I am referencing the attachment path etc, however you could have it as an input method.

Code: Select all

Let>[email protected]
Let>vJobNum=123321
Let>vSeqNum=123456789

SRT>sEmail
VBStart
Function CreateEmail(strRecipient, strSubject, strBody, strAttachment)
   'Create OL App object
   Set objOLApp = CreateObject("Outlook.Application")
   If objOLApp is nothing then
      MsgBox "Could not create OL App.  Shutting Down"
      Exit Function
   End If

   'Create a new mail item
   Set objMsg = objOLApp.CreateItem(0)
   If objMsg is nothing then
      MsgBox "Could not create Mail Item.  Shutting Down"
      Exit Function
   End If
   'Set basic message parameters
   objMsg.To = strRecipient
   objMsg.Subject = strSubject
   objMsg.Body = strBody
   objMsg.Attachments.Add(strAttachment)
   'Send the message
   objMsg.Send

   'Free up the space
   Set objOLApp = Nothing
   Set objMsg = Nothing

   CreateEmail = "Success"
End Function
VBEnd

Let>strTo=%vEmailNum%
Let>strSubj=Call: %vJobNum% - Sequence: %vSeqNum% - Dial Before You Dig Request
Let>strBody=Call: %vJobNum%%CRLF%Sequence: %vSeqNum%%CRLF%%CRLF%Good morning,%CRLF%%CRLF%Please find attached the requested Dial Before You Dig info.
Let>strAttach=N:\Information Management\ICT INF & OPS\_DBYD\%vJobNum%.pdf

StringReplace>strBody,CRLF," & vbCRLF & ",strBody

VBEval>CreateEmail("%strTo%","%strSubj%","%strBody%","%strAttach%"),Answer
END>sEmail
FIREFIGHTER

gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Re: Using Send & SendText delima

Post by gchichester » Sat Jan 14, 2017 2:18 pm

Thank You
Just what I needed, I had forgotten about using VB within MS much more efficient.
Thank you in advance for all your help
Gil

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts