Macro Scheduler acting erractically

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
ibwalkn
Newbie
Posts: 6
Joined: Wed Sep 18, 2013 6:34 pm
Contact:

Macro Scheduler acting erractically

Post by ibwalkn » Tue Sep 24, 2013 8:26 pm

When I run a script, the first pass seems to be alright but the second pass of a subroutine doesn't seem to execute the same steps. I tried the basic code by just putting a srt and end around it and a couple of gosubs calling the subroutine and the first time, it worked, the second didn't appear to work. Using the Message> command, I saw the first pass ran but not the second. So, I tried to turn on logging and it doesn't seem to create a log file even though I specified it and said Log start and completion of each step. Is there something wrong with my install? This is on a Windows 7 laptop.

I have de-installed the program, removed the my documents/macro scheduler 14 directory, deleted the program files/macro scheduler directory, re-installed the software and see similar issues. I de-installed everything and installed the latest version from your web site with the same issue. I have narrowed one issue to WaitScreenText where instead of completing, a message pops up with the number 1 and nothing else. A bit later, a message pops up with the number 2. I cannot abort the macro and have to stop the Macro Scheduler application using the task manager. Even after a reboot, it still does the same thing. This is a macro that has run fine a few days ago. I'm about to try another laptop as this is delaying progress. I was hoping to be done with development and do integration of compiled macros on several laptops.

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Tue Sep 24, 2013 9:37 pm

Maybe you can post your code so we can help you figure out the problem?
Thanks,
Jerry

[email protected]

ibwalkn
Newbie
Posts: 6
Joined: Wed Sep 18, 2013 6:34 pm
Contact:

Code with comments where the popup occurs (WaitScreenText)

Post by ibwalkn » Tue Sep 24, 2013 10:46 pm

// COMPILE_OPTS|C:\Users\TMSTestAccount46\Documents\TestResults\Outlook W7 V4 2 Loops.exe||CONSOLE=0|INCLUDES=1||RUNTIMES=1|BMPS=1
//Initialise Variables

//Set number of tests
Let>NTests=2
//Set to proper email account
Let>Recepient=Wof Tmstestaccount47

GetTextInit

//Initial variables for first pass
Let>SFilename=OutlookTest
Let>FileLocation=%USERDOCUMENTS_DIR%\TestResults\
Let>Message=200KB Test Message
Let>MailFile=%FileLocation%A200KBFile
Let>Row=1
Let>Col=1
Let>TestNo=0

//Get the date and time and build a standard format filename
Hour>Hour
Min>Minute
Sec>Second
Month>Month
Day>Day
Year>Year
Let>DTime= (
ConCat>DTime,%Month%-%Day%-%Year% %Hour%.%Minute%.%Second%)

//If Outlook is open close it and run it to ensure that the Inbox is visible
IfWindowOpen>Inbox -*
WindowAction>3,Inbox -*
EndIf>
Wait>2
Run>C:\Program Files\Microsoft Office\Office14\Outlook.exe
WaitWindowOpen>Inbox -*
WindowAction>1,Inbox -*
SetFocus>Inbox -*

//Create the results spreadsheet
ChangeDirectory>FileLocation
XLCreate>%FileLocation%%SFilename%%DTime%.xls,1,xlBook

//Add Initial Tab and Cells
XLAddSheet>xlBook,Outlook 25MB file
XLSetCell>xlBook,Outlook 25MB file,1,1,Test Number,scResult
XLSetCell>xlBook,Outlook 25MB file,1,2,Time,scResult
XLAddSheet>xlBook,Outlook 5MB file
XLSetCell>xlBook,Outlook 5MB file,1,1,Test Number,scResult
XLSetCell>xlBook,Outlook 5MB file,1,2,Time,scResult
XLAddSheet>xlBook,Outlook 1MB file
XLSetCell>xlBook,Outlook 1MB file,1,1,Test Number,scResult
XLSetCell>xlBook,Outlook 1MB file,1,2,Time,scResult
XLAddSheet>xlBook,Outlook 200KB file
XLSetCell>xlBook,Outlook 200KB file,1,1,Test Number,scResult
XLSetCell>xlBook,Outlook 200KB file,1,2,Time,scResult


//
//Main Loop
//
Let>ExcelTab=Outlook 200KB file
Let>NumberOfTests=NTests
While>TestNoTestNo,1
Add>Row,1
Let>Col=1
XLSetCell>xlBook,%ExcelTab%,%Row%,%Col%,%TestNo%,scResult
Gosub>OutlookTest
EndWhile

//Setup variables for next file size
Let>ExcelTab=Outlook 1MB file
Let>Message=1MB Test Message
Let>MailFile=%FileLocation%A1MBFile
Let>Row=1
Let>Col=1
Let>TestNo=0
Let>NumberOfTests=NTests

While>TestNoTestNo,1
Add>Row,1
Let>Col=1
XLSetCell>xlBook,%ExcelTab%,%Row%,%Col%,%TestNo%,scResult
Gosub>OutlookTest
EndWhile

//Setup variables for next file size
Let>ExcelTab=Outlook 5MB file
Let>Message=5MB Test Message
Let>MailFile=%FileLocation%A5MBFile
Let>Row=1
Let>Col=1
Let>TestNo=0
Let>NumberOfTests=NTests

While>TestNoTestNo,1
Add>Row,1
Let>Col=1
XLSetCell>xlBook,%ExcelTab%,%Row%,%Col%,%TestNo%,scResult
Gosub>OutlookTest
EndWhile

//Setup variables for next file size
Let>ExcelTab=Outlook 25MB file
Let>Message=25MB Test Message
Let>MailFile=%FileLocation%A25MBFile
Let>Row=1
Let>Col=1
Let>TestNo=0
Let>NumberOfTests=NTests

While>TestNoTestNo,1
Add>Row,1
Let>Col=1
XLSetCell>xlBook,%ExcelTab%,%Row%,%Col%,%TestNo%,scResult
Gosub>OutlookTest
EndWhile

XLSave>xlBook,%FileLocation%%SFilename%%DTime%.xls
XLQuit>xlBook

MessageModal>Outlook test is complete. It ran %NTests% times for each file size. Results spreadsheet for this test is saved as %FileLocation%%SFilename%%DTime%.xls.
Exit>0

SRT>OutlookTest
// Outlook test Subroutine

//Run>C:\Program Files\Microsoft Office\Office14\Outlook.exe
WaitWindowOpen>Inbox -*
WindowAction>1,Inbox -*
SetFocus>Inbox -*

//Send a new email message
Press LCTRL
Send>n
Release LCTRL
WaitWindowOpen>Untitled -*
Send %Recepient%
Press Tab * 3
Send>%Message%
Press Tab
Send This is a %Message% body
//
Wait>3
//
Press LALT
Send>n
Release LALT
Send>af
WaitWindowOpen>Insert File*
WindowAction>1,Insert File*
wait 5
Send>%MailFile%
GetTime>StartTime

Press LALT
Send>s
Release LALT

SetFocus>%Message%*
Press LALT
Send>s
Release LALT
Wait>5

//Look for the email message
SetFocus>Inbox -*
//
//
//
// This is the point where I get the popup, it seems to happen right after
// the text is found on the screen page
//
//
WaitScreenText>%Message%
//
//
//
GetTime>EndTime
TimeDiff>StartTime,EndTime,S,TaskTime
//It seems to take a couple of seconds to find the text, adjust time for the task
Sub>TaskTime,2

//Delete the message
SetFocus>Inbox -*
GetTextPos>%Message%,X1,Y1,X2,Y2
Let>x={%X1%+((%X2%-%X1%) div 2)}
Let>y={%Y1%+((%Y2%-%Y1%) div 2)}
MouseMove>x,y
Wait>1
RClick
Wait>1
Send>d

//Log the message

//Display completion message
Let>MSG_STAYONTOP=1
Let>MSG_CENTERED=1
//MessageModal>Complete in %TaskTime% seconds

//Set Collumn to result Collumn
Add>Col,1

XLSetCell>xlBook,%ExcelTab%,%Row%,%Col%,%TaskTime%,scResult
//Let>WIN_USEHANDLE=1

End>OutlookTest

//FindWindowWithText>This is a test message,1,windowname

//GetWindowHandle>Inbox -*,hWnd
//FindObject>hWnd,This is a test message,,1,hWnd,X1,Y1,X2,Y2,result
//MouseMove>X1,Y1
//MouseMoveRel>10,10
//LClick
//Wait 5
//LClick

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Wed Sep 25, 2013 12:19 am

IBWalkn, your code got messed up at the While Loops.
Can you repost one of them (I am guessing the logic is similar for each of them).

2 hints to improve the odds of your code coming through cleanly...
1. Check the "Disable HTML in this post" check box below the comment window
2. Select the code you paste in and click the

Code: Select all

  button above the comment window.


[b]While>TestNoTestNo,1[/b]
Add>Row,1
Let>Col=1
XLSetCell>xlBook,%ExcelTab%,%Row%,%Col%,%TestNo%,scResult
Gosub>OutlookTest
EndWhile
Thanks,
Jerry

[email protected]

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Wed Sep 25, 2013 12:56 am

I am guessing the While Loop should be:

Code: Select all

While>TestNo<NumberOfTests
  Add>TestNo,1
  Add>Row,1
  Let>Col=1
  XLSetCell>xlBook,%ExcelTab%,%Row%,%Col%,%TestNo%,scResult
  Gosub>OutlookTest
EndWhile
When you are setting the file attachment name, you are not setting the file extension

Code: Select all

Let>MailFile=%FileLocation%A200KBFile

Should this be

Let>MailFile=%FileLocation%A200KBFile.xls

Where does this file come from. You aren't saving a file anywhere that I see?
Thanks,
Jerry

[email protected]

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

Post by Marcus Tettmar » Wed Sep 25, 2013 6:31 am

Logging doesn't happen when you are running under the debugger. For logging to work, close the editor and run from the main interface.

Under the debugger (in the editor) set some Breakpoints, e.g. Put one in the subroutine so you can see it get there. Then run or step through.
http://www.mjtnet.com/blog/2006/05/17/use-the-debugger/

The most common cause of things running inconsistently are timing and focus. Make sure there's enough time for things to complete. Slow it RIGHT down to begin with. Can always speed up later. This is mentioned here:
http://www.mjtnet.com/blog/2008/10/27/t ... le-macros/

Make sure you are running the most recent update. Check Help/Check for update.

If still stuck. Drop support a line and we can arrange a phone/screen share and help you debug it.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

ibwalkn
Newbie
Posts: 6
Joined: Wed Sep 18, 2013 6:34 pm
Contact:

I'll post the code in plain text this time.

Post by ibwalkn » Wed Sep 25, 2013 3:34 pm

The problem is code that has been working fine for a week suddenly is erratic. In the case of the code posted, when it hits the "WaitScreenText>%Message%", it seems to find the text as I'm watching it as the next thing happens just as it appears. But, what happens is, it pops up a message with the number, "1" in it and nothing else. Then it appears to do nothing else but pop up another message with the number, "2" in it and so on. It is necessary to kill Macro Scheduler from the task manager at that point. I have other examples of a script that has other erratic behaviour that didn't the day before.

To repeat, I have deinstalled the software, deleted directories, etc and reinstalled it with the same issue. I have even installed the software on another PC and see the same issue.

_______________________________________________________

// COMPILE_OPTS|C:\Users\TMSTestAccount46\Documents\TestResults\Outlook W7 V4 2 Loops.exe||CONSOLE=0|INCLUDES=1||RUNTIMES=1|BMPS=1
//Initialise Variables

//Set number of tests
Let>NTests=2
//Set to proper email account
Let>Recepient=Wof Tmstestaccount47

GetTextInit

//Initial variables for first pass
Let>SFilename=OutlookTest
Let>FileLocation=%USERDOCUMENTS_DIR%\TestResults\
Let>Message=200KB Test Message
Let>MailFile=%FileLocation%A200KBFile
Let>Row=1
Let>Col=1
Let>TestNo=0

//Get the date and time and build a standard format filename
Hour>Hour
Min>Minute
Sec>Second
Month>Month
Day>Day
Year>Year
Let>DTime= (
ConCat>DTime,%Month%-%Day%-%Year% %Hour%.%Minute%.%Second%)

//If Outlook is open close it and run it to ensure that the Inbox is visible
IfWindowOpen>Inbox -*
WindowAction>3,Inbox -*
EndIf>
Wait>2
Run>C:\Program Files\Microsoft Office\Office14\Outlook.exe
WaitWindowOpen>Inbox -*
WindowAction>1,Inbox -*
SetFocus>Inbox -*

//Create the results spreadsheet
ChangeDirectory>FileLocation
XLCreate>%FileLocation%%SFilename%%DTime%.xls,1,xlBook

//Add Initial Tab and Cells
XLAddSheet>xlBook,Outlook 25MB file
XLSetCell>xlBook,Outlook 25MB file,1,1,Test Number,scResult
XLSetCell>xlBook,Outlook 25MB file,1,2,Time,scResult
XLAddSheet>xlBook,Outlook 5MB file
XLSetCell>xlBook,Outlook 5MB file,1,1,Test Number,scResult
XLSetCell>xlBook,Outlook 5MB file,1,2,Time,scResult
XLAddSheet>xlBook,Outlook 1MB file
XLSetCell>xlBook,Outlook 1MB file,1,1,Test Number,scResult
XLSetCell>xlBook,Outlook 1MB file,1,2,Time,scResult
XLAddSheet>xlBook,Outlook 200KB file
XLSetCell>xlBook,Outlook 200KB file,1,1,Test Number,scResult
XLSetCell>xlBook,Outlook 200KB file,1,2,Time,scResult


//
//Main Loop
//
Let>ExcelTab=Outlook 200KB file
Let>NumberOfTests=NTests
While>TestNoTestNo,1
Add>Row,1
Let>Col=1
XLSetCell>xlBook,%ExcelTab%,%Row%,%Col%,%TestNo%,scResult
Gosub>OutlookTest
EndWhile

//Setup variables for next file size
Let>ExcelTab=Outlook 1MB file
Let>Message=1MB Test Message
Let>MailFile=%FileLocation%A1MBFile
Let>Row=1
Let>Col=1
Let>TestNo=0
Let>NumberOfTests=NTests

While>TestNoTestNo,1
Add>Row,1
Let>Col=1
XLSetCell>xlBook,%ExcelTab%,%Row%,%Col%,%TestNo%,scResult
Gosub>OutlookTest
EndWhile

//Setup variables for next file size
Let>ExcelTab=Outlook 5MB file
Let>Message=5MB Test Message
Let>MailFile=%FileLocation%A5MBFile
Let>Row=1
Let>Col=1
Let>TestNo=0
Let>NumberOfTests=NTests

While>TestNoTestNo,1
Add>Row,1
Let>Col=1
XLSetCell>xlBook,%ExcelTab%,%Row%,%Col%,%TestNo%,scResult
Gosub>OutlookTest
EndWhile

//Setup variables for next file size
Let>ExcelTab=Outlook 25MB file
Let>Message=25MB Test Message
Let>MailFile=%FileLocation%A25MBFile
Let>Row=1
Let>Col=1
Let>TestNo=0
Let>NumberOfTests=NTests

While>TestNoTestNo,1
Add>Row,1
Let>Col=1
XLSetCell>xlBook,%ExcelTab%,%Row%,%Col%,%TestNo%,scResult
Gosub>OutlookTest
EndWhile

XLSave>xlBook,%FileLocation%%SFilename%%DTime%.xls
XLQuit>xlBook

MessageModal>Outlook test is complete. It ran %NTests% times for each file size. Results spreadsheet for this test is saved as %FileLocation%%SFilename%%DTime%.xls.
Exit>0

SRT>OutlookTest
// Outlook test Subroutine

//Run>C:\Program Files\Microsoft Office\Office14\Outlook.exe
WaitWindowOpen>Inbox -*
WindowAction>1,Inbox -*
SetFocus>Inbox -*

//Send a new email message
Press LCTRL
Send>n
Release LCTRL
WaitWindowOpen>Untitled -*
Send %Recepient%
Press Tab * 3
Send>%Message%
Press Tab
Send This is a %Message% body
//
Wait>3
//
Press LALT
Send>n
Release LALT
Send>af
WaitWindowOpen>Insert File*
WindowAction>1,Insert File*
wait 5
Send>%MailFile%
GetTime>StartTime

Press LALT
Send>s
Release LALT

SetFocus>%Message%*
Press LALT
Send>s
Release LALT
Wait>5

//Look for the email message
SetFocus>Inbox -*
//
//
//
//This is the point where I get the popup, it seems to happen right after the text is
//found on the screen page
//
WaitScreenText>%Message%
//
//
//
GetTime>EndTime
TimeDiff>StartTime,EndTime,S,TaskTime
//It seems to take a couple of seconds to find the text, adjust time for the task
Sub>TaskTime,2

//Delete the message
SetFocus>Inbox -*
GetTextPos>%Message%,X1,Y1,X2,Y2
Let>x={%X1%+((%X2%-%X1%) div 2)}
Let>y={%Y1%+((%Y2%-%Y1%) div 2)}
MouseMove>x,y
Wait>1
RClick
Wait>1
Send>d

//Log the message

//Display completion message
Let>MSG_STAYONTOP=1
Let>MSG_CENTERED=1
//MessageModal>Complete in %TaskTime% seconds

//Set Collumn to result Collumn
Add>Col,1

XLSetCell>xlBook,%ExcelTab%,%Row%,%Col%,%TaskTime%,scResult
//Let>WIN_USEHANDLE=1

End>OutlookTest

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

Post by Marcus Tettmar » Wed Sep 25, 2013 3:46 pm

Hi,

:oops: it appears the last build had some diagnostics left in it. :oops:

This accounts for the 1 and 2 messages. We backed those out this morning. Please download 14.0.15 from your account and that will be fixed.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Sep 25, 2013 9:08 pm

Marcus Tettmar wrote: :oops: it appears the last build had some diagnostics left in it. :oops:
Please elucidate the fix(es) in 14.0.15. Thanks.

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

Post by Marcus Tettmar » Wed Sep 25, 2013 9:14 pm

The answer is prior to your question. Said errant diagnostic messages were removed.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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