Script example please

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Script example please

Post by Snickers » Thu Dec 09, 2004 3:21 pm

I am new to Macro Scheduler but it seems like it may be able to do what im looking for. I have been looking for an example script that does the things im wanting but have been unable to find an example. I was hoping someone could provide me with a script so that I could see exaclty how this could be done and repeat it for different applications.


In laymans terms i was wanting macro scheduler to check a pixel color at a about 5 different locations and if the color matched the certain color im looking for then i want it to send a mouse click. I have gathered the colors at the various pixels and will write a script to show you what i need.

They need to be clicking in a certain window though so I dont know if thats important.

//BEGIN
send mouse click to 121,633
wait 1 second

//COLOR CHECKS
if color at pixel 51,575 = 602443 then
send mouse click to 133,863

if color at pixel 51,575 = 3092822 then
send mouse click to 176,863

if color at pixel 51,575 = 2513786 then
send mouse click to 95,862

if color at pixel 51,575 = 2105891 then
check pixel color at 309,232 and if it does NOT = 0 then
repeat //COLOR CHECKS

but if the color at 309,232 = 0 then
send mouse click to 304,138
wait 1 second
send mouse click to 121,633
and repeat this entire macro starting with //BEGIN


Im sorry this is so crappy. its the best i can do until im able to see an example.

I appreciate any assistance on this script
Thanks
Phil

if you need to email this instead of posting it please send to
[email protected]

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Dec 09, 2004 3:37 pm

Well you're 90% there. You just needed the syntax. You'll find explanations of all the commands and functions in the help file and sample scripts on our web site. Here's your script coded up:


Label>Begin
MouseMove>121,633
LClick
Wait>1

Label>ColorChecks
GetPixelColor>51,575,c
If>c=602443
MouseMove>133,863
LClick
Endif

GetPixelColor>51,575,c
If>c=3092822
MouseMove>176,863
LClick
Endif

GetPixelColor>51,575,c
If>c=2513786
MouseMove>95,862
LClick
Endif

GetPixelColor>51,575
If>c=2105891
GetPixelColor>309,232,c
If>c0
Goto>ColorChecks
Else
MouseMove>304,138
LClick
Wait>1
MouseMove>121,633
LClick
Goto>Begin
Endif
Endif
MJT Net Support
[email protected]

Guest

wow that was quick

Post by Guest » Thu Dec 09, 2004 3:47 pm

I totally see what is happening in this script now and should have no problem implementing, editing, or adding to this.
Big thanks!
Phil

now ill have to test her out and go from there.

Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Thu Dec 09, 2004 4:37 pm

It seems to send the first mouse click and I added a second mouseclick and it works too, but once it gets to the color checks it seems to not check colors and the macro doesnt repeat. Does Macro Scheduler have to be always on top or is it another issue causeing this?

with if then statements for example

Label>ColorChecks
GetPixelColor>51,575,c
If>c=602443
MouseMove>133,863
LClick
Endif

if the color at 51,575 does not egual 602443 will this statement simple move to the next color check or should I add

Label>ColorChecks
GetPixelColor>51,575,c
If>c=602443
MouseMove>133,863
LClick
else
endif

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Dec 09, 2004 4:47 pm

if the color at 51,575 does not egual 602443 will this statement simple move to the next color check or should I add
Correct. I did it that way because that is what you asked for.

If none of the color checks ever resolve true the script will simply end. Maybe you want to add the following line to the end of the script (last line):

Goto>ColorCheck

Then it will repeat even if all the checks resolve false.

In the following example 'do this' ONLY happens if 'something is true' but then the script will continue.

If>something is true
do this
endif

You can also do this:

If>something is true
do this
else
do another
endif

Here we 'do this' if 'something is true' but if 'something is NOT true' we 'do another'.
MJT Net Support
[email protected]

Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Thu Dec 09, 2004 5:06 pm

FOUND IT!

This is what you had written originally

GetPixelColor>51,575
If>c=2105891
GetPixelColor>309,232,c
If>c0
Goto>ColorChecks
Else
MouseMove>304,138
LClick
Wait>1
MouseMove>121,633
LClick
Goto>Begin
Endif
Endif


But i wondered why it was failing at the color checks and i added something to what you had written indicated in bold.

GetPixelColor>51,575,c
If>c=2105891
GetPixelColor>309,232,c
If>c0
Goto>ColorChecks
Else
MouseMove>304,138
LClick
Wait>1
MouseMove>121,633
LClick
Goto>Begin
Endif
Endif
Goto>ColorChecks

It runs like a charm...ill be buying this software afterall
great script program

Thank you for you assistance

I'm having trouble stopping the macro using the CTRL-B though

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Dec 09, 2004 5:32 pm

Hi,
GetPixelColor>51,575,c
Oops, well spotted.
I'm having trouble stopping the macro using the CTRL-B though
CTRL-B is a short cut key on the main Macro Scheduler window (short cut to the break menu item) so will only work when it has the focus. The macro is in a tight loop so this could be tricky.

Instead try SHIFT-ESC or whatever you have it set to in Tools/Options. This is a system wide hotkey for stopping any script anywhere. This should work.
MJT Net Support
[email protected]

Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Thu Dec 09, 2004 5:34 pm

One more question please. I'm trying to add a random event.

GetPixelColor>51,575,c
If>c=2105891
GetPixelColor>309,232,c
If>c0
generate a random number and if random number between 1-3=3
Mousemove>133,863
Lclick
Else
Goto>ColorChecks
Else
MouseMove>304,138
LClick
Wait>1
MouseMove>121,633
LClick
Goto>Begin
Endif
Endif
Goto>ColorChecks



is it possible to generate a random number between 1-3 and if that number is 3 send event?

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Dec 09, 2004 5:41 pm

Yep:


Random>3,res
Let>res=res+1
If>res=3
whatever
Endif
MJT Net Support
[email protected]

Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Thu Dec 09, 2004 11:59 pm

ok i have added quite a few things now and its looking good. I cant get the random number thing to work yet but I'll figure it out shortly.

Thank you; you've been a big help

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