AutoHotkey Community

It is currently May 27th, 2012, 2:40 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 20th, 2009, 5:25 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Yes, will be one of problems.

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 21st, 2009, 4:32 am 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
@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

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 21st, 2009, 12:52 pm 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
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

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 21st, 2009, 5:09 pm 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
any mmore support or ideas with this script would be much appreciated, im quite stuck =s

thanks
~Cyber.

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 21st, 2009, 7:59 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Does PixelSearch work in your window, at all?
Does Click work?

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 9:30 am 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
no i dont think so. all i ahve is a gui window. =(
is there a difrent aproach i can take?

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 9:43 am 
Offline

Joined: June 20th, 2009, 8:55 pm
Posts: 19
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"?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 3:49 pm 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
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

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 4:48 pm 
Offline

Joined: June 20th, 2009, 8:55 pm
Posts: 19
"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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 5:47 pm 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
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

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 6:33 pm 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
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

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 6:55 pm 
Offline

Joined: June 20th, 2009, 8:55 pm
Posts: 19
Code:
Loop
{
 pixelSearch  , TL , BR , 806 , 490 , 841 , 524 , 10 , fast
}


Endless loop...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2009, 4:44 am 
Offline

Joined: March 11th, 2009, 12:00 am
Posts: 86
Location: Nsw/Syd/Kiama
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

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2009, 6:23 pm 
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.


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

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
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 ! :x

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


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: Alpha Bravo, Bing [Bot], rbrtryn and 19 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