 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
HotKeyIt
Joined: 18 Jun 2008 Posts: 2198 Location: GERMANY
|
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Sat Nov 21, 2009 4:32 am Post subject: |
|
|
@HotKeyIt~
im going to try and explain it as best i can.
~ this small window im trying to create is about 30 by 30 pixels big, quite small. anywere Inside this region i want to run a continus pixel search.
if the color green becoms visible behidnt this box, then "left click"
this will be helpul in first person shooter games were the crosshair is always centred in the screen.
so genraly.. it is like making anouther crosshair that will pick up the color green and automaticly shoot.
i have chosen this way outher then pixesearching the whole screen becous
1: it defined a smaller and and much faster space to pixelsearch.
2: i will not have to maniluplate moving the crosshair to specif co-ordiantes at all.
@gunns256
thats what my alyas untop probelm is.
i need the small 30-30 pixel transparent window to "always" be ontop.
please read the abouve explanation for details.
@ anyone who still doesnt really underdstand. =S
so genraly, im asking for a pixel search in the centre of the screen, roughly about 30-30pixels... then just a gui small window ontop... whihc i have already created...(with help)
that may be an esire way to look at it _________________ ---{+.-}--- |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Sat Nov 21, 2009 12:52 pm Post subject: |
|
|
this is quite hard to explain..
a difrent aproach mabye..
ok, i whant to pixel search in a small space, lets say 30- by 30 pixels.
i whant this pixel search to always be in the midle of the screen... the script i have current is prety much a guide to show myself were this pixel search will be.
i need the pixel search to always be on the active and most top window.
along with the little gui square i have alreadys scripted (with help of the hak forums)
PS:THE LITTLE SQUARE IS ALSO 30-30 PIXELS.
thanks _________________ ---{+.-}--- |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Sat Nov 21, 2009 5:09 pm Post subject: |
|
|
any mmore support or ideas with this script would be much appreciated, im quite stuck =s
thanks
~Cyber. _________________ ---{+.-}--- |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 2198 Location: GERMANY
|
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Sun Nov 22, 2009 9:30 am Post subject: |
|
|
no i dont think so. all i ahve is a gui window. =(
is there a difrent aproach i can take? _________________ ---{+.-}--- |
|
| Back to top |
|
 |
AHKIsTheBest
Joined: 20 Jun 2009 Posts: 15
|
Posted: Sun Nov 22, 2009 9:43 am Post subject: |
|
|
| Cyber wrote: | no the oposite.
only inside this window i whant a pixel search.
so it searches the color green.. only inside the window.
thanks |
What do you mean by "window"? |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Sun Nov 22, 2009 3:49 pm Post subject: |
|
|
ok maby i ahve used the wrong word by window. but if you if you run the script i posted earlyer you will see what i mean.
the "window" is a the small and gui based, it is centred in the middle of the screen.
its not a window in regards to a web browser window, or a notepad, or something of a rather.
it is simply a small square created in the centre of the screen.
the "window"
and inside that. i wish to ahve a pixel search =)
thanks
~Cyber _________________ ---{+.-}--- |
|
| Back to top |
|
 |
AHKIsTheBest
Joined: 20 Jun 2009 Posts: 15
|
Posted: Sun Nov 22, 2009 4:48 pm Post subject: |
|
|
"Window" is a term with a very specific meaning in the GUI world, for example, it has a "window handle". I believe what you mean is just a gap in your GUI window, right? I'd suggest to avoid using the term "window" for that.
Note that the documentation for PixelSearch says "Searches a region of the screen for a pixel of the specified color", and ImageSearch "Searches a region of the screen for an image". Those do not work on windows, but on the screen.
So you just have to calculate the coordinates of the rectangle on the screen for the area you want to search. AHK helps you there since the coordinates you specify can be either absolute or relative to the Active Window. See the AHK help for that, "Coordinates are relative to the active window unless CoordMode was used to change that."
So. Forget all about windows, and just use ImageSearch/PixelSearch. If it is a game in fullscreen mode, then just use absolute coordinates and don't worry about the Active Window. |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Sun Nov 22, 2009 5:47 pm Post subject: |
|
|
Thankyou very much i have bean trying to explain this for like 4 days now =D
that helped alot.
Sorry for my error in terminology, just wasnt sure how else to explain it.
il look into what you said first thing in the morning and post back.
Thanks again
~cyber _________________ ---{+.-}--- |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Sun Nov 22, 2009 6:33 pm Post subject: |
|
|
ok i couldnt help it i done it now..
so far with a litle more help with the corection of variables from the forum, i managed to get this
| Code: |
;-----------the gui hitbox---------------------------------------------------
bDim = 35 ; Change this to desired size.
xPos = % (A_ScreenWidth/2) - bDim
yPos = % (A_ScreenHeight/2) - bDim
Gui, +alwaysontop
Gui, -Caption Border AlwaysOnTop ToolWindow
Gui, Color, C0C0C0
Gui, Show, NA W%bDim% H%bDim% X%xPos% Y%yPos%, hitBox
WinWait, hitBox
WinSet, TransColor, C0C0C0 255, hitBox
;------------the continuos pixelsearch inside the box-----------------------
Loop
{
pixelSearch , TL , BR , 806 , 490 , 841 , 524 , 10 , fast
}
;----------left click grabs the position of the color then leftclicks it----
LButton::
MouseGetPos, TL , BR
sleep 100
MouseClick , left , TL , BR , 1 , 10
sleep 100
return
;----------------------------end statemnts------------------------------------
^z::ExitApp
|
ok the problem is... it stil doesnt work.. it doesnt click th color green?
i think the problem is, in this particular green, there is alot of shades, in mixes between green and a yealow green. mabye i fix the shades?
im not sure, im just stabbing in the dark now =S
any ideas?
thanks for everything guys
~cyber _________________ ---{+.-}--- |
|
| Back to top |
|
 |
AHKIsTheBest
Joined: 20 Jun 2009 Posts: 15
|
Posted: Sun Nov 22, 2009 6:55 pm Post subject: |
|
|
| Code: |
Loop
{
pixelSearch , TL , BR , 806 , 490 , 841 , 524 , 10 , fast
}
|
Endless loop... |
|
| Back to top |
|
 |
Cyber
Joined: 11 Mar 2009 Posts: 86 Location: Nsw/Syd/Kiama
|
Posted: Mon Nov 23, 2009 4:44 am Post subject: |
|
|
ok i messed up.. badly..
i should have thought it through more lol.
i made small gui box... adn i made i if there is any green color in it and i left click... then send left click...
thats not doing anything lol, if im left clicking on green, then whats the point of making a macro that leftclicks on green at the same time i left click lol ^.^
so what i need to change is that it always searches for green in the litle gui box, and it leftclicks green itself. =S woop's
And @ AhkIsTheBest, what do you mean, i need that endles loop dont i? so that it always searches for green.. then when it finds it the next part of the script uses the variable in pixelsearchm, grabs the co-ordinates and left clicks green, and the pixelsearch still is running for next left click.
ot is that not how it works =s _________________ ---{+.-}--- |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Nov 23, 2009 6:23 pm Post subject: |
|
|
| Cyber wrote: | ok i messed up.. badly..
i should have thought it through more lol.
|
No problem mate, everyone starts out one step at a time.
You're thinking too complicated. Break it down into very small steps. Do not try to get the whole program running, get it to run one piece after the other.
Open the documentation (right click your AHK icon in the windows task bar and click "Help"), use the index to find the "Loop" command and then read what it does. You only need to read the very first sentence.
Especially, look at the word "break" in that sentence.
If that does not clear it up, then I'd suggest using the OutputDebug command and the dbgview.exe (use google to find it, it's the first hit) to find out what happens while your script is running. Or, simpler, use MsgBox to insert little popups, you'd be surprised how much even that can help. |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 1507 Location: San Diego, California
|
Posted: Tue Nov 24, 2009 1:30 am Post subject: |
|
|
I started from your script in the post that starts like this:
| Quote: | ok i couldnt help it i done it now..
so far with a litle more help with the corection of variables from the forum, i managed to get |
So, there are several errors and assumption in your script that I corrected. The script may not be perfect bit works pretty well.
The errors were:
1. PixelSearch: -- you have bad parameters for the command. Hint: what is the color "10" ?
2. PixelSearch: -- Coordinates are relative to the active window unless CoordMode was used to change that. If there was a difference in the selected window and where the game is locationed results are worthless.
3. even if you used "CoordMode, Pixel, Screen" your original search location may not correspond to the location of the box,
for example on my 1024 x 768 screen I get
x477 Y349 W37 H37 for the box window
x1 806 y1 490 x2 841 y2 524 for your search area Those don't match or even overlap !
4. as you mentioned in a later post, your pixelsearch is doing nothing useful. I added a tooltip that tells you if the color is found via errorlevel , and the x & y location. Press F2 to start it running. You could probably use that location to do your mouseclick.
btw, I added a quick 'pixel color under mouse' rountine -- F3 for snapshot.
I tested the code by creating an image with Paint with then I
| Code: | CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen
;-----------the gui hitbox---------------------------------------------------
bDim = 35 ; Change this to desired size.
xPos = % (A_ScreenWidth/2) - bDim
yPos = % (A_ScreenHeight/2) - bDim
Gui, +alwaysontop
Gui, -Caption Border AlwaysOnTop ToolWindow
Gui, Color, C0C0C0
Gui, Show, NA W%bDim% H%bDim% X%xPos% Y%yPos%, hitBox
WinWait, hitBox
WinSet, TransColor, C0C0C0 255, hitBox
WinGetPos , X, Y, Width, Height, hitBox
; report actual location of the window
msgbox !%Title% x%X% Y%Y% W%Width% H%Height%! `n wanted upper_left-> X%xPos% Y%yPos%
return
;================================================================================
f2::
;------------the continuos pixelsearch inside the box-----------------------
Loop
{
pixelSearch , TL , BR , 806 , 490 , 841 , 524 , 10 , fast
; your original search location may not correspond to the location of the box
pixelSearch , TL , BR , X, Y, X+Width, Y+Height, 0x0000FF ; search for red
;tooltip, !%errorlevel%!%TL%!%BR%!, TL+100, BR+100
tooltip, !%errorlevel%!%TL%!%BR%!, xpos+50, ypos
}
return
/*
;----------left click grabs the position of the color then leftclicks it----
LButton::
MouseGetPos, TL , BR
sleep 100
MouseClick , left , TL , BR , 1 , 10
sleep 100
return
*/
;================================================================================
f3:: ; get the color of the pixel at the mouse cursor location
; coodinates are relative to screen based on CoordMode used at top of script
MouseGetPos, xx , yy
PixelGetColor, cc, xX, xY
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
|