Problem with macro

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
webo
Newbie
Posts: 4
Joined: Thu Mar 03, 2011 2:35 pm

Problem with macro

Post by webo » Thu Mar 03, 2011 3:03 pm

HI.

I have a very strange problem.

I have made a macro and when I run it it does the same thing that I can do all the steps manually and then it works fine but when I use the macro for it then it won't work.

It's a bit comlited to say because it's a program for our pbx för extracting statistics.

I run Macroscheduler as administrator and I have alos disabled UAC. I use Windows 7 Pro 64bit.

It does this:

It run a program, press CTRL+O (Open) and then tabs to right place to enter text and then open a new window and it's when it shall open the new window then it says that the file it reads that is 2,5MB big is empty and when I look at the file then it's is 0 byte big. When i do the same steps manully the the window opens and it gets the is right size. It gets the file from our pbx when just before it opens the windows that fail. So when i do it manully the it downloads the file right but from macro with same steps then it fails.

It's very strange and We can not see the diffrence since it's same info and under same user account i windows and so on.

Any ideá what could be wrong?

Here is the code:

Code: Select all

RunProgram>D:\Alcatel\Ticket Analyzer\Ticket.exe
WaitWindowOpen>Ticket Analyzer
Wait>0.4
Press CTRL
Wait>0.4
Send>o
WaitWindowOpen>Connection
Wait>0.4
Release CTRL
Wait>0.4
Press Left * 14
Wait>0.4
Press Tab * 4

Send>pbxname
Wait>0.4
Press Tab
Wait>0.4
Send>username
Wait>0.4
Press Tab
Wait>0.4
Send>password
Wait>0.4
Press Tab
Wait>0.4
Send>Communication
Wait>0.4
Press Tab
Wait>0.4
VBSTART
VBEND

VBEval>DateAdd("d",-1,date),yesterday
VBEval>Right("0" & DatePart("d","%yesterday%"), 2),day_bit
VBEval>Right("0" & DatePart("m","%yesterday%"), 2),month_bit
VBEval>DatePart("yyyy","%yesterday%"),year_bit

Let>formatted_date=%year_bit%-%month_bit%-%day_bit%

Send>formatted_date

Press Tab

Send>formatted_date

Wait>0.4
Press Enter

Best regards
Morten

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Thu Mar 03, 2011 3:23 pm

Not sure if this is your problem, however It has been known to cause problems in the past so I'll mention it. Sometimes Macro Scheduler can send keystrokes faster than an application can process them. So for instance where you do this:

Press Left * 14


Instead do this:

Let>r=0
Repeat>r
Add>r,1
Wait>0.1
Press Left
Until>r=14

And also add this to the top of your Macro
Let>SK_DELAY=100

This will insert 100 millisecond waits between each character sent using the Send> command

webo
Newbie
Posts: 4
Joined: Thu Mar 03, 2011 2:35 pm

Problem with macro

Post by webo » Tue Mar 08, 2011 9:50 am

adroege wrote:Not sure if this is your problem, however It has been known to cause problems in the past so I'll mention it. Sometimes Macro Scheduler can send keystrokes faster than an application can process them. So for instance where you do this:

Press Left * 14


Instead do this:

Let>r=0
Repeat>r
Add>r,1
Wait>0.1
Press Left
Until>r=14

And also add this to the top of your Macro
Let>SK_DELAY=100

This will insert 100 millisecond waits between each character sent using the Send> command
Thanks for the answer and I have made the changes but still have the same problem. When doing all the steps manuelly the verything works fine but with macro scheduler the it fails. It's very strange and I really need this to work as it something we need to do 3 times a day everyday and it's too much work to do manuelly.

I use the newest version of Macro Sheduler Pro Enterprise.

Anyone else that can help me with this, please?

Best regards
Morten

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

Post by Marcus Tettmar » Tue Mar 08, 2011 10:05 am

Some thoughts:

* I don't see a SetFocus line in your script. Has the right window got the focus?

* When is the macro run?

* What state is the system in when it is run?

* If it works in debug (run from the editor) but fails when run outside of th editor then it just needs slowing down. Slow those keysends down as has been suggested.

If needed contact support and we can arrange a desktop sharing session and debug it with you in situ.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

webo
Newbie
Posts: 4
Joined: Thu Mar 03, 2011 2:35 pm

Problem with macro

Post by webo » Tue Mar 08, 2011 10:34 am

mtettmar wrote:Some thoughts:

* I don't see a SetFocus line in your script. Has the right window got the focus?

* When is the macro run?

* What state is the system in when it is run?

* If it works in debug (run from the editor) but fails when run outside of th editor then it just needs slowing down. Slow those keysends down as has been suggested.

If needed contact support and we can arrange a desktop sharing session and debug it with you in situ.
The right window opens (WaitWindowOpen>Connection).

Dosen't matter when I run it.

I'm logged on and starting the macro från the run command in Macro Scheduler.

Same problem when run in debug.

I'll contact the support and see if they can help me in a desktop sharingn session.

Thanks.

Best regards
Morten

webo
Newbie
Posts: 4
Joined: Thu Mar 03, 2011 2:35 pm

Problem with macro

Post by webo » Tue Mar 08, 2011 2:10 pm

Thanks to the great support taking time to do a desktop sharing session tha problem was solved after som trys.

The solution was to use Executefile instead of RunProgram and then everything was working as it should.

Best regards
Morten

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Wed Mar 09, 2011 3:53 pm

Marcus,

Can you provide some explanation here? Is there a lesson to be learned?

I would have never guessed that when calling an EXE it would matter if I used ExecuteFile instead of RunProgram

?
?
?
?

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

Post by Marcus Tettmar » Wed Mar 09, 2011 4:28 pm

If there's an explanation I don't know what it is, though knowing a little about how Run works as opposed to ExecuteFile and the Windows APIs being used behind the scenes I can guess that it *may* have *something* to do with process ownership. But I cannot possibly know why the behaviour was different. If I had the source code of the 3rd party app in question, or could get inside the head of the person who wrote it, I may be able to find a technical but very boring answer.

Let's not get hung up on what we can never possibly find out (we don't have any control over third party apps or how they work). Instead let's just remember that Macro Scheduler is a huge toolbox which offers various different ways of doing something, for the very reason that one method may work wonders for one scenario but fail in another. With Macro Scheduler there is always another way to do something.

I don't have all the answers. If there is anything to be learned from this it is just "if one method fails, try another".
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