Blue Eye Logo

Blue Eye Macro

Automation is freedom
It is currently Wed Jun 26, 2019 10:59 am

All times are UTC




Post new topic Reply to topic  [ 15 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: shorten Macro ?
Thanked: 0 time(s)  Unread post Posted: Tue Sep 27, 2011 7:15 am 
VIP Contributor
VIP Contributor
User avatar



Joined: Mon Sep 12, 2011 8:36 pm
Posts: 1307
Location: Steins;Gate
Been thanked: 87 time(s)
Has thanked: 0 time(s)
Contribution Points: 15365
IRock6996 wrote:
i was thinking it would halt and wait for the picture and ya the reason i added that other if was so if the item did not need to be repaired it would skip past and do the next. So are you saying i can remove it and it will do it anyways. ?


Code:
if  Image.Can be located on screen("C:\Documents and Settings\nonrepair.png", "100")
               begin
               end


Long story short: Exactly, but if you want an invigorating detail as to why, read on to my thread as I moved this to the Tips&How section.

Edit: Moved my guide elsewhere along with a minor guide edit update.

_________________
Image
Code:
> Meanwhile at Blue Eye Macro...
> BEM Video Games Department - Moderator, Coder, Debugger, Math/Physics & Algorithm Enthusiast - USA
Current Project: Mod Duty


Last edited by Critical on Tue Sep 27, 2011 12:08 pm, edited 6 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: shorten Macro ?
Thanked: 0 time(s)  Unread post Posted: Tue Sep 27, 2011 8:51 am 
Partner / Developer
Partner / Developer
User avatar



Joined: Mon Jan 18, 2010 11:51 am
Posts: 4524
Been thanked: 1206 time(s)
Has thanked: 132 time(s)
Contribution Points: 32885
Very nice guide.

Just thought id add a third way of doing it.

This will perform best of all three, but in a not very "nice" way, since we are essentially using a macro error to detect if the image was found. (If Image.Find location..... is unable to find the image, it will log it as an error)

Code:
 begin
     Image.Find location of first occurrence on screen("C:\Documents and Settings\repair.png", "100", "x", "y")
     if  Macro.No errors occurred()
          begin
               Macro.Pause("500")
               Mouse.Click at coordinate("{x}", "{y}", "left")
               Macro.Pause("500")
               Mouse.Click at coordinate("571", "602", "left")
               Macro.Pause("500")
          end
     Macro.Reset error has occurred()
 end


Its faster though since we only search the screen once for the image.

In BE version 2.6, new functions will be available to "try" to find an image on screen, which will essentially allow you to do exactly as I did above, but in a nice way, without the errors.

Keep up the good work Critical!

_________________
Blue Eye - Developer / Moderator
Code:
Gigus


Please read the rules about contribution points - click here

Do you know everything about BE, the forum, licenses and contribution points?
Please take a minute to read this introduction & guidelines.


Top
 Profile  
Reply with quote  
 Post subject: Re: shorten Macro ?
Thanked: 0 time(s)  Unread post Posted: Tue Sep 27, 2011 3:03 pm 
Silver Contributor
Silver Contributor



Joined: Tue Jul 19, 2011 5:04 am
Posts: 121
Been thanked: 1 time(s)
Has thanked: 0 time(s)
Contribution Points: 120
Well i check out the way you guys said first i removed the extra if and it failed it skipped past all the armor without repairing it. Then i tried Image Find location of first occurrence on screen and that and again it failed it skipped past all the armor without repairing. Not sure what is going on not errors reported any ideas ?


Top
 Profile  
Reply with quote  
 Post subject: Re: shorten Macro ?
Thanked: 0 time(s)  Unread post Posted: Tue Sep 27, 2011 3:46 pm 
VIP Contributor
VIP Contributor
User avatar



Joined: Mon Sep 12, 2011 8:36 pm
Posts: 1307
Location: Steins;Gate
Been thanked: 87 time(s)
Has thanked: 0 time(s)
Contribution Points: 15365
Edit: Try Gigus's idea first and if the image couldn't be found then try mine. If my ideas are also bust after trying both of ours, report back.

So both of these codes didn't work for you?

Code:
begin
     if  Image.Can be located on screen("C:\Documents and Settings\repair.png", "100")
          begin
               Macro.Pause("500")
               Mouse.Click at image("C:\Documents and Settings\repair.png", "100", "left")
               Macro.Pause("500")
               Mouse.Click at coordinate("571", "602", "left")
               Macro.Pause("500")
          end
end

Code:
begin
     Image.Find location of first occurrence on screen("C:\Documents and Settings\repair.png", "100", "x", "y")
     if  Macro.No errors occurred()
          begin
               Macro.Pause("500")
               Mouse.Click at coordinate("{x}", "{y}", "left")
               Macro.Pause("500")
               Mouse.Click at coordinate("571", "602", "left")
               Macro.Pause("500")
          end
     Macro.Reset error has occurred()
end


Hmm, there are a few ways to go about given the problem you've described. If you can, list the game or program you're trying to use it with, I can at the least pinpoint the specifics out. Totally up to you if you want to keep that private or not.

A) There's transparency within the windows, so you need to adjust the range to NOT be at 100. More like 30% or so.
Code:
//Your Code
if  Image.Can be located on screen("C:\Documents and Settings\repair.png", "{This is your range value here, edit it to 30")
or
//Gigus's Code
Image.Find location of first occurrence on screen("C:\Documents and Settings\repair.png", "{This is your range value here, edit it to 30}", "x", "y")

B) In some games, there will be an additional window to 'confirm', you probably need to add Image/Color command so the macro can detect and click on it.
C) If all else fails: Use the Macro Record Button and repair the item yourself, stop it and cut+paste the parts where you move to the specified coordinates. Make it look similar to our code structure. Seriously keep in mind of Tip A) as Transparency is usually the main culprit behind it all.

Hopefully that'll help you out. Leave back some more questions along with your code (if applicable). Making macros is a tricky business when you type it out by hand, and I understand that.

See you when you get back~

_________________
Image
Code:
> Meanwhile at Blue Eye Macro...
> BEM Video Games Department - Moderator, Coder, Debugger, Math/Physics & Algorithm Enthusiast - USA
Current Project: Mod Duty


Last edited by Critical on Tue Sep 27, 2011 3:53 pm, edited 3 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: shorten Macro ?
Thanked: 0 time(s)  Unread post Posted: Tue Sep 27, 2011 3:50 pm 
Partner / Developer
Partner / Developer
User avatar



Joined: Mon Jan 18, 2010 11:51 am
Posts: 4524
Been thanked: 1206 time(s)
Has thanked: 132 time(s)
Contribution Points: 32885
IRock6996 wrote:
Well i check out the way you guys said first i removed the extra if and it failed it skipped past all the armor without repairing it. Then i tried Image Find location of first occurrence on screen and that and again it failed it skipped past all the armor without repairing. Not sure what is going on not errors reported any ideas ?


Try executing just:
Code:
Image.Find location of first occurrence on screen("C:\Documents and Settings\repair.png", "100", "x", "y")


You should get a error then if the image couldn't be found.

_________________
Blue Eye - Developer / Moderator
Code:
Gigus


Please read the rules about contribution points - click here

Do you know everything about BE, the forum, licenses and contribution points?
Please take a minute to read this introduction & guidelines.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ]  Go to page Previous  1, 2

All times are UTC


You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group