mouse click

Need help to make the source code in c++ for left/right clicking on particular text and shape..
closed account (Dy7SLyTq)
sdl, sfml, allegro(i think), ncurses, pdcurses. take your pick
Last edited on
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
want to make mouse click on particular text or shape...not on positions..
Get the mouse position when they click and check to see if it on the shape or text yourself.
@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
If you don't know where the shape is, how do you expect to figure out whether something is inside it?
want to make mouse click on particular text or shape...not on positions..
I just explained how to click on a flipping rectangle.

You can make any shape from rectangles on PCs. (Pixels are squares)
what if i don't know the position of text or shape?


i are you asking if the text of shape is outside of your program?
what if i don't know the position of text or shape?
Your program will always know the position of text or shape. What you're saying makes no sense. Explain.
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
can anyone help??
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.
Topic archived. No new replies allowed.