Aug 15, 2013 at 9:47pm UTC
Need help to make the source code in c++ for left/right clicking on particular text and shape..
Aug 15, 2013 at 10:41pm UTC
sdl, sfml, allegro(i think), ncurses, pdcurses. take your pick
Last edited on Aug 15, 2013 at 10:42pm UTC
Aug 15, 2013 at 10:54pm UTC
Once you learn either of those, it's simple. Just check if the mouse is inside it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
struct Box
{
int x, y;
unsigned int w, h;
}
bool mouseC(int x, int y, Box box)
{
if ((x > box.x) && x < (box.x + box.w) && (y > box.y) && (y < box.y + box.h))
{
return true ;
}
return false ;
}
(For SDL you can just use the SDL_Rect.)
(Each lib has different functions for getting mouse x and mouse y)
1 2 3 4 5 6
// SDL (All I know)
int x;
int y;
SDL_GetMouseState(&x, &y);
//(x and y should now equal mouse position)
Last edited on Aug 15, 2013 at 10:58pm UTC
Aug 17, 2013 at 7:13pm UTC
want to make mouse click on particular text or shape...not on positions..
Aug 17, 2013 at 7:16pm UTC
Get the mouse position when they click and check to see if it on the shape or text yourself.
Aug 18, 2013 at 12:18am UTC
@firedraco : what if i don't know the position of text or shape?
can anyone tell me of any good ebook which can help me for this?
Last edited on Aug 18, 2013 at 12:24am UTC
Aug 18, 2013 at 4:01am UTC
If you don't know where the shape is, how do you expect to figure out whether something is inside it?
Aug 18, 2013 at 4:46pm UTC
like if i wanna make mouse autoclick on submit on web browser in full screen mode....if i use web browser in small window ...how does it detect where the text "submit" is?
....
Last edited on Aug 19, 2013 at 1:13pm UTC
Aug 19, 2013 at 3:07pm UTC
If you're trying to make something like an IRC bot then you're thinking about this problem wrong. Everything on a website is text, the fact that you even see a button is only due to the text being interpreted by your browser. Look up how to write an IRC bot, it's not exactly what you want but the concepts should be similar.