AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pixel Search Looping

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
patgenn123



Joined: 03 Jul 2008
Posts: 3

PostPosted: Sat Jul 19, 2008 2:49 am    Post subject: Pixel Search Looping Reply with quote

Hello. I am very new and it's my first post! I would like to say hello to all.

I also wanted to say that compared to a lot of people here, I have absolutely no idea of what I am doing, YET Laughing

I have no programming experience and have only some practice with a program called MacroExpress. Outside of that, little vbs and some hta.

So it's exciting to find such an incredible program! it might take a while to learn.

Anyway, I looked at pixel topics and couldn't find one quite like I had in mind.

So HERE I Go! I ask that you not give me full code. Just for places to look, help sections etc.

What I would like to do is have the pixel color underneath the mouse always trying to find a specific pixel in a specific program. I would prefer to have the mouse pixel search going on whether the window is active or behind the active window(if it's some other window on top). If the declared pixel is found, run/launch some other program.

Can I get a hint or several hints on how to do this?

Thanks!

Pat
Back to top
View user's profile Send private message
infogulch



Joined: 27 Mar 2008
Posts: 150
Location: USA

PostPosted: Sat Jul 19, 2008 4:22 am    Post subject: Reply with quote

maybe something like this: (not tested, just for reference)

Code:
MyWinTitle = title of window ;the title of the window this works in
MyPixelColor = 0x00FF00 ;six digit hex color value
SetWinDelay, -1

loop,
{
   sleep 50   ;wait 50 ms
   ;get the window id of the window under the mouse as well as it's position
    MouseGetPos, MouseX, MouseY, MouseWinID   
   WinGetTitle, MouseWinTitle, ahk_id %MouseWinID%     ;get the title of that window
   If (MouseWinTitle = MyWinTitle)    ;compare with your variable set above, if they're the same, continue
   {
      PixelGetColor, MouseColor, MouseX, MouseY ;get the color of the pixel under the mouse
      If (MouseColor = MyPixelColor) ;compare with what you set above, if they're the same, go on.
         Gosub, DoSomething
   }
}

DoSomething:
   ;do something here
return


About:

Variables
SetWinDelay
Loop
Sleep
MouseGetPos
WinGetTitle
If
PixelGetColor
GoSub

it could be expanded a lot, e.g. a range of colors instead of just one, fix the title if so it doesn't have to be exact, etc.

hope this helps Smile
_________________
Back to top
View user's profile Send private message
SpiderGames



Joined: 09 Jun 2008
Posts: 341
Location: Canada

PostPosted: Sat Jul 19, 2008 5:01 am    Post subject: Reply with quote

lol.. something easyer would be like...
Code:

Loop,
{ ; start of looped actions
Sleep, 400 ; Sleeps 0.4 seconds every time... makes less CPU usage
MouseGetPos, Mousex, MouseY ; get the mouse's position and stores the X value as "MouseX" (can be anything amke it "Pizza if you want) and the Y as MouseY.
PixelGetColor, color, %MouseX%, %MouseY% ; get the colour Id (Numbers in Hex.) at the position of the mouse and store the Hex. number as the variable "color".
if color = 0xFFFFFF ; just white make it w/e colour you want....
 { ; start of icolated action
   Run, http://www.google.ca ; Runs google change it to w/e you want.
 } ; End of action
} ; End of loop action...

Try that
_________________
Join Rubies of Eventide. It's a Fun, Free, 3D mmorpg. Add to the 60 people that play Pheonix Server. Nice place to get away.

Join at www.eventide.net =D
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group