AutoHotkey Community

It is currently May 27th, 2012, 1:32 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: November 21st, 2009, 2:06 am 
Offline

Joined: November 21st, 2009, 1:17 am
Posts: 4
First post on the boards. I've read everything that popped up through search relating to what I am trying to do and no luck. What I am trying to do is use pixel detection to lock on to the pixel that I am currently hovering over. In other words I am trying to search a small box in the middle of my screen instead of my entire window. This should stay locked until I release the key. Here is the part giving me trouble:

~F3::
MouseGetPos, begin_x, begin_y
while GetKeyState("F3")
{
MouseGetPos, x1, y1
PixelSearch, Px, Py, 0, 0, 636, 638, %color%, 0, Fast
if ErrorLevel
MsgBox, That color was not found in the specified region.
else
MouseMove, Px, Py, 0 ;0 is mouse speed, 0 is instant
}
Return



I am new to the lang so go easy on me. Thanks in advance!

-Jaws87


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

Joined: July 18th, 2006, 12:18 pm
Posts: 403
Can you give more info? Im a little puzzled in what your trying to do. You want to lock-on to a pixel? What do you mean by that?

Also use the MouseGetPos cords with the PixelSearch region if thats what your looking for.


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

Joined: November 21st, 2009, 1:17 am
Posts: 4
Ok this is what I have done so far. It works but just not like I had hoped. I don't believe there is much more I can do to make it work with the apps that I am trying. But it is flawless when using it in paint.


F1::
{
IniFile := "C:\Users\Jesse\Desktop\location.txt"
FileGetSize, size, %IniFile%
if (size = "") {
MsgBox Setting up
IniWrite, %color%, %IniFile%, location, color
} else {
IniRead, %color%, %IniFile%, location, color
}
CoordMode, Pixel
Return
}

F2::
{
MouseGetPos, x, y
PixelGetColor,color, %x%, %y%
IniWrite, %color%, %IniFile%, location, color
Return
}

~F3::
MouseGetPos, begin_x, begin_y
while GetKeyState("F3")
{
MouseGetPos, x1, y1
PixelSearch, Px, Py, 803, 524, 803, 524, %color%, 0, Fast
MouseMove, Px, Py, 0 ;0 is mouse speed, 0 is instant
}
Return



f1: creates ini file if there isn't one.
f2: selects the pixel to lock to.
Hold f3: goes to the pixel and stays on it until you let off.

I was hoping to use it in some simple flash games etc. as a means of aiming. It was a good beginner project but I just don't think PixelSearch can process it.

If you have any suggestions let me know.


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

Joined: July 18th, 2006, 12:18 pm
Posts: 403
Theres much better way to do stuff like this. First i wouldnt use GetKeyState.

You know there is also a PixelMatrixSearch right? Search the forum.

Basically it searchs or obtains a 3x3 matrix be default.. Meaning. a combination of 3x3 pixels so its uniqe. That way it wont mis-match as much.. or maybe not at all


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

Joined: November 21st, 2009, 1:17 am
Posts: 4
PixelMatrixSearch seems to be pretty advanced from the examples posted on here. I'll read up on it tommorow and modify/test it. Thanks for the support, i'll keep posting here with the changes I make.


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

Joined: July 18th, 2006, 12:18 pm
Posts: 403
It actually isnt complicated at all. 2 functions. One finds the matrix. One obtains the matrix. Just call them when you need to.


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

Joined: November 21st, 2009, 1:17 am
Posts: 4
I have made the changes and implemented PixelMatrixSearch. Seems to work on a screen cap of the game but not in the game itself?

Here is what I've got:


#NoEnv
#SingleInstance Force
#Persistent
SetBatchLines -1
SetDefaultMouseSpeed, 0
SetControlDelay, -1
Process,priority,,low

SetBatchLines, -1
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen

f1::
MouseGetPos, mX, mY
SplashImage, Off
Matrix := GetMatrix(mX,mY,4)
Matrixtemp := Matrix
again:
soundbeep 3000
Result := FindMatrix(1,1600,1,1200,4,Matrix)


~f2::
MouseGetPos, begin_x, begin_y
while GetKeyState("f2")
{
Result := FindMatrix(1,1600,1,1200,4,Matrix)
StringSplit, Result, Result, %A_Space%
Mousemove, %Result1%, %Result2%
}
Return

f3:: reload


Once again, I am open to any suggestions. Thanks.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Blackholyman, bobbysoon, Google [Bot], iDrug, Ohnitiel, Yahoo [Bot] and 18 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