Click here to Skip to main content
15,611,306 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,
As you know , some of the headers in widows are different with linux.
So i could nt run my C code in linux Fedora.
Please guide me, how can i write that left click of the mouse press down and press up in C .
Which header i have to use ?
And what code i have to write?

Thank you

What I have tried:

I have used Windows.h and winuser as header but doesnt work.
I used code: input mouse event
Updated 24-Jan-23 5:50am
Dave Kreskowiak 25-Jul-22 10:16am    
If you're using windows.h, you're not using C#.

So which is it? C or C#? The two languages are nowhere close to being the same.
Member 15527623 25-Jul-22 10:22am    
C is correct
Richard MacCutchan 25-Jul-22 11:22am    
You need to use a framework that can run Windows code on a Linux OS, or rework your code to use one of the available supported GUI libraries (GTK, Qt, opencv etc.).

1 solution

I don't know how to write any of the code, but I do have an idea of how you can approach the problem:
Get the user input, if it matches the mouse button your looking for, go onto a while loop which is while the mouse button is held down, call a click function which, surprisingly, clicks. Some pseudo-code below.

// gets user input
int input = get_user_input();
// for mouse
if(input == MOUSE_BUTTON_LEFT)
    // runs while mouse button is held down
    while(get_user_input(MOUSE_BUTTON_LEFT) == BUTTON_PRESS)
        // this function makes a click
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900