Need your knowledge while creating a macro

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Freeman
Newbie
Posts: 5
Joined: Sun Feb 26, 2012 2:22 pm

Need your knowledge while creating a macro

Post by Freeman » Sun Feb 26, 2012 2:43 pm

Im a total newbie,im specifically trying to make a macro to cover my needs. But im kinda lost while trying to do it,never done this before. I will be glad if anyone can help me out. This is what i want to do:

When i press specific keyboard button = for example F5 it should start the macro and when it reaches the end waits for me to press it once again.

Macro needs to do this in priority order:

*part1* (priority order)
check if image or pixel color on specific location matches (Less cpu usage is better )
if yes ,press somekey
if not skip to part 2
*part 2*
check if image or pixel color on specific location matches
if yes ,press somekey
if not skip to part 3
*part 3*
check if image or pixel color on specific location matches
if yes ,press somekey
if not skip to part 4
*part 4*
check if image or pixel color on specific location matches
if yes ,press somekey
if not skip to part 5
*part 5*
check if image or pixel color on specific location matches
if yes ,press somekey
if not end the macro and until i press F5 again do not fire it.

Thanks in advance !

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sun Feb 26, 2012 6:28 pm

I suggest FindImagePos>
Online Help http://www.mjtnet.com/OnlineHelp/index. ... agepos.htm

Code: Select all

FindImagePos>C:\part1.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
//Press Some Key
Endif

FindImagePos>C:\part2.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
//Press Some Key
Endif

FindImagePos>C:\part3.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
//Press Some Key
Endif

FindImagePos>C:\part4.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
//Press Some Key
Endif

FindImagePos>C:\part5.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
//Press Some Key
Endif

Freeman
Newbie
Posts: 5
Joined: Sun Feb 26, 2012 2:22 pm

Post by Freeman » Mon Feb 27, 2012 1:38 pm

thank you for your fast reply and help!

I do have another question, how do i set script to fire only when i press specific key like F5?

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Mon Feb 27, 2012 6:24 pm

OnEvent is what you're looking for...

OnEvent Online Help http://www.mjtnet.com/OnlineHelp/index.htm?onevent.htm

Virtual Key Codes http://www.mjtnet.com/vkcodes.htm

Code: Select all

OnEvent>KEY_DOWN,VK116,0,F5KeyPressed

Label>Loop
Wait>.1
Goto>Loop

SRT>F5KeyPressed
MDL>F5 was pressed
END>F5KeyPressed

Freeman
Newbie
Posts: 5
Joined: Sun Feb 26, 2012 2:22 pm

Post by Freeman » Mon Feb 27, 2012 6:32 pm

thx for your kind help :)

Freeman
Newbie
Posts: 5
Joined: Sun Feb 26, 2012 2:22 pm

Post by Freeman » Fri Mar 02, 2012 12:06 pm

So i recently bought MS,im going to figure working with it hopefully. Baby steps for now. Unfortunately,i need this one working as soon as possible:

it looks like this :

Code: Select all

OnEvent>KEY_DOWN,VK116,0,F5KeyPressed
SetFocus> ProgramX
Label>Loop
FindImagePos>C:\Users\Patish\Desktop\Documents\Macro scheduler\brand.bmp,C:\Users\Patish\Desktop\Documents\Macro scheduler\brand.bmp,1,1,1845,1058,NumFound
If>NumFound>0
//Press F11
Endif
FindImagePos>C:\Users\Patish\Desktop\Documents\Macro scheduler\banner.bmp,C:\Users\Patish\Desktop\Documents\Macro scheduler\banner.bmp,2,1,1896,961,NumFound
If>NumFound>0
//Press F10
Endif
FindImagePos>C:\Users\Patish\Desktop\Documents\Macro scheduler\powerr.bmp,C:\Users\Patish\Desktop\Documents\Macro scheduler\powerr.bmp,1,1,1896,993,NumFound
If>NumFound>0
//Press F9
Endif
FindImagePos>C:\Users\Patish\Desktop\Documents\Macro scheduler\Execute.bmp,C:\Users\Patish\Desktop\Documents\Macro scheduler\Execute.bmp,1,1,1896,1028,NumFound
If>NumFound>0
//Press F8
Endif
FindImagePos>C:\Users\Patish\Desktop\Documents\Macro scheduler\style.bmp,C:\Users\Patish\Desktop\Documents\Macro scheduler\style.bmp,1,1,1896,1059,NumFound
If>NumFound>0
//Press F7
Endif
Wait>.1
Goto>Loop
SRT>F5KeyPressed
END>F5KeyPressed
Problem atm:
:arrow: It always fires F11-first image found,does not skip part 2.

Freeman
Newbie
Posts: 5
Joined: Sun Feb 26, 2012 2:22 pm

Post by Freeman » Fri Mar 02, 2012 4:51 pm

Problem solved,thanks to mjtnet support!

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