AutoHotkey Community

It is currently May 27th, 2012, 2:56 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 68 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject:
PostPosted: November 26th, 2009, 10:48 am 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
wow! thanks .
thats was a great example of fine ahk work =)

the only problem i have now is im kinda confused wit my script.
in the most basic form can yu explain what happends and what the script is doing, so i can finsih it and add my mouse click.

im not sure what exactly has changed and whatnot.

i have noticed that if i press f3 on a color it brings it up under the curser.
what do i need to do "in baby talk pretty much" to complete this, i need to understand the script and what next steps i shld take.

keep in mind that my original idea is

have a small gui box, if green goes underneath it, then click the left mouyse button

_________________
---{+.-}---


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 5:53 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
Quote:
keep in mind that my original idea is
have a small gui box, if green goes underneath it, then click the left mouyse button

Thanks for the reminder, here are my suggested steps with an improved and commented script :wink:

1. Note: if you can't capture the game with printscreen the script won't work! Test this first!

If you don't know the exact color of the pixel, steps 4 & 5 will help.
If you are going to do these steps save the small section of the image with the 'green' color in a small 35 x 35 BMP file.

2. The script as written shows a gui with RED and searches for it.
It reports via tooltip the time the search took, pass/fail and x & y coordinates.
If you let it run as is, you will probably see it takes 600 miliseconds or so.
There is a single line that when commented out will remove the fill color.

3. If you have the color of the 'green' in BLUE/GREEN/RED order you can skip step 4 & 5.

4. If you want to test against the BMP, edit the script to correct the lines.
Code:
image = 4red_pixel.bmp ; <------filename goes here
gui, add, picture, , %image%

Save and run it. You should get the image that you saved.
Don't press OK. Instead, move your cursor over the image and see the color values by pressing F3.

5. Note the color you want

6. Edit the script line with your choice of 'pixel_color' Save and run the script

7. if the script works to find the pixel on the game, edit the script to comment out the tooltip and enable the mouseclick.

8. Test and have fun with it.

Code:
;============================================================================
; set coordinates for the screen so GUI position, search and clicks will align

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen

;-----------the gui hitbox---------------------------------------------------
bDim = 35 ; Change this to desired size.
;bDim = 5 ; Change this to desired size.
xPos = % (A_ScreenWidth/2) - bDim
yPos = % (A_ScreenHeight/2) - bDim

;============================================================================
; Leef_me's choice of pixel color
pixel_color= 0x0000FF ; search for red ; BLUE/GREEN/RED order

;Cyber's choice of pixel color
;pixel_color= 0x0000FF

;============================================================================
; If you want to test on an image you can enable this
image = 4red_pixel.bmp ; <------filename goes here
;gui, add, picture, , %image%

Gui, +alwaysontop
Gui, -Caption Border AlwaysOnTop ToolWindow

; RED/GREEN/BLUE order
Gui, Color, C0C0C0
Gui, Color, ff0000 ; <----- Leef_me's choice of GUI fill color

Gui, Show, NA W%bDim% H%bDim% X%xPos% Y%yPos%, hitBox

WinWait, hitBox
WinSet, TransColor, C0C0C0 255, hitBox

;============================================================================
; get the location of the box, without relying on the above xpos & ypos
; report actual location of the window, and save for imagesearch

WinGetPos , X, Y, Width, Height, hitBox
msgbox !%Title% x%X% Y%Y% W%Width% H%Height%! `n wanted upper_left-> X%xPos% Y%yPos% `n press OK to start search
;return

;================================================================================
;start the search

settimer, find_pixel,-1 ; wait 0.001 seconds before searching
return

;============================================================================

find_pixel:

b:=A_TickCount ; <--- measure the time the pixelsearch takes

pixelSearch  , TL , BR , X, Y, X+Width, Y+Height, pixel_color ; BLUE/GREEN/RED order

c:=A_TickCount ; <--- measure the time the pixelsearch takes
d:=c-b

;============================================================================
; for testing, show a tooltip instead of causing a mouseclick

;tooltip, !!%errorlevel%!%TL%!%BR%!, xpos+50, ypos

; the next line shows 1/1000 second, 0 if found, x and y coordinates
tooltip, !%d%!!%errorlevel%!%TL%!%BR%!, xpos+50, ypos

;MouseClick [, WhichButton , X, Y, ClickCount, Speed, D|U, R]

;MouseClick , left , TL , BR , 1 , 10


settimer, find_pixel , -200 ; wait 0.2 seconds between searches

return

;================================================================================
f3::   ; get the color of the pixel at the mouse cursor location
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen

; coodinates are relative to screen based on CoordMode used at top of script

MouseGetPos, xx , yy
PixelGetColor, cc, xx, yy
tooltip %xx% %yy% %cc%
return
 
;----------------------------end statemnts------------------------------------
esc::
^z::ExitApp


Last edited by Leef_me on November 28th, 2009, 9:37 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 11:25 am 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
thankyou so much =D.
that did help quite alot.

i am confused on why the color red is now in mall small gui box. (hitbox)
i thought that was ment to be transparent?

well anyway, il post for you my curent script (close to the same)
with the few "little" changes of colors and imgaes and what not.

i still have a problem with it, ahh it always left clicks after i press the "ok" button.

is there a certain oreder i should set it up, for example.

i just run the script the press ok.. is that all i need to make it work.

ot is it that i need to run the script search for it with f3 then press ok?
or something liek that?
i also get this msg/error?
" ! x805 y490 w37 h37! wanted upper left -> x805.000000 y490.000000 press ok to search"
im not sure if thats an error or instructions or something =s

Id like to thank you again, you have helped me with alot, especialy understanding how my script actualy workes, well alot more then i did.
i still find it quite complex, but im learning alot quicker then not asking questions =D


Code:
;============================================================================
; set coordinates for the screen so GUI position, search and clicks will align

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen

;-----------the gui hitbox---------------------------------------------------
bDim = 35 ; Change this to desired size.
;bDim = 5 ; Change this to desired size.
xPos = % (A_ScreenWidth/2) - bDim
yPos = % (A_ScreenHeight/2) - bDim

;============================================================================
; Leef_me's choice of pixel color
pixel_color= 0x0000FF ; search for red ; BLUE/GREEN/RED order

;Cyber's choice of pixel color
;pixel_color= 0x0000FF

;============================================================================
; If you want to test on an image you can enable this
image = ImgQL.bmp ; <------filename goes here
;gui, add, picture, , %image%

Gui, +alwaysontop
Gui, -Caption Border AlwaysOnTop ToolWindow

; RED/GREEN/BLUE order
Gui, Color, C0C0C0
Gui, Color, FF0000 ; <----- Leef_me's choice of GUI fill color

Gui, Show, NA W%bDim% H%bDim% X%xPos% Y%yPos%, hitBox

WinWait, hitBox
WinSet, TransColor, C0C0C0 255, hitBox

;============================================================================
; get the location of the box, without relying on the above xpos & ypos
; report actual location of the window, and save for imagesearch

WinGetPos , X, Y, Width, Height, hitBox
msgbox !%Title% x%X% Y%Y% W%Width% H%Height%! `n wanted upper_left-> X%xPos% Y%yPos% `n press OK to start search
;return

;================================================================================
;start the search

settimer, find_pixel,-1 ; wait 0.001 seconds before searching
return

;============================================================================

find_pixel:

b:=A_TickCount ; <--- measure the time the pixelsearch takes

pixelSearch  , TL , BR , X, Y, X+Width, Y+Height, pixel_color ; BLUE/GREEN/RED order

c:=A_TickCount ; <--- measure the time the pixelsearch takes
d:=c-b

;============================================================================
; for testing, show a tooltip instead of causing a mouseclick

;tooltip, !!%errorlevel%!%TL%!%BR%!, xpos+50, ypos

; the next line shows 1/1000 second, 0 if found, x and y coordinates
tooltip, !%d%!!%errorlevel%!%TL%!%BR%!, xpos+50, ypos

;MouseClick [, WhichButton , X, Y, ClickCount, Speed, D|U, R]

MouseClick , left , TL , BR , 1 , 10


settimer, find_pixel , -200 ; wait 0.2 seconds between searches

return

;================================================================================
f3::   ; get the color of the pixel at the mouse cursor location
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen

; coodinates are relative to screen based on CoordMode used at top of script

MouseGetPos, xx , yy
PixelGetColor, cc, xx, yy
tooltip %xx% %yy% %cc%
return
 
;----------------------------end statemnts------------------------------------
esc::
^z::ExitApp


ps: the image is like 15-19pixels or something, im using paint.net, and it wldnt let me have 30-30 =s
all it is a completly greenish yelow color "an exact color of a part of the image im searching"

so to sumerise.

-im not sure how to properly run this efectivly?
-it always leftclicks when script is run?
-im not quite sure why the hitbox is now red?

-oh! and the new line of code
Code:
; get the location of the box, without relying on the above xpos & ypos
; report actual location of the window, and save for imagesearch

WinGetPos , X, Y, Width, Height, hitBox
msgbox !%Title% x%X% Y%Y% W%Width% H%Height%! `n wanted upper_left-> X%xPos% Y%yPos% `n press OK to start search
;return

_________________
---{+.-}---


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 11:42 am 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
Update in my script, how im trying to run it presently.

Code:

;============================================================================
; set coordinates for the screen so GUI position, search and clicks will align

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen

;-----------the gui hitbox---------------------------------------------------
bDim = 35 ; Change this to desired size.
;bDim = 5 ; Change this to desired size.
xPos = % (A_ScreenWidth/2) - bDim
yPos = % (A_ScreenHeight/2) - bDim

;============================================================================
; Leef_me's choice of pixel color
pixel_color= 0x0000FF ; search for red ; BLUE/GREEN/RED order

;Cyber's choice of pixel color
;pixel_color= 0x0000FF

;============================================================================
; If you want to test on an image you can enable this
;image = ImgQL.bmp ; <------filename goes here
;gui, add, picture, , %image%

Gui, +alwaysontop
Gui, -Caption Border AlwaysOnTop ToolWindow

; RED/GREEN/BLUE order
Gui, Color, C0C0C0
;Gui, Color, FF0000 ; <----- Leef_me's choice of GUI fill color

Gui, Show, NA W%bDim% H%bDim% X%xPos% Y%yPos%, hitBox

WinWait, hitBox
WinSet, TransColor, C0C0C0 255, hitBox

;============================================================================
; get the location of the box, without relying on the above xpos & ypos
; report actual location of the window, and save for imagesearch

WinGetPos , X, Y, Width, Height, hitBox
msgbox !%Title% x%X% Y%Y% W%Width% H%Height%! `n wanted upper_left-> X%xPos% Y%yPos% `n press OK to start search
;return

;================================================================================
;start the search

settimer, find_pixel,-1 ; wait 0.001 seconds before searching
return

;============================================================================

find_pixel:

b:=A_TickCount ; <--- measure the time the pixelsearch takes

pixelSearch  , TL , BR , X, Y, X+Width, Y+Height, E6EFEF ; BLUE/GREEN/RED order

c:=A_TickCount ; <--- measure the time the pixelsearch takes
d:=c-b

;============================================================================
; for testing, show a tooltip instead of causing a mouseclick

;tooltip, !!%errorlevel%!%TL%!%BR%!, xpos+50, ypos

; the next line shows 1/1000 second, 0 if found, x and y coordinates
;tooltip, !%d%!!%errorlevel%!%TL%!%BR%!, xpos+50, ypos

;MouseClick [, WhichButton , X, Y, ClickCount, Speed, D|U, R]

MouseClick , left , TL , BR , 1 , 10


settimer, find_pixel , -200 ; wait 0.2 seconds between searches

return

;================================================================================
f3::   ; get the color of the pixel at the mouse cursor location
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen

; coodinates are relative to screen based on CoordMode used at top of script

MouseGetPos, xx , yy
PixelGetColor, cc, xx, yy
tooltip %xx% %yy% %cc%
return
 
;----------------------------end statemnts------------------------------------
esc::
^z::ExitApp



not sure why it isnt working now =s

_________________
---{+.-}---


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 10:40 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
Edit: OOPS! I missed that you edited the pixel color directly in the imagesearch line. :oops: All I can suggest is going through my steps more carefully.
===============================================

In your latest script, I see that you found out why the box was filled red.

To make the script work with you version of 'green' look here, what is missing ?
Code:
;============================================================================
; Leef_me's choice of pixel color
pixel_color= 0x0000FF ; search for red ; BLUE/GREEN/RED order

;Cyber's choice of pixel color
;pixel_color= 0x0000FF

;============================================================================


per my prior post:

3. If you have the color of the 'green' in BLUE/GREEN/RED order you can skip step 4 & 5.

6. Edit the script line with your choice of 'pixel_color' Save and run the script


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2009, 6:11 am 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
Actualt, no i have no idea why u picked red as the hitbox color?
i might have chaned the settings and script acording to what i thought was right, im stil quite confused on alot of this =/
iv read therough it a bit, and im getting there but still a bit slipery on it.

and im not sure what you mean by "i missed that you edited the pixel coor into the imagesearch line?"

also i have chged the color of that line like u suggestted. but my problem stil occures,
-it clicks everything, and the so called "error?" mesage still ocures when the ok buton is present.

EG BY "CLICKS EVERYTHING" i mean, it loops leftclick, everything i move my cursour over it just clicks, (thought id clear that up)

im just going to remind you, that this is a pixel search only in the hotbox area. i dont whant the color to always be behind the hitbox...
example..
playing a game, the hiotbox is always over the crosshair "the crosshair alqways stayes centred in the screen" and manny colors wil run past the "hitbox"/crosshair area, but i dont whant it to leftclick until it fins "green"
im just making sure that this isunderstood so i dont make the wrong script.
thanks heaps, especialy you Leaf_Me =) you have worked wonders forme

_________________
---{+.-}---


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2009, 7:19 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
You referred to 'green' but there are many shades.
I chose the color red because it was NOT green.

I suggest that you have the wrong color for green.
Here is a bmp of the color you are searching for.
http://www.autohotkey.net/~Leef_me/BGR_E6EFEF.bmp
It doesn't look like green to me.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2009, 12:00 pm 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
ahh i see! good thinking sir!. wel cld i leave it as transparent? , not that matters to much =)

anywho, that confuses me the picture u posted.. is that really the color i selected, im not sure how to post images so il search how and post an image of the screenshot i have taken to get the color of.

now for the color am i suposed to be reading the
red = blah blah
green = lalala
blue = bannana?

or am i suposed to be taking it of the actual numbers after "color"

color = blah blah hibbidigoga =[)

ok, and u have tickled my thining a litle bit when u said theres more then one shade.. can i use some sort of way so that it picks manny shades between a lime yelow, and bright green.
refer to the link i wil post of the screenshot when i work out how to sumbit.. shld only be a few minuts.

also i tested this and it stil clicks colores like red =s not just grey.

test the script yourself, see what i mean?

thanks alot
~Cyber.

_________________
---{+.-}---


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2009, 9:39 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
Ah Hah!

One definite problem with your version of the script is that you are NOT searching for a know color. This line of code is written wrong
Code:
pixelSearch  , TL , BR , X, Y, X+Width, Y+Height, E6EFEF ; BLUE/GREEN/RED order

It SHOULD like this be written
Code:
pixelSearch  , TL , BR , X, Y, X+Width, Y+Height, 0xE6EFEF ; BLUE/GREEN/RED order

The pixel color parameter can be an expression, and 'E6EFEF' is interpreted to be a variable, not a value; 0xE6EFEF is a value.



The BMP I posted is indeed the color 0xE6EFEF

To find the proper color, go back to my instructions, and do steps 4 & 5


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2009, 10:51 am 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
ok i changed the the error with pixel search i shal test it in 1 sec.
here is the image

[img]<a%20href="http://imgur.com/P5Jzy.jpg"%20title="Hosted%20by%20imgur.com">http://imgur.com/P5Jzy.jpg</a>[/img]

_________________
---{+.-}---


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2009, 10:56 am 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
sorry i think i posted that link wrong
<a href="http://imgur.com/P5Jzy.jpg" title="Hosted by imgur.com">http://imgur.com/P5Jzy.jpg</a>
thats it? but yeah..

also i changed that mistake with the color...

when i run it it still clicks every color. =/

i was thinking mabye ad a winwaitactive command, or whatever its called.
but that wld still click everycolor when its in the current window i need.

so what do i do fromk here


Problems still current
- clicks every color.
- and i get a confusing msg when i run the program.

mind giving it a test for me leaf, just so you can see what i mean?

cheers
Cyber

_________________
---{+.-}---


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2009, 1:19 pm 
Cyber wrote:
here is the image
[img]<a%20href="http://imgur.com/P5Jzy.jpg"%20title="Hosted%20by%20imgur.com">http://imgur.com/P5Jzy.jpg</a>[/img]
Cyber wrote:
sorry i think i posted that link wrong
<a href="http://imgur.com/P5Jzy.jpg" title="Hosted by imgur.com">http://imgur.com/P5Jzy.jpg</a>
thats it?

Why your link attempts didn't work (Re: how to include an image (.png) in a post)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2009, 2:37 pm 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
thanks buddy.

Still looking for why this script isnt working =s

any ideas leaf me?
anyone else is more then welcome to help aswell, thanks

_________________
---{+.-}---


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2009, 6:23 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
Did you follow my instructions on how to get the color.?

Post your line of code for the imagesearch.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2009, 6:24 am 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
i just copied and pasted your line?



i asumed thats what you meant =s

Code:
 pixelSearch  , TL , BR , X, Y, X+Width, Y+Height, 0xE6EFEF ; BLUE/GREEN/RED order 


and il post my script once again for an overview.

Code:
;============================================================================
; set coordinates for the screen so GUI position, search and clicks will align

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen

;-----------the gui hitbox---------------------------------------------------
bDim = 35 ; Change this to desired size.
;bDim = 5 ; Change this to desired size.
xPos = % (A_ScreenWidth/2) - bDim
yPos = % (A_ScreenHeight/2) - bDim

;============================================================================
; Leef_me's choice of pixel color
pixel_color= 0xBBCDCD ; search for red ; BLUE/GREEN/RED order

;Cyber's choice of pixel color
;pixel_color= 0x0000FF

;============================================================================
; If you want to test on an image you can enable this
;image = ImgQL.bmp ; <------filename goes here
;gui, add, picture, , %image%

Gui, +alwaysontop
Gui, -Caption Border AlwaysOnTop ToolWindow

; RED/GREEN/BLUE order
Gui, Color, C0C0C0
;Gui, Color, FF0000 ; <----- Leef_me's choice of GUI fill color

Gui, Show, NA W%bDim% H%bDim% X%xPos% Y%yPos%, hitBox

WinWait, hitBox
WinSet, TransColor, C0C0C0 255, hitBox

;============================================================================
; get the location of the box, without relying on the above xpos & ypos
; report actual location of the window, and save for imagesearch

WinGetPos , X, Y, Width, Height, hitBox
msgbox !%Title% x%X% Y%Y% W%Width% H%Height%! `n wanted upper_left-> X%xPos% Y%yPos% `n press OK to start search
;return

;================================================================================
;start the search

settimer, find_pixel,-1 ; wait 0.001 seconds before searching
return

;============================================================================

find_pixel:

b:=A_TickCount ; <--- measure the time the pixelsearch takes

pixelSearch  , TL , BR , X, Y, X+Width, Y+Height, 0xE6EFEF ; BLUE/GREEN/RED order 

c:=A_TickCount ; <--- measure the time the pixelsearch takes
d:=c-b

;============================================================================
; for testing, show a tooltip instead of causing a mouseclick

;tooltip, !!%errorlevel%!%TL%!%BR%!, xpos+50, ypos

; the next line shows 1/1000 second, 0 if found, x and y coordinates
;tooltip, !%d%!!%errorlevel%!%TL%!%BR%!, xpos+50, ypos

;MouseClick [, WhichButton , X, Y, ClickCount, Speed, D|U, R]

MouseClick , left , TL , BR , 1 , 10


settimer, find_pixel , -200 ; wait 0.2 seconds between searches

return

;================================================================================
f3::   ; get the color of the pixel at the mouse cursor location
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen

; coodinates are relative to screen based on CoordMode used at top of script

MouseGetPos, xx , yy
PixelGetColor, cc, xx, yy
tooltip %xx% %yy% %cc%
return
 
;----------------------------end statemnts------------------------------------
esc::
^z::ExitApp

_________________
---{+.-}---


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 68 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], rbrtryn and 28 guests


You can 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

Search for:
Powered by phpBB® Forum Software © phpBB Group