Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Egorx

Tell me your colour, pixel...

This topic is 5280 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK. Im gonna use diablo 2 as an example again(as those who helped me on transparencies would know). Many of you would have already seen on of these Diablo 2 LOD bots, the kind that(for example) does rushes for you. The one im using, works like this...it makes D2 run in an window, and moves the window in the upper left corner or my screen. After creating an game, it moves ur char around and kils monsters for you(very simply put).Here comes the clever bit...it needs to have an way to know where your char is, so it replaced some of d2''s tiles with green ones. When running the bot, it tests the pixels colours, and when it finds an green one, it knows roughly where it is. If this all sounds a little unclear to u, let me just ask my q. and get it over with.If i would wanna write an bot like this: 1) How would i test the colours of pixels outside my own prog.(lets say my prog uses either gdi''s getpixel or my own memory reading functionn and that it runs in widowed-mode ,next to the program of wich i will be testing the pixel colours). 2) How do i feed in keystrokes (or even mouseclicks) into this other program??

Share this post


Link to post
Share on other sites
Advertisement
1. GetPixel will work outside your window. (At least on 9x/ME, it''s possible that they limited it to the current window for 2000/XP)
2. For key presses, I use this code:

void SendKey(unsigned char key){
keybd_event(key,0,0,0);
Sleep(key_pause);
keybd_event(key,0,KEYEVENTF_KEYUP,0);
}

Mouse stuff:

void MoveMouse(int x,int y){
//Note that this only works at 1024x768.
//You can A. Get the res and plug it in here or
//B. Find another way to do this.
//(I''m pretty sure there is one, I just didn''t bother looking for too long)
float rx=x/1024.0f;
float ry=y/768.0f;
x=rx*65535;
y=ry*65535;
mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE,x,y,0,NULL);
}
void ClickAt(int x,int y){
MoveMouse(x,y);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,NULL);
Sleep(key_pause);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,NULL);
}


Hope this helps.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!