 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Thu Nov 26, 2009 10:48 am Post subject: |
|
|
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 _________________ ---{+.-}--- |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 1443 Location: San Diego, California
|
Posted: Fri Nov 27, 2009 5:53 am Post subject: |
|
|
| 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
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 Sat Nov 28, 2009 9:37 pm; edited 1 time in total |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Fri Nov 27, 2009 11:25 am Post subject: |
|
|
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 |
_________________ ---{+.-}--- |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Fri Nov 27, 2009 11:42 am Post subject: |
|
|
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 _________________ ---{+.-}--- |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 1443 Location: San Diego, California
|
Posted: Fri Nov 27, 2009 10:40 pm Post subject: |
|
|
Edit: OOPS! I missed that you edited the pixel color directly in the imagesearch line. 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 |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Sat Nov 28, 2009 6:11 am Post subject: |
|
|
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 _________________ ---{+.-}--- |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 1443 Location: San Diego, California
|
Posted: Sat Nov 28, 2009 7:19 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Sat Nov 28, 2009 12:00 pm Post subject: |
|
|
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. _________________ ---{+.-}--- |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 1443 Location: San Diego, California
|
Posted: Sat Nov 28, 2009 9:39 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Sun Nov 29, 2009 10:51 am Post subject: |
|
|
ok i changed the the error with pixel search i shal test it in 1 sec.
here is the image
[img]<a href="http://imgur.com/P5Jzy.jpg" title="Hosted by imgur.com">http://imgur.com/P5Jzy.jpg</a>[/img] _________________ ---{+.-}--- |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Sun Nov 29, 2009 10:56 am Post subject: |
|
|
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 _________________ ---{+.-}--- |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Nov 29, 2009 1:19 pm Post subject: |
|
|
| Cyber wrote: | here is the image
[img]<a href="http://imgur.com/P5Jzy.jpg" title="Hosted by imgur.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) |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Sun Nov 29, 2009 2:37 pm Post subject: |
|
|
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 _________________ ---{+.-}--- |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 1443 Location: San Diego, California
|
Posted: Sun Nov 29, 2009 6:23 pm Post subject: |
|
|
Did you follow my instructions on how to get the color.?
Post your line of code for the imagesearch. |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Mon Nov 30, 2009 6:24 am Post subject: |
|
|
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
|
_________________ ---{+.-}--- |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|