Problem with FindColor library

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mokshal1663
Junior Coder
Posts: 33
Joined: Sat Feb 27, 2010 8:11 pm

Problem with FindColor library

Post by mokshal1663 » Sat Mar 20, 2010 5:19 pm

Hello. I have a problem with moving the mouse to a pixel color. The first part works but after it waits for the pixel color to come on the screen, it doesn't work. Please help! My code:

// COMPILE_OPTS|C:\Documents and Settings\mokshal\My Documents\AutoBot\AutoFlaxer\AutoFlaxer.exe||CONSOLE=0|INCLUDES=1|
Dialog>AutoSpin
Caption=AutoEP - http://www.autobot.tk
Width=407
Height=239
Top=294
Left=827
Button=Start,32,96,97,41,1
Button=End,272,96,97,41,2
Image=fbg copy.jpg,0,0,401,201,msImage1,0
Button=Info,152,128,97,41,3
Label=Bot ID: 2,176,176,true
EndDialog>AutoSpin

Label>codeStart

show>AutoSpin,result

if>result=2
goto>end
endif

if>result=1
goto>start
endif

if>result=3
MessageModal>Start your character lumbridge bank, make sure flax is visable in the bank!
goto>codeStart
endif

Label>start

Message>Authorizing ID: 2

/*HTTPRequest>http://www.nakido.com/F8DD9F6D48B74E204 ... ,GET,,Data

if>Data=404 HTTP/1.1 404 Not Found
goto>Disabled
endif


Label>Disabled
MessageModal>Your Bot Has Been Disabled. For questions please contact [email protected] or the msn [email protected]
*/

Wait>5

//GetPixelColor>633,320,col
//Message>col

Let>fcLib=%SCRIPT_DIR%\findcolor.dll

LibFunc>fcLib,FindColor,r,16642557,325,32,1362,761,xres,yres
If>r=1
Let>x=r_6
Let>y=r_7
MouseMove>x,y
RClick
Wait>1
Let>YB=y+45
MouseMove>x,YB
LClick
WaitPixelColor>11446860
Endif

Let>fcLib=%SCRIPT_DIR%\findcolor.dll

LibFunc>fcLib,FindColor,r,11446860,325,32,1362,761,xres,yres
If>r=1
Let>x=r_6
Let>y=r_7
MouseMove>x,y
RClick
Wait>1
Endif

Label>end

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Findcolor example incorrect?

Post by gdyvig » Sun Mar 21, 2010 3:37 am

Hi mokeshal1663,

I believe the example that comes with the Findcolor plug-in refers to the wrong variable when capturing the coordinates of the found colorl

Try this:

Code: Select all

Let>fcLib=%SCRIPT_DIR%\findcolor.dll 

LibFunc>fcLib,FindColor,r,11446860,325,32,1362,761,xres,yres 
If>r=1 
Let>x=xres
Let>y=yres
MouseMove>x,y 
RClick 
Wait>1 
Endif 

I'm a little unsure of my answer because I am not at my computer with Macro Scheduler loaded.

Here is the FindColor documentation:
// location of library
Let>fcLib=%SCRIPT_DIR%\findcolor.dll

// Find color on screen
// LibFunc>findcolor.dll,FindColor,result,color,xStart,yStart,xEnd,yEnd,result_x,result_y
// if found result = 1, else 0
// result in result_6,result_7

// Find color between 0,0 and 500,500
LibFunc>fcLib,FindColor,r,15986598,0,0,500,500,xres,yres
If>r=1
Let>x=r_6
Let>y=r_7
MouseMove>x,y
Endif

// Find color in window only
GetActiveWindow>title,x,y,w,h
LibFunc>fcLib,FindColor,r,16105118,x,y,w,h,xres,yres
If>r=1
Let>x=r_6
Let>y=r_7
MouseMove>x,y
Endif
xres and yres are the 6th and 7th parameters after r and seem intended to return the same value as array members r_6 and r_7.



Gale

mokshal1663
Junior Coder
Posts: 33
Joined: Sat Feb 27, 2010 8:11 pm

:(

Post by mokshal1663 » Sun Mar 21, 2010 1:41 pm

Nope, still not working. Thanks for the input though. Anyone have any suggestions?

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

Post by Marcus Tettmar » Mon Mar 22, 2010 9:48 am

What is the debugger telling you? What does it tell you is the value of "r" after the LibFunc line? What does the watch list show for the other values? If you don't have the debugger (if you're using Lite) then place some diagnostic message boxes in the code or use a log file. Please use the tools available to help you help us help you.

Really must charge up that crystal ball again.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Mon Mar 22, 2010 2:59 pm

I confirmed that FindColor works under Windows XP SP3 using MS 11.1.13.

When the color is found,
r=1
r_6=the xcoord found
r_7=the ycoord found

When the color is not found
r=0
r_6=xres
r_7=yres

When FindColor not loaded properly or not functioning
r should be neither 0 or 1, should not be assigned at all.


xres and yres are not variables, just text values for r_6 and r_7 to aid in debugging it appears.

I used FindPixelColor to guarantee a color is found to test the r=1 condition.

//Get a color, then find that color.
GetPixelColor>111,164,nColor
// Find color between 0,0 and 500,500
LibFunc>fcLib,FindColor,r,nColor,0,0,500,500,xres,yres


Gale

mokshal1663
Junior Coder
Posts: 33
Joined: Sat Feb 27, 2010 8:11 pm

HElp

Post by mokshal1663 » Tue Mar 23, 2010 1:08 am

Still not working :cry:
Anyone got any suggestions?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Mar 23, 2010 3:17 am

Will somethin like THIS help? It uses FindImagePos rather than FindColor. It also does not do a wait but the technique could probably be adapted to wait by looping.

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

Re: HElp

Post by Marcus Tettmar » Tue Mar 23, 2010 8:10 am

mokshal1663 wrote:Still not working :cry:
Anyone got any suggestions?
You must be doing something wrong (e.g. a typo in your code or looking for the wrong pixel color). How about posting your code.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

mokshal1663
Junior Coder
Posts: 33
Joined: Sat Feb 27, 2010 8:11 pm

Code

Post by mokshal1663 » Tue Mar 23, 2010 11:34 am

// COMPILE_OPTS|C:\Documents and Settings\mokshal\My Documents\AutoBot\AutoFlaxer\AutoFlaxer.exe||CONSOLE=0|INCLUDES=1|
Dialog>AutoSpin
Caption=AutoEP - http://www.autobot.tk
Width=407
Height=239
Top=294
Left=827
Button=Start,32,96,97,41,1
Button=End,272,96,97,41,2
Image=fbg copy.jpg,0,0,401,201,msImage1,0
Button=Info,152,128,97,41,3
Label=Bot ID: 2,176,176,true
EndDialog>AutoSpin

Label>codeStart

show>AutoSpin,result

if>result=2
goto>end
endif

if>result=1
goto>start
endif

if>result=3
MessageModal>Start your character lumbridge bank, make sure flax is visable in the bank!
goto>codeStart
endif

Label>start

Message>Authorizing ID: 2

/*HTTPRequest>http://www.nakido.com/F8DD9F6D48B74E204 ... ,GET,,Data

if>Data=404 HTTP/1.1 404 Not Found
goto>Disabled
endif


Label>Disabled
MessageModal>Your Bot Has Been Disabled. For questions please contact [email protected] or the msn [email protected]
*/

Wait>5

//GetPixelColor>680,169,col
//Message>col

Let>fcLib=%SCRIPT_DIR%\findcolor.dll

LibFunc>fcLib,FindColor,r,10067879,325,32,1362,761,xres,yres
If>r=1
Let>x=r_6
Let>y=r_7
MouseMove>x,y
RClick
Wait>1
Let>YB=y+45
MouseMove>x,YB
LClick
WaitPixelColor>11446860
Endif

Let>fcLib=%SCRIPT_DIR%\findcolor.dll

LibFunc>fcLib,FindColor,r,11446860,325,32,1362,761,xres,yres
If>r=1
Let>x=xres
Let>y=yres
MouseMove>x,y
RClick
Wait>1
Endif

Label>end

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Tue Mar 23, 2010 4:19 pm

Please provide this detail:
The return values for r, r_6, and r_7.
Your OS so someone can try to reproduce problem.

Try this:
Reactive your GetPixelColor code in case color has changed.
Replace the hardcoded color code with %col%.
Make sure you have erased all trailing spaces in your script.

I don't believe FindColor recognizes color tolerance, so the color has to be right on. Try JRL's suggestion, FindImagePos allows for a color tolerance in case there is some variance from run to run or machine to machine.


Gale

mokshal1663
Junior Coder
Posts: 33
Joined: Sat Feb 27, 2010 8:11 pm

OS

Post by mokshal1663 » Sat Mar 27, 2010 7:54 pm

Os = Windows XP

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Sun Apr 11, 2010 5:21 am

wahaha hello runescapian you do realise that the color changes right and is not constant? and you should not be worrying about color what you need to do is learn to use image recognition when you right click something in runescape the color is still constant wich makes for easy autoers like when you right click a monster you will get like 3 options

attack monster
view monster
walk here

or something like that

or you can do it your way wich is long and boring and dosent always work
and requires multiple colors for all the color changes it runs thru
also the mini map colors are still constant so walking can still work too just the icons on mini map can change exact location slightly so you will need to make use of the findcolor dll for running back and forth also clickable text in runescape never changes positon when its the blue tect you can interact with at bottom of screen wqhen talking to a npc

also never trust autobots it is bad site all the way around
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

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